Skip to content

Commit

Permalink
test: fix add app ui change (#12411)
Browse files Browse the repository at this point in the history
* test: fix chatdata aisearch test create index command missing args

* test: fix add app ui change

---------

Co-authored-by: Ivan_Chen <v-ivanchen@microsoft.com>
  • Loading branch information
ayachensiyuan and Ivan_Chen authored Sep 19, 2024
1 parent cfef6cf commit 37a49c4
Show file tree
Hide file tree
Showing 5 changed files with 83 additions and 99 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
174 changes: 79 additions & 95 deletions packages/tests/src/utils/playwrightOperation.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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")');
Expand Down Expand Up @@ -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;
}
Expand Down Expand Up @@ -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"]`
);
Expand All @@ -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({
Expand Down

0 comments on commit 37a49c4

Please sign in to comment.