Skip to content

Commit f42e099

Browse files
More generous alert check (#1113)
Aims not to care about duplicates or other old alerts.
1 parent f62af6b commit f42e099

File tree

1 file changed

+16
-6
lines changed

1 file changed

+16
-6
lines changed

src/e2e/app.ts

Lines changed: 16 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -433,12 +433,22 @@ export class App {
433433
*/
434434
async findAlertText(title: string, description?: string): Promise<void> {
435435
const document = await this.document();
436-
const alert = await document.findByRole("alert", {
437-
name: title,
438-
});
439-
if (description) {
440-
await alert.findByText(description);
441-
}
436+
await waitFor(async () => {
437+
const alerts = await document.findAllByRole("alert", {
438+
name: title,
439+
});
440+
if (description) {
441+
const matchingDescriptions = await Promise.all(
442+
alerts.map(async (alert) => {
443+
const matches = await alert.queryAllByText(description);
444+
return matches.length > 0;
445+
})
446+
);
447+
if (!matchingDescriptions.some((x) => x)) {
448+
throw new Error("No description match in matching alerts");
449+
}
450+
}
451+
}, defaultWaitForOptions);
442452
}
443453

444454
/**

0 commit comments

Comments
 (0)