From a481120cc1cc22f1b0ad234b707cb0fda70aca5c Mon Sep 17 00:00:00 2001 From: Ivan_Chen Date: Tue, 30 Apr 2024 13:59:47 +0800 Subject: [PATCH 1/6] test: add tab docker sample --- ...-localdebug-hello-world-tab-docker.test.ts | 56 +++++++++++++++++++ .../src/ui-test/samples/sampleCaseFactory.ts | 8 ++- packages/tests/src/utils/constants.ts | 7 ++- .../tests/src/utils/playwrightOperation.ts | 3 + 4 files changed, 72 insertions(+), 2 deletions(-) create mode 100644 packages/tests/src/ui-test/samples/sample-localdebug-hello-world-tab-docker.test.ts diff --git a/packages/tests/src/ui-test/samples/sample-localdebug-hello-world-tab-docker.test.ts b/packages/tests/src/ui-test/samples/sample-localdebug-hello-world-tab-docker.test.ts new file mode 100644 index 0000000000..0bc4cbb1f0 --- /dev/null +++ b/packages/tests/src/ui-test/samples/sample-localdebug-hello-world-tab-docker.test.ts @@ -0,0 +1,56 @@ +// Copyright (c) Microsoft Corporation. +// Licensed under the MIT license. + +/** + * @author Ivan Chen + */ + +import { Page } from "playwright"; +import { TemplateProject, LocalDebugTaskLabel } from "../../utils/constants"; +import { validateTab, reopenPage } from "../../utils/playwrightOperation"; +import { CaseFactory } from "./sampleCaseFactory"; +import { Env } from "../../utils/env"; +import { SampledebugContext } from "./sampledebugContext"; + +class HelloWorldTabDockerTestCase extends CaseFactory { + override async onValidate( + page: Page, + options?: { includeFunction: boolean } + ): Promise { + return await validateTab(page, { + displayName: Env.displayName, + includeFunction: options?.includeFunction, + }); + } + override async onCliValidate( + page: Page, + options?: { includeFunction: boolean } + ): Promise { + return await validateTab(page, { + displayName: Env.displayName, + includeFunction: options?.includeFunction, + }); + } + public override async onReopenPage( + sampledebugContext: SampledebugContext, + teamsAppId: string + ): Promise { + return await reopenPage( + sampledebugContext.context!, + teamsAppId, + Env.username, + Env.password, + undefined, + true, + true + ); + } +} + +new HelloWorldTabDockerTestCase( + TemplateProject.HelloWorldTabDocker, + 12684063, + "v-ivanchen@microsoft.com", + "local", + [LocalDebugTaskLabel.DockerTask] +).test(); diff --git a/packages/tests/src/ui-test/samples/sampleCaseFactory.ts b/packages/tests/src/ui-test/samples/sampleCaseFactory.ts index a4c8a2b530..4e44040b91 100644 --- a/packages/tests/src/ui-test/samples/sampleCaseFactory.ts +++ b/packages/tests/src/ui-test/samples/sampleCaseFactory.ts @@ -101,7 +101,13 @@ const debugMap: Record Promise> = { [LocalDebugTaskLabel.DockerRun]: async () => { await waitForTerminal( LocalDebugTaskLabel.DockerRun, - LocalDebugTaskResult.WebServerSuccess + LocalDebugTaskResult.DockerFinish + ); + }, + [LocalDebugTaskLabel.DockerTask]: async () => { + await waitForTerminal( + LocalDebugTaskLabel.DockerTask, + LocalDebugTaskResult.DockerFinish ); }, }; diff --git a/packages/tests/src/utils/constants.ts b/packages/tests/src/utils/constants.ts index 096a8fedeb..573ae4fce2 100644 --- a/packages/tests/src/utils/constants.ts +++ b/packages/tests/src/utils/constants.ts @@ -58,6 +58,7 @@ export enum TemplateProject { TabSSOApimProxy = "SSO Enabled Tab via APIM Proxy", LargeScaleBot = "Large Scale Notification Bot", BotSSODocker = "Containerized Bot App with SSO Enabled", + HelloWorldTabDocker = "Containerized Hello World Tab with Backend", } export enum TemplateProjectFolder { @@ -91,6 +92,7 @@ export enum TemplateProjectFolder { RetailDashboard = "react-retail-dashboard", TabSSOApimProxy = "sso-enabled-tab-via-apim-proxy", LargeScaleBot = "large-scale-notification", + HelloWorldTabDocker = "hello-world-tab-docker", // v2 only Deeplinking = "deep-linking-hello-world-tab-without-sso-M365", } @@ -130,6 +132,8 @@ export const sampleProjectMap: Record = [TemplateProject.TabSSOApimProxy]: TemplateProjectFolder.TabSSOApimProxy, [TemplateProject.LargeScaleBot]: TemplateProjectFolder.LargeScaleBot, [TemplateProject.BotSSODocker]: TemplateProjectFolder.BotSSODocker, + [TemplateProject.HelloWorldTabDocker]: + TemplateProjectFolder.HelloWorldTabDocker, }; export enum Resource { @@ -383,6 +387,7 @@ export enum LocalDebugTaskLabel { Compile = "Compile typescript", StartWebServer = "Start web server", DockerRun = "docker-run: debug", + DockerTask = "docker", } export class LocalDebugTaskResult { @@ -397,7 +402,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"; + static readonly DockerFinish = "press any key to close it"; } export enum LocalDebugTaskLabel2 { diff --git a/packages/tests/src/utils/playwrightOperation.ts b/packages/tests/src/utils/playwrightOperation.ts index 868ea7cada..9528757431 100644 --- a/packages/tests/src/utils/playwrightOperation.ts +++ b/packages/tests/src/utils/playwrightOperation.ts @@ -104,6 +104,9 @@ export const debugInitMap: Record Promise> = { [TemplateProject.BotSSODocker]: async () => { await startDebugging("Debug in Docker (Chrome)"); }, + [TemplateProject.HelloWorldTabDocker]: async () => { + await startDebugging("Debug in Teams (Chrome)"); + }, }; export async function initPage( From 7992f8774f99cb7c120f4295382b76da5241ab0a Mon Sep 17 00:00:00 2001 From: Ivan_Chen Date: Tue, 30 Apr 2024 14:47:54 +0800 Subject: [PATCH 2/6] test: add tab docker sample --- packages/tests/scripts/randomCases.json | 4 ++- .../sample-remotedebug-bot-sso-docker.test.ts | 2 +- ...remotedebug-hello-world-tab-docker.test.ts | 33 +++++++++++++++++++ 3 files changed, 37 insertions(+), 2 deletions(-) create mode 100644 packages/tests/src/ui-test/samples/sample-remotedebug-hello-world-tab-docker.test.ts diff --git a/packages/tests/scripts/randomCases.json b/packages/tests/scripts/randomCases.json index 0a9c0c47ca..4526ed8997 100644 --- a/packages/tests/scripts/randomCases.json +++ b/packages/tests/scripts/randomCases.json @@ -186,7 +186,9 @@ }, "cases": [ "sample-localdebug-bot-sso-docker", - "sample-remotedebug-bot-sso-docker" + "sample-remotedebug-bot-sso-docker", + "sample-localdebug-hello-world-tab-docker.test", + "sample-remotedebug-hello-world-tab-docker.test" ] } ] \ No newline at end of file diff --git a/packages/tests/src/ui-test/samples/sample-remotedebug-bot-sso-docker.test.ts b/packages/tests/src/ui-test/samples/sample-remotedebug-bot-sso-docker.test.ts index f87e6a6cce..b15dc98c5b 100644 --- a/packages/tests/src/ui-test/samples/sample-remotedebug-bot-sso-docker.test.ts +++ b/packages/tests/src/ui-test/samples/sample-remotedebug-bot-sso-docker.test.ts @@ -6,7 +6,7 @@ */ import { Page } from "playwright"; -import { TemplateProject, LocalDebugTaskLabel } from "../../utils/constants"; +import { TemplateProject } from "../../utils/constants"; import { validateBot } from "../../utils/playwrightOperation"; import { CaseFactory } from "./sampleCaseFactory"; import { Env } from "../../utils/env"; diff --git a/packages/tests/src/ui-test/samples/sample-remotedebug-hello-world-tab-docker.test.ts b/packages/tests/src/ui-test/samples/sample-remotedebug-hello-world-tab-docker.test.ts new file mode 100644 index 0000000000..afdd1ac3fa --- /dev/null +++ b/packages/tests/src/ui-test/samples/sample-remotedebug-hello-world-tab-docker.test.ts @@ -0,0 +1,33 @@ +// Copyright (c) Microsoft Corporation. +// Licensed under the MIT license. + +/** + * @author Ivan Chen + */ + +import { Page } from "playwright"; +import { TemplateProject } from "../../utils/constants"; +import { validateTab } from "../../utils/playwrightOperation"; +import { CaseFactory } from "./sampleCaseFactory"; +import { Env } from "../../utils/env"; + +class HelloWorldTabDockerTestCase extends CaseFactory { + override async onValidate( + page: Page, + options?: { includeFunction: boolean } + ): Promise { + return await validateTab(page, { + displayName: Env.displayName, + includeFunction: options?.includeFunction, + }); + } +} + +new HelloWorldTabDockerTestCase( + TemplateProject.HelloWorldTabDocker, + 12684063, + "v-ivanchen@microsoft.com", + "dev", + undefined, + { container: true } +).test(); From a57854071fe06fcd4bf578b4803fde38d04d5533 Mon Sep 17 00:00:00 2001 From: Ivan_Chen Date: Tue, 30 Apr 2024 15:17:05 +0800 Subject: [PATCH 3/6] test: update sample test app name --- .../tests/src/ui-test/samples/sampleCaseFactory.ts | 2 ++ .../tests/src/ui-test/samples/sampledebugContext.ts | 11 +++++++++++ 2 files changed, 13 insertions(+) diff --git a/packages/tests/src/ui-test/samples/sampleCaseFactory.ts b/packages/tests/src/ui-test/samples/sampleCaseFactory.ts index 4e44040b91..18638aadf2 100644 --- a/packages/tests/src/ui-test/samples/sampleCaseFactory.ts +++ b/packages/tests/src/ui-test/samples/sampleCaseFactory.ts @@ -336,6 +336,8 @@ export abstract class CaseFactory { try { // create project await sampledebugContext.openResourceFolder(); + // update manifest app name + await sampledebugContext.updateManifestAppName(); // use 1st middleware to process typical sample await onAfterCreate(sampledebugContext, env, azSqlHelper); diff --git a/packages/tests/src/ui-test/samples/sampledebugContext.ts b/packages/tests/src/ui-test/samples/sampledebugContext.ts index 331666990d..306c27b4be 100644 --- a/packages/tests/src/ui-test/samples/sampledebugContext.ts +++ b/packages/tests/src/ui-test/samples/sampledebugContext.ts @@ -257,6 +257,17 @@ export class SampledebugContext extends TestContext { ); } + public async updateManifestAppName(): Promise { + console.log("update manifest file"); + const manifestFile = + path.resolve(this.projectPath, "appPackage", "manifest.json") ?? + path.resolve(this.projectPath, "appManifest", "manifest.json"); + const manifest = await fs.readJSON(manifestFile); + manifest.name.short = this.appName + "${{APP_NAME_SUFFIX}}"; + fs.writeJSON(manifestFile, manifest, { spaces: 4 }); + console.log("update manifest file successfully"); + } + public async openExistFolder(path: string): Promise { await openExistingProject(path); } From e62a3f7db90659c28f53b1da351760e70b1208f4 Mon Sep 17 00:00:00 2001 From: Ivan_Chen Date: Tue, 30 Apr 2024 15:18:43 +0800 Subject: [PATCH 4/6] test: update sample test app name --- packages/tests/src/ui-test/samples/sampledebugContext.ts | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/packages/tests/src/ui-test/samples/sampledebugContext.ts b/packages/tests/src/ui-test/samples/sampledebugContext.ts index 306c27b4be..e917fe5339 100644 --- a/packages/tests/src/ui-test/samples/sampledebugContext.ts +++ b/packages/tests/src/ui-test/samples/sampledebugContext.ts @@ -258,14 +258,17 @@ export class SampledebugContext extends TestContext { } public async updateManifestAppName(): Promise { - console.log("update manifest file"); + console.log("[start] update manifest file"); const manifestFile = path.resolve(this.projectPath, "appPackage", "manifest.json") ?? path.resolve(this.projectPath, "appManifest", "manifest.json"); const manifest = await fs.readJSON(manifestFile); manifest.name.short = this.appName + "${{APP_NAME_SUFFIX}}"; fs.writeJSON(manifestFile, manifest, { spaces: 4 }); - console.log("update manifest file successfully"); + console.log( + "[finish] update manifest file successfully, appName: ", + manifest.name.short + ); } public async openExistFolder(path: string): Promise { From 37388e02b341823b32fe6d0ae9307d553c54e76b Mon Sep 17 00:00:00 2001 From: Ivan_Chen Date: Tue, 30 Apr 2024 15:29:45 +0800 Subject: [PATCH 5/6] test: update sample test app name --- packages/tests/src/ui-test/samples/sampledebugContext.ts | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/packages/tests/src/ui-test/samples/sampledebugContext.ts b/packages/tests/src/ui-test/samples/sampledebugContext.ts index e917fe5339..87dbc90866 100644 --- a/packages/tests/src/ui-test/samples/sampledebugContext.ts +++ b/packages/tests/src/ui-test/samples/sampledebugContext.ts @@ -263,7 +263,9 @@ export class SampledebugContext extends TestContext { path.resolve(this.projectPath, "appPackage", "manifest.json") ?? path.resolve(this.projectPath, "appManifest", "manifest.json"); const manifest = await fs.readJSON(manifestFile); - manifest.name.short = this.appName + "${{APP_NAME_SUFFIX}}"; + // manifest name can't be longer than 15 characters + manifest.name.short = + this.appName.substring(0, 10) + "${{APP_NAME_SUFFIX}}"; fs.writeJSON(manifestFile, manifest, { spaces: 4 }); console.log( "[finish] update manifest file successfully, appName: ", From 4fae73a59dd030b9b5e74e4aa4349a6315e57afb Mon Sep 17 00:00:00 2001 From: Ivan_Chen Date: Tue, 30 Apr 2024 16:17:45 +0800 Subject: [PATCH 6/6] test: update sample test app name --- .../samples/sample-localdebug-hello-world-tab-docker.test.ts | 2 +- .../samples/sample-remotedebug-hello-world-tab-docker.test.ts | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/packages/tests/src/ui-test/samples/sample-localdebug-hello-world-tab-docker.test.ts b/packages/tests/src/ui-test/samples/sample-localdebug-hello-world-tab-docker.test.ts index 0bc4cbb1f0..b38d4c877c 100644 --- a/packages/tests/src/ui-test/samples/sample-localdebug-hello-world-tab-docker.test.ts +++ b/packages/tests/src/ui-test/samples/sample-localdebug-hello-world-tab-docker.test.ts @@ -49,7 +49,7 @@ class HelloWorldTabDockerTestCase extends CaseFactory { new HelloWorldTabDockerTestCase( TemplateProject.HelloWorldTabDocker, - 12684063, + 27085868, "v-ivanchen@microsoft.com", "local", [LocalDebugTaskLabel.DockerTask] diff --git a/packages/tests/src/ui-test/samples/sample-remotedebug-hello-world-tab-docker.test.ts b/packages/tests/src/ui-test/samples/sample-remotedebug-hello-world-tab-docker.test.ts index afdd1ac3fa..9d80b4df96 100644 --- a/packages/tests/src/ui-test/samples/sample-remotedebug-hello-world-tab-docker.test.ts +++ b/packages/tests/src/ui-test/samples/sample-remotedebug-hello-world-tab-docker.test.ts @@ -25,7 +25,7 @@ class HelloWorldTabDockerTestCase extends CaseFactory { new HelloWorldTabDockerTestCase( TemplateProject.HelloWorldTabDocker, - 12684063, + 27852473, "v-ivanchen@microsoft.com", "dev", undefined,