Skip to content

Commit

Permalink
test: add cleanup app in ui test
Browse files Browse the repository at this point in the history
  • Loading branch information
ivan chen committed Jan 22, 2025
1 parent 9d7697d commit dd13c66
Showing 1 changed file with 20 additions and 9 deletions.
29 changes: 20 additions & 9 deletions packages/tests/src/utils/playwrightOperation.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3063,7 +3063,7 @@ export async function validateRetailDashboard(page: Page, tabName: string) {
console.log("Dashboard tab loaded successfully");

// cleanup
await cleanupInstalledApp(page, tabName);
await cleanupInstalledApp(page, tabName);
} catch (error) {
await page.screenshot({
path: getPlaywrightScreenshotPath("error"),
Expand All @@ -3075,30 +3075,42 @@ export async function validateRetailDashboard(page: Page, tabName: string) {

export async function cleanupInstalledApp(page: Page, appName: string) {
console.log("start to cleanupInstalledApp");
const tabCardContainer = await page?.waitForSelector("div[data-tid='app-layout-area--header']");
const tabCardContainer = await page?.waitForSelector(
"div[data-tid='app-layout-area--header']"
);
try {
// clean up
const homeTab = await tabCardContainer?.waitForSelector(`button:has-text('${appName}')`);
const homeTab = await tabCardContainer?.waitForSelector(
`button:has-text('${appName}')`
);
// right click to open context menu
await homeTab?.click({ button: "right" });
await page.waitForTimeout(Timeout.shortTimeWait);
const deleteBtn = await page?.waitForSelector("div[data-tid='data-tid-removeTab']");
const deleteBtn = await page?.waitForSelector(
"div[data-tid='data-tid-removeTab']"
);
await deleteBtn?.click();
await page.waitForTimeout(Timeout.shortTimeLoading);
const confirmBtn = await page?.waitForSelector("button[id='tab-remove-btn']");
const confirmBtn = await page?.waitForSelector(
"button[id='tab-remove-btn']"
);
await confirmBtn?.click();
await page.waitForTimeout(Timeout.shortTimeWait);
try {
await page.waitForSelector("h3:has-text('There was a problem removing this tab')");
const dobuleConfirmBtn = await page.waitForSelector("button:has-text('Yes, remove tab')");
await page.waitForSelector(
"h3:has-text('There was a problem removing this tab')"
);
const dobuleConfirmBtn = await page.waitForSelector(
"button:has-text('Yes, remove tab')"
);
await dobuleConfirmBtn?.click();
} catch (error) {
console.log("no error message");
}
console.log("cleanupInstalledApp successfully");
} catch (error) {
console.log("[skip] cleanupInstalledApp error");
console.log(error)
console.log(error);
}
return tabCardContainer;
}
Expand All @@ -3115,7 +3127,6 @@ export async function validateMeeting(page: Page, name: string) {

// clean up
await cleanupInstalledApp(page, "Home");

} catch (error) {
await page.screenshot({
path: getPlaywrightScreenshotPath("error"),
Expand Down

0 comments on commit dd13c66

Please sign in to comment.