Fix intermittent failure in the viewer alert tests

It takes some time for the viewer alert to be updated after the editor
is committed, but the current tests don't await that and proceed too
fast to the viewer alert string assertion. This commit fixes the issue
by waiting for the expected viewer alert string to appear instead.
This commit is contained in:
Tim van der Meij 2025-07-18 20:39:44 +02:00
parent e4585c2452
commit 603fd2524a
No known key found for this signature in database
GPG Key ID: 8C3FD2925A5F2762
5 changed files with 15 additions and 10 deletions

View File

@ -111,8 +111,9 @@ describe("FreeText Editor", () => {
await waitForSelectedEditor(page, editorSelector);
await waitForStorageEntries(page, 1);
const alert = await page.$eval("#viewer-alert", el => el.textContent);
expect(alert).toEqual("Text added");
await page.waitForFunction(
`document.getElementById("viewer-alert").textContent === "Text added"`
);
let content = await page.$eval(editorSelector, el =>
el.innerText.trimEnd()

View File

@ -78,8 +78,9 @@ describe("Highlight Editor", () => {
await page.waitForSelector(`${getEditorSelector(0)}`);
const alert = await page.$eval("#viewer-alert", el => el.textContent);
expect(alert).toEqual("Highlight added");
await page.waitForFunction(
`document.getElementById("viewer-alert").textContent === "Highlight added"`
);
const oneToOne = Array.from(new Array(13).keys(), n => n + 2).concat(
Array.from(new Array(13).keys(), n => 13 - n)

View File

@ -84,8 +84,9 @@ describe("Ink Editor", () => {
await commit(page);
}
const alert = await page.$eval("#viewer-alert", el => el.textContent);
expect(alert).toEqual("Drawing added");
await page.waitForFunction(
`document.getElementById("viewer-alert").textContent === "Drawing added"`
);
await clearAll(page);

View File

@ -181,8 +181,9 @@ describe("Signature Editor", () => {
{ visible: true }
);
const alert = await page.$eval("#viewer-alert", el => el.textContent);
expect(alert).toEqual("Signature added");
await page.waitForFunction(
`document.getElementById("viewer-alert").textContent === "Signature added"`
);
// Check the tooltip.
await page.waitForSelector(

View File

@ -125,8 +125,9 @@ describe("Stamp Editor", () => {
const editorSelector = getEditorSelector(0);
await waitForImage(page, editorSelector);
const alert = await page.$eval("#viewer-alert", el => el.textContent);
expect(alert).toEqual("Image added");
await page.waitForFunction(
`document.getElementById("viewer-alert").textContent === "Image added"`
);
const { width } = await getEditorDimensions(page, editorSelector);