From 37a49c4a89a12796243781aff2dacc681c194c44 Mon Sep 17 00:00:00 2001 From: Siyuan Chen <67082457+ayachensiyuan@users.noreply.github.com> Date: Thu, 19 Sep 2024 08:16:49 +0800 Subject: [PATCH] test: fix add app ui change (#12411) * test: fix chatdata aisearch test create index command missing args * test: fix add app ui change --------- Co-authored-by: Ivan_Chen --- ...ug-chatdata-azureai-js-azureopenai.test.ts | 2 +- ...ug-chatdata-azureai-ts-azureopenai.test.ts | 2 +- ...ug-chatdata-azureai-js-azureopenai.test.ts | 2 +- ...ug-chatdata-azureai-ts-azureopenai.test.ts | 2 +- .../tests/src/utils/playwrightOperation.ts | 174 ++++++++---------- 5 files changed, 83 insertions(+), 99 deletions(-) diff --git a/packages/tests/src/ui-test/localdebug/localdebug-chatdata-azureai-js-azureopenai.test.ts b/packages/tests/src/ui-test/localdebug/localdebug-chatdata-azureai-js-azureopenai.test.ts index d1ac050eb3..782c936f39 100644 --- a/packages/tests/src/ui-test/localdebug/localdebug-chatdata-azureai-js-azureopenai.test.ts +++ b/packages/tests/src/ui-test/localdebug/localdebug-chatdata-azureai-js-azureopenai.test.ts @@ -150,7 +150,7 @@ describe("Local Debug Tests", function () { throw new Error("Failed to install packages"); } - const insertDataCmd = "npm run indexer:create"; + const insertDataCmd = `npm run indexer:create -- '${searchKey}' '${searchEndpoint}'`; const { success: insertDataSuccess } = await Executor.execute( insertDataCmd, projectPath diff --git a/packages/tests/src/ui-test/localdebug/localdebug-chatdata-azureai-ts-azureopenai.test.ts b/packages/tests/src/ui-test/localdebug/localdebug-chatdata-azureai-ts-azureopenai.test.ts index 3e4f727a89..b34362fcb3 100644 --- a/packages/tests/src/ui-test/localdebug/localdebug-chatdata-azureai-ts-azureopenai.test.ts +++ b/packages/tests/src/ui-test/localdebug/localdebug-chatdata-azureai-ts-azureopenai.test.ts @@ -151,7 +151,7 @@ describe("Local Debug Tests", function () { throw new Error("Failed to install packages"); } - const insertDataCmd = "npm run indexer:create"; + const insertDataCmd = `npm run indexer:create -- '${searchKey}' '${searchEndpoint}'`; const { success: insertDataSuccess } = await Executor.execute( insertDataCmd, projectPath diff --git a/packages/tests/src/ui-test/remotedebug/remotedebug-chatdata-azureai-js-azureopenai.test.ts b/packages/tests/src/ui-test/remotedebug/remotedebug-chatdata-azureai-js-azureopenai.test.ts index 968f73eb5b..8df1a452e4 100644 --- a/packages/tests/src/ui-test/remotedebug/remotedebug-chatdata-azureai-js-azureopenai.test.ts +++ b/packages/tests/src/ui-test/remotedebug/remotedebug-chatdata-azureai-js-azureopenai.test.ts @@ -169,7 +169,7 @@ describe("Remote debug Tests", function () { throw new Error("Failed to install packages"); } - const insertDataCmd = "npm run indexer:create"; + const insertDataCmd = `npm run indexer:create -- '${searchKey}' '${searchEndpoint}'`; const { success: insertDataSuccess } = await Executor.execute( insertDataCmd, projectPath diff --git a/packages/tests/src/ui-test/remotedebug/remotedebug-chatdata-azureai-ts-azureopenai.test.ts b/packages/tests/src/ui-test/remotedebug/remotedebug-chatdata-azureai-ts-azureopenai.test.ts index aa3c73fa7f..b74fadc532 100644 --- a/packages/tests/src/ui-test/remotedebug/remotedebug-chatdata-azureai-ts-azureopenai.test.ts +++ b/packages/tests/src/ui-test/remotedebug/remotedebug-chatdata-azureai-ts-azureopenai.test.ts @@ -170,7 +170,7 @@ describe("Remote debug Tests", function () { throw new Error("Failed to install packages"); } - const insertDataCmd = "npm run indexer:create"; + const insertDataCmd = `npm run indexer:create -- '${searchKey}' '${searchEndpoint}'`; const { success: insertDataSuccess } = await Executor.execute( insertDataCmd, projectPath diff --git a/packages/tests/src/utils/playwrightOperation.ts b/packages/tests/src/utils/playwrightOperation.ts index bfae524e01..4cf4921f4b 100644 --- a/packages/tests/src/utils/playwrightOperation.ts +++ b/packages/tests/src/utils/playwrightOperation.ts @@ -493,104 +493,88 @@ export async function initTeamsPage( } // default - if (options?.type !== "meeting") { - console.log("click add button"); - const addBtn = await page?.waitForSelector( - "button>span:has-text('Add')" + console.log("click add button"); + let addInBtn; + try { + addInBtn = await page?.waitForSelector("button>span:has-text('Add')"); + } catch { + try { + addInBtn = await page?.waitForSelector( + "button>span:has-text('Open')" + ); + } catch { + await page.screenshot({ + path: getPlaywrightScreenshotPath("add_page"), + fullPage: true, + }); + throw "error to add app"; + } + } + await addInBtn?.click(); + if (options?.type === "meeting") { + // select meeting tab in dialog box + const dialog = await page.waitForSelector("div[role='dialog']"); + const meetingTab = await dialog?.waitForSelector( + "li:has-text('testing')" ); - await addBtn?.click(); + console.log("click meeting tab"); + await meetingTab?.click(); await page.waitForTimeout(Timeout.shortTimeLoading); - } else { - // add in meeting - console.log("click showListBtn button"); - const showListBtn = await page?.waitForSelector( - ".ui-splitbutton>button" - ); - await showListBtn?.click(); + const gotoBtn = await dialog?.waitForSelector("button[data-tid='go']"); + console.log("click 'set up a tab' button"); + await gotoBtn?.click(); await page.waitForTimeout(Timeout.shortTimeLoading); - console.log("click addInMeetingBtn button"); - const addInMeetingBtn = await page?.waitForSelector( - ".ui-popup__content li:has-text('Add to a meeting')" - ); - await addInMeetingBtn?.click(); - await page.waitForTimeout(Timeout.shortTimeLoading); + await page?.waitForSelector("button[data-tid='go']", { + state: "detached", + }); + console.log("successful to add teams app!!!"); + return; + } - console.log("input meeting name in search box"); - const inputBox = await page.waitForSelector( - ".fui-DialogBody .ui-dropdown input.ui-box" - ); - await inputBox.fill("testing"); - await page.waitForTimeout(Timeout.shortTimeLoading); - const testingTab = await page.waitForSelector( - "ul li:has-text('testing')" + try { + // teams app add + const dialog = await page.waitForSelector("div[role='dialog']"); + const openBtn = await dialog?.waitForSelector( + "button:has-text('Open')" ); - await testingTab?.click(); + console.log("click 'open' button"); + await openBtn?.click(); await page.waitForTimeout(Timeout.shortTimeLoading); - const setUpBtn = await page?.waitForSelector( - 'button span:has-text("Set up a tab")' - ); - await setUpBtn?.click(); - console.log("click 'set up a tab' button"); - await page.waitForTimeout(Timeout.shortTimeLoading); - await page?.waitForSelector('button span:has-text("Set up a tab")', { + await page?.waitForSelector("div[role='dialog']", { state: "detached", }); console.log("successful to add teams app!!!"); - return; + } catch (error) { + console.log("no need to add to a team step"); } - try { - // verify add page is closed - await page?.waitForSelector(`h1:has-text('to a team')`); - try { - try { - // select 2nd li item - const items = await page?.waitForSelector( - "li.ui-dropdown__item:nth-child(2)" - ); - await items?.click(); - console.log("selected a team."); - } catch (error) { - const searchBtn = await page?.waitForSelector( - "div.ui-dropdown__toggle-indicator" - ); - await searchBtn?.click(); - await page.waitForTimeout(Timeout.shortTimeLoading); - const items = await page?.waitForSelector("li.ui-dropdown__item"); - await items?.click(); - console.log("[catch] selected a team."); - } - - const setUpBtn = await page?.waitForSelector( - 'button span:has-text("Set up a tab")' + { + if (options?.type === "spfx") { + // spfx add to channel + const dialog = await page.waitForSelector("div[role='dialog']"); + const spfxTab = await dialog?.waitForSelector( + "li:has-text('test-team')" + ); + console.log("click spfxTab tab"); + await spfxTab?.click(); + await page.waitForTimeout(Timeout.shortTimeLoading); + const gotoBtn = await dialog?.waitForSelector( + "button[data-tid='go']" ); - await setUpBtn?.click(); console.log("click 'set up a tab' button"); + await gotoBtn?.click(); await page.waitForTimeout(Timeout.shortTimeLoading); - await page?.waitForSelector('button span:has-text("Set up a tab")', { + + await page?.waitForSelector("button[data-tid='go']", { state: "detached", }); - } catch (error) { - console.log(error); - await page.screenshot({ - path: getPlaywrightScreenshotPath("error"), - fullPage: true, - }); - throw error; - } - } catch (error) { - console.log("no need to add to a team step"); - } - { - console.log('[start] click "save" button'); - const frameElementHandle = await page.waitForSelector( - `iframe[name="embedded-page-container"]` - ); - const frame = await frameElementHandle?.contentFrame(); - if (options?.type === "spfx") { + const frameElementHandle = await page.waitForSelector( + `iframe[name="embedded-page-container"]` + ); + const frame = await frameElementHandle?.contentFrame(); try { console.log("Load debug scripts"); await frame?.click('button:has-text("Load debug scripts")'); @@ -683,17 +667,22 @@ export async function reopenTeamsPage( await page.waitForTimeout(Timeout.shortTimeLoading); if (options?.type === "meeting") { - // verify add page is closed - try { - await page?.waitForSelector( - `h1:has-text('Add ${options?.teamsAppName} to a team')` - ); - } catch (error) { - await page?.waitForSelector( - `h1:has-text('Add ${options?.teamsAppName} to a meeting')` - ); - } - // TODO: need to add more logic + // select meeting tab in dialog box + const dialog = await page.waitForSelector("div[role='dialog']"); + const meetingTab = await dialog?.waitForSelector( + "li:has-text('testing')" + ); + console.log("click meeting tab"); + await meetingTab?.click(); + await page.waitForTimeout(Timeout.shortTimeLoading); + const gotoBtn = await dialog?.waitForSelector("button[data-tid='go']"); + console.log("click 'set up a tab' button"); + await gotoBtn?.click(); + await page.waitForTimeout(Timeout.shortTimeLoading); + + await page?.waitForSelector("button[data-tid='go']", { + state: "detached", + }); console.log("successful to add teams app!!!"); return; } @@ -3024,9 +3013,6 @@ export async function validateCustomapi( export async function validateRetailDashboard(page: Page) { try { console.log("start to verify dashboard tab"); - await page?.waitForSelector("button:has-text('RetailDashboard')"); - await page?.waitForSelector("button:has-text('RetailHome')"); - await page?.waitForSelector("button:has-text('RetailInventory')"); const frameElementHandle = await page.waitForSelector( `iframe[name="embedded-page-container"]` ); @@ -3035,8 +3021,6 @@ export async function validateRetailDashboard(page: Page) { await frame?.waitForSelector( "span:has-text('Global Customer Satisfaction')" ); - await frame?.waitForSelector("span:has-text('Product Sell')"); - await frame?.waitForSelector("span:has-text('Reasons for Return')"); console.log("Dashboard tab loaded successfully"); } catch (error) { await page.screenshot({