From 62af22ed4ee720c0a41ee66b6435d6727db4a57c Mon Sep 17 00:00:00 2001 From: Siyuan Chen <67082457+ayachensiyuan@users.noreply.github.com> Date: Wed, 4 Dec 2024 14:15:30 +0800 Subject: [PATCH] test: fix failure ui test case (#12841) * test: update sample large notification case * test: skip warning during debug session * test: update debug random os * test: update dashboard sample --------- Co-authored-by: Ivan_Chen --- packages/tests/scripts/randomCases.json | 22 ++---------- .../sample-localdebug-dashboard.test.ts | 1 - ...ocaldebug-large-scale-notification.test.ts | 7 +++- packages/tests/src/utils/constants.ts | 1 + .../tests/src/utils/playwrightOperation.ts | 3 +- packages/tests/src/utils/vscodeOperation.ts | 34 ++++++++++++++++--- 6 files changed, 42 insertions(+), 26 deletions(-) diff --git a/packages/tests/scripts/randomCases.json b/packages/tests/scripts/randomCases.json index 5b20220478..e66159d2bd 100644 --- a/packages/tests/scripts/randomCases.json +++ b/packages/tests/scripts/randomCases.json @@ -35,23 +35,6 @@ "sample-remotedebug-outlook-signature", "sample-localdebug-reddit-link", "sample-remotedebug-reddit-link", - "sample-localdebug-intelligent-data-chart", - "sample-remotedebug-intelligent-data-chart" - ] - }, - { - "os": { - "windows-latest": { - "node-18": [] - }, - "ubuntu-latest": { - "node-18": [] - }, - "macos-latest": { - "node-18": [] - } - }, - "cases": [ "sample-localdebug-chef-bot", "sample-remotedebug-chef-bot" ] @@ -73,7 +56,9 @@ "sample-localdebug-contact-exporter", "sample-localdebug-hello-world-meeting", "sample-localdebug-food-catalog", - "sample-remotedebug-food-catalog" + "sample-remotedebug-food-catalog", + "sample-localdebug-intelligent-data-chart", + "sample-remotedebug-intelligent-data-chart" ] }, { @@ -114,7 +99,6 @@ "sample-localdebug-hello-world-tab-outlook", "sample-localdebug-one-productivity-hub", "sample-localdebug-assistant-dashboard", - "sample-localdebug-large-scale-notification", "sample-localdebug-todo-list-sql", "sample-remotedebug-share-now", "sample-remotedebug-todo-list-sql", diff --git a/packages/tests/src/ui-test/samples/sample-localdebug-dashboard.test.ts b/packages/tests/src/ui-test/samples/sample-localdebug-dashboard.test.ts index 643c567dd1..556a86fbde 100644 --- a/packages/tests/src/ui-test/samples/sample-localdebug-dashboard.test.ts +++ b/packages/tests/src/ui-test/samples/sample-localdebug-dashboard.test.ts @@ -48,6 +48,5 @@ new DashboardTestCase( ], { dashboardFlag: true, - debug: "cli", } ).test(); diff --git a/packages/tests/src/ui-test/samples/sample-localdebug-large-scale-notification.test.ts b/packages/tests/src/ui-test/samples/sample-localdebug-large-scale-notification.test.ts index 75049b0c4b..7732a8abf0 100644 --- a/packages/tests/src/ui-test/samples/sample-localdebug-large-scale-notification.test.ts +++ b/packages/tests/src/ui-test/samples/sample-localdebug-large-scale-notification.test.ts @@ -5,6 +5,7 @@ * @author Ivan Chen */ +// this test case diposed due to cancel local debug import { Page } from "playwright"; import { TemplateProject, LocalDebugTaskLabel } from "../../utils/constants"; import { CaseFactory } from "./sampleCaseFactory"; @@ -41,6 +42,10 @@ class LargeNotiTestCase extends CaseFactory { "env", `.env.${env}.user` ); + // create envuserfile + if (!fs.existsSync(envUserFile)) { + fs.writeFileSync(envUserFile, ""); + } let envUserFileString = fs.readFileSync(envUserFile, "utf-8"); envUserFileString += `\nSECRET_STORAGE_ACCOUNT_KEY=${process.env["STORAGE_ACCOUNT_KEY"]}`; fs.writeFileSync(envUserFile, envUserFileString); @@ -92,4 +97,4 @@ new LargeNotiTestCase( { debug: "ttk", } -).test(); +); diff --git a/packages/tests/src/utils/constants.ts b/packages/tests/src/utils/constants.ts index 7a4571a377..d8c73d794f 100644 --- a/packages/tests/src/utils/constants.ts +++ b/packages/tests/src/utils/constants.ts @@ -441,6 +441,7 @@ export enum LocalDebugError { WarningError = "Warning", WarningCapError = "WARNING", DeprecatedError = "npm warn deprecated", + CompiledWithWarningError = "Compiled with warnings", } export class LocalDebugTaskInfo { diff --git a/packages/tests/src/utils/playwrightOperation.ts b/packages/tests/src/utils/playwrightOperation.ts index 5cd1717c8d..8d70b742f1 100644 --- a/packages/tests/src/utils/playwrightOperation.ts +++ b/packages/tests/src/utils/playwrightOperation.ts @@ -2367,6 +2367,7 @@ export async function validateDashboardTab(page: Page) { } } }); + console.log("start to verify dashboard tab"); await page.waitForTimeout(Timeout.longTimeWait); const frameElementHandle = await page.waitForSelector( @@ -2728,7 +2729,7 @@ export async function validateLargeNotificationBot( console.log(e); } try { - await frame?.waitForSelector('p:has-text("Hello World")'); + await frame?.waitForSelector('p:has-text("New Event Occurred!")'); } catch (e) { throw e; } diff --git a/packages/tests/src/utils/vscodeOperation.ts b/packages/tests/src/utils/vscodeOperation.ts index 4b6a0255ec..720bf16323 100644 --- a/packages/tests/src/utils/vscodeOperation.ts +++ b/packages/tests/src/utils/vscodeOperation.ts @@ -1253,10 +1253,36 @@ export async function findWordFromTerminal(word: string): Promise { return true; } } else { - await VSBrowser.instance.takeScreenshot( - getScreenshotName("debug failed") - ); - assert.fail("[failed] error message found !!!"); + try { + await searchInput.clear(); + await searchInput.sendKeys("Compiled with warnings"); + console.log("send key: Compiled with warnings"); + } catch (error) { + console.log("[Pending]: Input error, try to find next..."); + continue; + } + // verify warning error message + result = await ( + await searchBox.findElement(By.className("matchesCount")) + ).getText(); + if (result.includes("No results")) { + await VSBrowser.instance.takeScreenshot( + getScreenshotName("debug failed") + ); + assert.fail("[failed] error message found !!!"); + } + // verify success message + await searchInput.clear(); + await searchInput.sendKeys("No issues found"); + console.log("send key: ", "No issues found."); + await VSBrowser.instance.driver.sleep(Timeout.webView); + result = await ( + await searchBox.findElement(By.className("matchesCount")) + ).getText(); + if (result.includes("No results") == false) { + console.log("[Pass]: verify " + word + " success !!!"); + return true; + } } } return false;