Skip to content

Commit

Permalink
Merge pull request #19069 from calixteman/stamp_test
Browse files Browse the repository at this point in the history
Fix 'must load a SVG, delete it and undo' integration test
  • Loading branch information
timvandermeij authored Nov 19, 2024
2 parents c31ccc6 + eefaca0 commit 07765e9
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 7 deletions.
8 changes: 4 additions & 4 deletions test/integration/stamp_editor_spec.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -195,14 +195,14 @@ describe("Stamp Editor", () => {
);
const editorSelector = getEditorSelector(0);
await waitForImage(page, editorSelector);

await waitForSerialized(page, 1);

await page.waitForSelector(`${editorSelector} button.delete`);
await page.click(`${editorSelector} button.delete`);

await waitForSerialized(page, 0);

await kbUndo(page);
await waitForImage(page, editorSelector);
await waitForSerialized(page, 1);

await waitForSelectedEditor(page, editorSelector);
Expand Down Expand Up @@ -654,8 +654,8 @@ describe("Stamp Editor", () => {
await waitForSerialized(page, 0);

await kbUndo(page);
await waitForImage(page, selector);
await waitForSerialized(page, 1);
await page.waitForSelector(`${selector} canvas`);
}
});
});
Expand Down Expand Up @@ -739,8 +739,8 @@ describe("Stamp Editor", () => {
}

await kbUndo(page);
await waitForImage(page, selector);
await waitForSerialized(page, 1);
await page.waitForSelector(`${selector} canvas`);
}
});
});
Expand Down
15 changes: 12 additions & 3 deletions test/integration/test_utils.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -327,9 +327,18 @@ async function waitForStorageEntries(page, nEntries) {

async function waitForSerialized(page, nEntries) {
return page.waitForFunction(
n =>
(window.PDFViewerApplication.pdfDocument.annotationStorage.serializable
.map?.size ?? 0) === n,
n => {
try {
return (
(window.PDFViewerApplication.pdfDocument.annotationStorage
.serializable.map?.size ?? 0) === n
);
} catch {
// When serializing a stamp annotation with a SVG, the transfer
// can fail because of the SVG, so we just retry.
return false;
}
},
{},
nEntries
);
Expand Down

0 comments on commit 07765e9

Please sign in to comment.