Skip to content

Commit

Permalink
test: add docker sample
Browse files Browse the repository at this point in the history
  • Loading branch information
Ivan_Chen committed Apr 29, 2024
1 parent 6f439b9 commit 0adff00
Show file tree
Hide file tree
Showing 5 changed files with 12 additions and 1 deletion.
1 change: 1 addition & 0 deletions packages/tests/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,7 @@ CI_ENABLED=true
- (**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
- (**OPTIONAL**) If local test docker cases, Run `npx extest install-from-marketplace --storage .test-resources --extensions_dir .test-resources --type stable ms-azuretools.vscode-docker` to install docker extension.
- (**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
- (**OPTIONAL**) If you want to debug your case via vscode, replace "YOUR TEST CASE" with your case name in .vscode/launch.json and click F5

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -31,5 +31,5 @@ new BotSSODockerTestCase(
26577671,
"[email protected]",
"local",
[LocalDebugTaskLabel.StartLocalTunnel, LocalDebugTaskLabel.StartApplication]
[LocalDebugTaskLabel.StartLocalTunnel, LocalDebugTaskLabel.DockerRun]
).test();
6 changes: 6 additions & 0 deletions packages/tests/src/ui-test/samples/sampleCaseFactory.ts
Original file line number Diff line number Diff line change
Expand Up @@ -98,6 +98,12 @@ const debugMap: Record<LocalDebugTaskLabel, () => Promise<void>> = {
LocalDebugTaskResult.WebServerSuccess
);
},
[LocalDebugTaskLabel.DockerRun]: async () => {
await waitForTerminal(
LocalDebugTaskLabel.DockerRun,
LocalDebugTaskResult.WebServerSuccess
);
},
};

export abstract class CaseFactory {
Expand Down
2 changes: 2 additions & 0 deletions packages/tests/src/utils/constants.ts
Original file line number Diff line number Diff line change
Expand Up @@ -382,6 +382,7 @@ export enum LocalDebugTaskLabel {
Azurite = "Start Azurite emulator",
Compile = "Compile typescript",
StartWebServer = "Start web server",
DockerRun = "docker-run: debug",
}

export class LocalDebugTaskResult {
Expand All @@ -396,6 +397,7 @@ export class LocalDebugTaskResult {
static readonly Error = "error";
static readonly DebuggerAttached = "Debugger attached";
static readonly WebServerSuccess = "press h to show help";
static readonly DockerRunFinish = "press any key to close it";
}

export enum LocalDebugTaskLabel2 {
Expand Down
2 changes: 2 additions & 0 deletions packages/tests/src/utils/vscodeOperation.ts
Original file line number Diff line number Diff line change
Expand Up @@ -220,6 +220,7 @@ export async function execCommandIfExist(
): Promise<void> {
const driver = VSBrowser.instance.driver;
await VSBrowser.instance.waitForWorkbench();
console.log("[start] run vsc command: ", commandName);
if (os.type() === "Darwin") {
// command + P
await driver.actions().keyDown(Key.COMMAND).keyDown("P").perform();
Expand All @@ -245,6 +246,7 @@ export async function execCommandIfExist(
if (timeout) {
await driver.sleep(timeout);
}
console.log("[finish] run vsc command successfully");
return;
}
}
Expand Down

0 comments on commit 0adff00

Please sign in to comment.