diff --git a/packages/tests/src/ui-test/localdebug/localdebug-obo-tab-ts.test.ts b/packages/tests/src/ui-test/localdebug/localdebug-obo-tab-ts.test.ts index f4b99362d5..b298ae916e 100644 --- a/packages/tests/src/ui-test/localdebug/localdebug-obo-tab-ts.test.ts +++ b/packages/tests/src/ui-test/localdebug/localdebug-obo-tab-ts.test.ts @@ -88,13 +88,9 @@ describe("Local Debug M365 Tests", function () { ); await localDebugTestContext.validateLocalStateForTab(); await validateReactTab(page, Env.displayName, true); - const url = page.url(); - const pattern = - /https:\/\/teams\.microsoft\.com\/_#\/apps\/(.*)\/sections\/index.*/; - const result = url.match(pattern); - const internalId = result![1]; + const m365AppId = await localDebugTestContext.getM365AppId(); await page.goto( - `https://outlook.office.com/host/${internalId}/index?login_hint=${Env.username}` + `https://outlook.office.com/host/${m365AppId}/index?login_hint=${Env.username}` ); await validateReactOutlookTab(page, Env.displayName, true); } diff --git a/packages/tests/src/ui-test/localdebug/localdebug-obo-tab.test.ts b/packages/tests/src/ui-test/localdebug/localdebug-obo-tab.test.ts index b10a595f81..e8ebe73c27 100644 --- a/packages/tests/src/ui-test/localdebug/localdebug-obo-tab.test.ts +++ b/packages/tests/src/ui-test/localdebug/localdebug-obo-tab.test.ts @@ -88,13 +88,9 @@ describe("Local Debug M365 Tests", function () { ); await localDebugTestContext.validateLocalStateForTab(); await validateReactTab(page, Env.displayName, true); - const url = page.url(); - const pattern = - /https:\/\/teams\.microsoft\.com\/_#\/apps\/(.*)\/sections\/index.*/; - const result = url.match(pattern); - const internalId = result![1]; + const m365AppId = await localDebugTestContext.getM365AppId(); await page.goto( - `https://outlook.office.com/host/${internalId}/index?login_hint=${Env.username}` + `https://outlook.office.com/host/${m365AppId}/index?login_hint=${Env.username}` ); await validateReactOutlookTab(page, Env.displayName, true); } diff --git a/packages/tests/src/ui-test/localdebug/localdebugContext.ts b/packages/tests/src/ui-test/localdebug/localdebugContext.ts index 17e493c247..f557064a79 100644 --- a/packages/tests/src/ui-test/localdebug/localdebugContext.ts +++ b/packages/tests/src/ui-test/localdebug/localdebugContext.ts @@ -86,6 +86,24 @@ export class LocalDebugTestContext extends TestContext { return result; } + public async getM365AppId(): Promise { + const userDataFile = path.join( + TestFilePath.configurationFolder, + `.env.local` + ); + const configFilePath = path.resolve( + this.testRootFolder, + this.appName, + userDataFile + ); + const context = dotenvUtil.deserialize( + await fs.readFile(configFilePath, { encoding: "utf8" }) + ); + const result = context.obj.M365_APP_ID as string; + console.log(`M365 APP ID: ${result}`); + return result; + } + public async createProject(): Promise { if (this.needMigrate) { await execCommand(this.testRootFolder, `set TEAMSFX_V3=false`); diff --git a/packages/tests/src/utils/playwrightOperation.ts b/packages/tests/src/utils/playwrightOperation.ts index 2af1909584..9a6decf66e 100644 --- a/packages/tests/src/utils/playwrightOperation.ts +++ b/packages/tests/src/utils/playwrightOperation.ts @@ -2301,10 +2301,7 @@ export async function validateDashboardTab(page: Page) { export async function validateNotificationTimeBot(page: Page) { try { - const frameElementHandle = await page.waitForSelector( - "iframe.embedded-page-content" - ); - const frame = await frameElementHandle?.contentFrame(); + const frame = await page.waitForSelector("div#app"); await frame?.waitForSelector("div.ui-box"); await RetryHandler.retry(async () => { await frame?.waitForSelector(