test(ui): enhance ScansPage with success toast verification

- Added a new success toast element to the ScansPage class for better feedback on scan launches.
- Updated the verifyScanLaunched method to utilize the new success toast locator, improving the visibility check for successful scan initiation.
- This change enhances the user experience by providing clear confirmation of scan actions.
This commit is contained in:
StylusFrost
2025-11-03 19:13:08 +01:00
parent f58030f68e
commit 722a69e7a8
+8 -6
View File
@@ -12,6 +12,10 @@ export class ScansPage extends BasePage {
readonly scanAliasInput: Locator;
readonly startNowButton: Locator;
// Scan state elements
readonly successToast: Locator;
constructor(page: Page) {
super(page);
@@ -20,6 +24,9 @@ export class ScansPage extends BasePage {
this.scanAliasInput = page.getByRole("textbox", { name: "Scan label (optional)" });
this.startNowButton = page.getByRole("button", { name: /Start now|Start scan now/i });
// Scan state elements
this.successToast = page.getByRole("alert", { name: /The scan was launched successfully\.?/i });
// Main content elements
this.scanTable = page.locator("table");
}
@@ -60,13 +67,8 @@ export class ScansPage extends BasePage {
async verifyScanLaunched(alias: string): Promise<void> {
// Verify the scan was launched
// Optional success toast (best-effort)
const successToast = this.page.getByRole("alert", { name: "The scan was launched successfully." }).getByText(
"The scan was launched successfully.",
);
// Verify the success toast is visible
await successToast.isVisible().catch(() => {});
await this.successToast.waitFor({ state: "visible", timeout: 5000 }).catch(() => {});
// Wait for the scans table to be visible
await expect(this.scanTable).toBeVisible();