Fix intermittent failure in the stamp editor's undo-related integration tests

The clipboard, used via the `copyImage` helper function, is a shared
resource, so access to it cannot happen concurrently because it could
result in tests overwriting each other's contents. Most tests using
the clipboard are therefore run sequentially, but only the stamp
editor's undo-related tests weren't, so this commit fixes the issue
by running those tests sequentially too.
This commit is contained in:
Tim van der Meij 2025-05-18 14:19:13 +02:00
parent f6e4b1cf4a
commit 6355dd7ded
No known key found for this signature in database
GPG Key ID: 8C3FD2925A5F2762

View File

@ -631,6 +631,7 @@ describe("Stamp Editor", () => {
}); });
it("must check that the alt-text button is here when pasting in the second tab", async () => { it("must check that the alt-text button is here when pasting in the second tab", async () => {
// Run sequentially to avoid clipboard issues.
for (let i = 0; i < pages1.length; i++) { for (let i = 0; i < pages1.length; i++) {
const [, page1] = pages1[i]; const [, page1] = pages1[i];
await page1.bringToFront(); await page1.bringToFront();
@ -1592,86 +1593,80 @@ describe("Stamp Editor", () => {
}); });
it("must check that deleting an image can be undone using the undo button", async () => { it("must check that deleting an image can be undone using the undo button", async () => {
await Promise.all( // Run sequentially to avoid clipboard issues.
pages.map(async ([browserName, page]) => { for (const [, page] of pages) {
await switchToStamp(page); await switchToStamp(page);
const editorSelector = getEditorSelector(0); const editorSelector = getEditorSelector(0);
await copyImage(page, "../images/firefox_logo.png", editorSelector); await copyImage(page, "../images/firefox_logo.png", editorSelector);
await page.waitForSelector(editorSelector); await page.waitForSelector(editorSelector);
await waitForSerialized(page, 1); await waitForSerialized(page, 1);
await page.waitForSelector(`${editorSelector} button.delete`); await page.waitForSelector(`${editorSelector} button.delete`);
await page.click(`${editorSelector} button.delete`); await page.click(`${editorSelector} button.delete`);
await waitForSerialized(page, 0); await waitForSerialized(page, 0);
await page.waitForSelector("#editorUndoBar", { visible: true }); await page.waitForSelector("#editorUndoBar", { visible: true });
await page.waitForSelector("#editorUndoBarUndoButton", { await page.waitForSelector("#editorUndoBarUndoButton", {
visible: true, visible: true,
}); });
await page.click("#editorUndoBarUndoButton"); await page.click("#editorUndoBarUndoButton");
await waitForSerialized(page, 1); await waitForSerialized(page, 1);
await page.waitForSelector(editorSelector); await page.waitForSelector(editorSelector);
await page.waitForSelector(`${editorSelector} canvas`); await page.waitForSelector(`${editorSelector} canvas`);
}) }
);
}); });
it("must check that the undo deletion popup displays the correct message", async () => { it("must check that the undo deletion popup displays the correct message", async () => {
await Promise.all( // Run sequentially to avoid clipboard issues.
pages.map(async ([browserName, page]) => { for (const [, page] of pages) {
await switchToStamp(page); await switchToStamp(page);
const editorSelector = getEditorSelector(0); const editorSelector = getEditorSelector(0);
await copyImage(page, "../images/firefox_logo.png", editorSelector); await copyImage(page, "../images/firefox_logo.png", editorSelector);
await page.waitForSelector(editorSelector); await page.waitForSelector(editorSelector);
await waitForSerialized(page, 1); await waitForSerialized(page, 1);
await page.waitForSelector(`${editorSelector} button.delete`); await page.waitForSelector(`${editorSelector} button.delete`);
await page.click(`${editorSelector} button.delete`); await page.click(`${editorSelector} button.delete`);
await waitForSerialized(page, 0); await waitForSerialized(page, 0);
await page.waitForFunction(() => { await page.waitForFunction(() => {
const messageElement = document.querySelector( const messageElement = document.querySelector(
"#editorUndoBarMessage" "#editorUndoBarMessage"
);
return messageElement && messageElement.textContent.trim() !== "";
});
const message = await page.waitForSelector("#editorUndoBarMessage");
const messageText = await page.evaluate(
el => el.textContent,
message
); );
expect(messageText).toContain("Image removed"); return messageElement && messageElement.textContent.trim() !== "";
}) });
); const message = await page.waitForSelector("#editorUndoBarMessage");
const messageText = await page.evaluate(el => el.textContent, message);
expect(messageText).toContain("Image removed");
}
}); });
it("must check that the popup disappears when a new image is inserted", async () => { it("must check that the popup disappears when a new image is inserted", async () => {
await Promise.all( // Run sequentially to avoid clipboard issues.
pages.map(async ([browserName, page]) => { for (const [, page] of pages) {
await switchToStamp(page); await switchToStamp(page);
const editorSelector = getEditorSelector(0); const editorSelector = getEditorSelector(0);
await copyImage(page, "../images/firefox_logo.png", editorSelector); await copyImage(page, "../images/firefox_logo.png", editorSelector);
await page.waitForSelector(editorSelector); await page.waitForSelector(editorSelector);
await waitForSerialized(page, 1); await waitForSerialized(page, 1);
await page.waitForSelector(`${editorSelector} button.delete`); await page.waitForSelector(`${editorSelector} button.delete`);
await page.click(`${editorSelector} button.delete`); await page.click(`${editorSelector} button.delete`);
await waitForSerialized(page, 0); await waitForSerialized(page, 0);
await page.waitForSelector("#editorUndoBar", { visible: true }); await page.waitForSelector("#editorUndoBar", { visible: true });
await page.click("#editorStampAddImage"); await page.click("#editorStampAddImage");
const newInput = await page.$("#stampEditorFileInput"); const newInput = await page.$("#stampEditorFileInput");
await newInput.uploadFile( await newInput.uploadFile(
`${path.join(__dirname, "../images/firefox_logo.png")}` `${path.join(__dirname, "../images/firefox_logo.png")}`
); );
await waitForImage(page, getEditorSelector(1)); await waitForImage(page, getEditorSelector(1));
await waitForSerialized(page, 1); await waitForSerialized(page, 1);
await page.waitForSelector("#editorUndoBar", { hidden: true }); await page.waitForSelector("#editorUndoBar", { hidden: true });
}) }
);
}); });
}); });