diff --git a/.github/workflows/ui-test.yml b/.github/workflows/ui-test.yml index 0c544139fd..217af787aa 100644 --- a/.github/workflows/ui-test.yml +++ b/.github/workflows/ui-test.yml @@ -452,6 +452,11 @@ jobs: $vsix = (Get-ChildItem *.vsix | Select-Object -ExpandProperty Name) npx extest install-vsix --storage .test-resources --extensions_dir .test-resources --type stable --vsix_file $vsix + - name: proposal api support + run: | + mkdir -p $HOME/.vscode + echo '{"enable-proposed-api": ["TeamsDevApp.ms-teams-vscode-extension"]}' > $HOME/.vscode/argv.json + - name: Run UI Test(ubuntu) if: matrix.os == 'ubuntu-latest' working-directory: packages/tests diff --git a/packages/tests/README.md b/packages/tests/README.md index 1f9203d4a5..7b60bbc166 100644 --- a/packages/tests/README.md +++ b/packages/tests/README.md @@ -46,7 +46,7 @@ CI_ENABLED=true ``` - (**Required**) Run `npx extest get-vscode --storage .test-resources --type stable --code_version 1.88.1` to download vscode -- (**Required**) Run `npx extest get-chromedriver --storage .test-resources --type stable --code_version 1.88.1` to download chromedriver(known issue: current chromedriver version may not availble, you can use another lower version or download it manually and replace it in .test-resources https://googlechromelabs.github.io/chrome-for-testing/) +- (**Required**) Run `npx extest get-chromedriver --storage .test-resources --type stable --code_version 1.88.1` to download chromedriver - (**Required**) Download TeamsFx vsix file to this project root folder. You can download it from the [artifacts of TeamsFx CD action](https://github.com/OfficeDev/TeamsFx/actions/workflows/cd.yml). Remember to unzip. - (**Required**) Run `npx extest install-vsix --storage .test-resources --extensions_dir .test-resources --type stable --vsix_file ${{ YOUR VSIX FILE NAME }} ` to install Teams Toolkit - (**Required**) Run `npx extest run-tests --storage .test-resources --extensions_dir .test-resources --type stable --code_version 1.88.1 --code_settings ./settings.json ./out/ui-test/**/${{ YOUR TEST CASE }}.test.js` to execute your case diff --git a/packages/tests/src/ui-test/testContext.ts b/packages/tests/src/ui-test/testContext.ts index 132f681bde..90e2656ecd 100644 --- a/packages/tests/src/ui-test/testContext.ts +++ b/packages/tests/src/ui-test/testContext.ts @@ -1,6 +1,5 @@ // Copyright (c) Microsoft Corporation. // Licensed under the MIT license. - import * as path from "path"; import * as fs from "fs-extra"; import { VSBrowser } from "vscode-extension-tester"; @@ -16,7 +15,6 @@ import { import { getAppName, getScreenshotName } from "../utils/nameUtil"; import { dotenvUtil } from "../utils/envUtil"; import { Env } from "../utils/env"; -import { createVscodeArgvFile } from "../utils/commonUtils"; export class TestContext { public browser?: Browser; @@ -31,7 +29,6 @@ export class TestContext { public async before(): Promise { await fs.ensureDir(this.testRootFolder); - createVscodeArgvFile(); await VSBrowser.instance.waitForWorkbench(); this.browser = await chromium.launch({ headless: false, diff --git a/packages/tests/src/ui-test/treeview/treeviewContext.ts b/packages/tests/src/ui-test/treeview/treeviewContext.ts index fd54f09f5f..862e9fe622 100644 --- a/packages/tests/src/ui-test/treeview/treeviewContext.ts +++ b/packages/tests/src/ui-test/treeview/treeviewContext.ts @@ -23,7 +23,6 @@ import { ensureExtensionActivated, } from "../../utils/vscodeOperation"; import { getScreenshotName } from "../../utils/nameUtil"; -import { createVscodeArgvFile } from "../../utils/commonUtils"; export class TreeViewTestContext extends TestContext { public testName: string; @@ -35,7 +34,6 @@ export class TreeViewTestContext extends TestContext { public async before() { await fs.ensureDir(this.testRootFolder); - createVscodeArgvFile(); await VSBrowser.instance.waitForWorkbench(); await VSBrowser.instance.driver.sleep(Timeout.reloadWindow); await VSBrowser.instance.takeScreenshot(getScreenshotName("before")); diff --git a/packages/tests/src/utils/commonUtils.ts b/packages/tests/src/utils/commonUtils.ts index 6261291718..6cef9a8d8d 100644 --- a/packages/tests/src/utils/commonUtils.ts +++ b/packages/tests/src/utils/commonUtils.ts @@ -4,7 +4,6 @@ import { FeatureFlagName } from "./constants"; import * as path from "path"; import * as fs from "fs-extra"; import * as chai from "chai"; -import * as os from "os"; import { dotenvUtil } from "./envUtil"; import { TestFilePath } from "./constants"; import { exec, spawn, SpawnOptionsWithoutStdio } from "child_process"; @@ -366,26 +365,3 @@ export async function updateDeverloperInManifestFile( console.log("Replaced the properties of developer in manifest file"); await fs.writeJSON(manifestFile, context, { spaces: 4 }); } - -/** - * Create a file named argv.json in the .vscode folder in the user's home directory. - * fix issue: TTK sideloading extension is not enabled in vscode - */ -export function createVscodeArgvFile(): void { - const userDir = os.homedir(); - const vscodeDir = path.join(userDir, ".vscode"); - const vscodeArgvPath = path.join(vscodeDir, "argv.json"); - const content = { - "enable-proposed-api": ["TeamsDevApp.ms-teams-vscode-extension"], - }; - - if (!fs.existsSync(vscodeDir)) { - console.log("Creating .vscode directory in the user's home directory."); - console.log("vscodeArgvPath: ", vscodeArgvPath); - fs.mkdirSync(vscodeDir); - } - - fs.writeFileSync(vscodeArgvPath, JSON.stringify(content, null, 2)); - console.log("argv.json file created successfully."); - console.log(content); -} diff --git a/packages/tests/src/utils/vscodeOperation.ts b/packages/tests/src/utils/vscodeOperation.ts index ee7a352564..a14898fbb2 100644 --- a/packages/tests/src/utils/vscodeOperation.ts +++ b/packages/tests/src/utils/vscodeOperation.ts @@ -51,9 +51,16 @@ export async function ensureExtensionActivated(): Promise { const sidebar = await driver.findElement( By.id("workbench.parts.sidebar") ); - const welcomeView = await sidebar.findElement( - By.className("welcome-view-content") - ); + let welcomeView: WebElement; + try { + welcomeView = await sidebar.findElement( + By.className("welcome-view-content") + ); + } catch (error) { + welcomeView = await sidebar.findElement( + By.className("split-view-container") + ); + } if (welcomeView) { const welcomeContent = await welcomeView.getText(); if (welcomeContent.includes(Extension.sidebarWelcomeContentName)) {