Skip to content

Commit

Permalink
test: fix failure ui test case (#12841)
Browse files Browse the repository at this point in the history
* 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 <[email protected]>
  • Loading branch information
ayachensiyuan and Ivan_Chen authored Dec 4, 2024
1 parent bba16f7 commit 62af22e
Show file tree
Hide file tree
Showing 6 changed files with 42 additions and 26 deletions.
22 changes: 3 additions & 19 deletions packages/tests/scripts/randomCases.json
Original file line number Diff line number Diff line change
Expand Up @@ -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"
]
Expand All @@ -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"
]
},
{
Expand Down Expand Up @@ -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",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,5 @@ new DashboardTestCase(
],
{
dashboardFlag: true,
debug: "cli",
}
).test();
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
* @author Ivan Chen <[email protected]>
*/

// this test case diposed due to cancel local debug
import { Page } from "playwright";
import { TemplateProject, LocalDebugTaskLabel } from "../../utils/constants";
import { CaseFactory } from "./sampleCaseFactory";
Expand Down Expand Up @@ -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);
Expand Down Expand Up @@ -92,4 +97,4 @@ new LargeNotiTestCase(
{
debug: "ttk",
}
).test();
);
1 change: 1 addition & 0 deletions packages/tests/src/utils/constants.ts
Original file line number Diff line number Diff line change
Expand Up @@ -441,6 +441,7 @@ export enum LocalDebugError {
WarningError = "Warning",
WarningCapError = "WARNING",
DeprecatedError = "npm warn deprecated",
CompiledWithWarningError = "Compiled with warnings",
}

export class LocalDebugTaskInfo {
Expand Down
3 changes: 2 additions & 1 deletion packages/tests/src/utils/playwrightOperation.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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(
Expand Down Expand Up @@ -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;
}
Expand Down
34 changes: 30 additions & 4 deletions packages/tests/src/utils/vscodeOperation.ts
Original file line number Diff line number Diff line change
Expand Up @@ -1253,10 +1253,36 @@ export async function findWordFromTerminal(word: string): Promise<boolean> {
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;
Expand Down

0 comments on commit 62af22e

Please sign in to comment.