-
Notifications
You must be signed in to change notification settings - Fork 17
Open
Labels
cleanupGeneral refactoring and/or minor adjustments needed that shouldn't impact overall functionalityGeneral refactoring and/or minor adjustments needed that shouldn't impact overall functionalitytestingInvolves the test suite, click-testing, or tests running in CIInvolves the test suite, click-testing, or tests running in CI
Description
We have many areas that just wait for a specific notification type with some text following the same general pattern:
const notificationArea = new NotificationArea(page);
const notifications = notificationArea.[infoNotifications|warningNotifications|errorNotifications].filter({
hasText: // string or RegExp,
});
await expect(notifications.first()).toBeVisible(); // or check count, but same general ideaWe could reduce a lot of boilerplate by having some small utility functions here, like:
export async function waitForNotification(
page: Page,
level: "info" | "warning" | "error",
withText: string | RegExp,
) {
const notificationArea = new NotificationArea(page);
let notifications: Locator;
switch (level) {
case "info":
notifications = notificationArea.infoNotifications;
break;
case "warning":
notifications = notificationArea.warningNotifications;
break;
case "error":
notifications = notificationArea.errorNotifications;
break;
default:
throw new Error(`Unsupported notification level: ${level}`);
}
const notification = notifications.filter({ hasText: withText }).first();
await expect(notification).toBeVisible();
}And then the wrappers would look like:
export async function waitForInfoNotification(page: Page, withText: string | RegExp) {
await waitForNotification(page, "info", withText);
}Metadata
Metadata
Assignees
Labels
cleanupGeneral refactoring and/or minor adjustments needed that shouldn't impact overall functionalityGeneral refactoring and/or minor adjustments needed that shouldn't impact overall functionalitytestingInvolves the test suite, click-testing, or tests running in CIInvolves the test suite, click-testing, or tests running in CI