Skip to content

Commit

Permalink
test: add set propose api step (#11445)
Browse files Browse the repository at this point in the history
* Revert "test: fix sideloading disabled (#11421)"

* test: add set propose api step

* test: adjust test flow

---------

Co-authored-by: Ivan_Chen <[email protected]>
  • Loading branch information
ayachensiyuan and Ivan_Chen authored Apr 23, 2024
1 parent 5f9af3c commit 2c983f9
Show file tree
Hide file tree
Showing 6 changed files with 16 additions and 33 deletions.
5 changes: 5 additions & 0 deletions .github/workflows/ui-test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
2 changes: 1 addition & 1 deletion packages/tests/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
3 changes: 0 additions & 3 deletions packages/tests/src/ui-test/testContext.ts
Original file line number Diff line number Diff line change
@@ -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";
Expand All @@ -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;
Expand All @@ -31,7 +29,6 @@ export class TestContext {

public async before(): Promise<void> {
await fs.ensureDir(this.testRootFolder);
createVscodeArgvFile();
await VSBrowser.instance.waitForWorkbench();
this.browser = await chromium.launch({
headless: false,
Expand Down
2 changes: 0 additions & 2 deletions packages/tests/src/ui-test/treeview/treeviewContext.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand All @@ -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"));
Expand Down
24 changes: 0 additions & 24 deletions packages/tests/src/utils/commonUtils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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";
Expand Down Expand Up @@ -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);
}
13 changes: 10 additions & 3 deletions packages/tests/src/utils/vscodeOperation.ts
Original file line number Diff line number Diff line change
Expand Up @@ -51,9 +51,16 @@ export async function ensureExtensionActivated(): Promise<void> {
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)) {
Expand Down

0 comments on commit 2c983f9

Please sign in to comment.