Skip to content

Commit bc53e29

Browse files
committed
chore: add integ test for stamp moving between pages
1 parent 06f5200 commit bc53e29

File tree

1 file changed

+73
-0
lines changed

1 file changed

+73
-0
lines changed

test/integration/stamp_editor_spec.mjs

Lines changed: 73 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1824,4 +1824,77 @@ describe("Stamp Editor", () => {
18241824
);
18251825
});
18261826
});
1827+
1828+
describe("Stamp (move between pages)", () => {
1829+
let pages;
1830+
1831+
beforeEach(async () => {
1832+
pages = await loadAndWait(
1833+
"firefox_stamp.pdf",
1834+
`.page[data-page-number="1"] section[data-annotation-id]`,
1835+
"50"
1836+
);
1837+
});
1838+
1839+
afterEach(async () => {
1840+
await closePages(pages);
1841+
});
1842+
1843+
it("must move a stamp annotation from page 1 to page 2", async () => {
1844+
await Promise.all(
1845+
pages.map(async ([browserName, page]) => {
1846+
await waitForPageRendered(page, 1);
1847+
await waitForPageRendered(page, 2);
1848+
await waitForAnnotationEditorLayer(page, 1);
1849+
await waitForAnnotationEditorLayer(page, 2);
1850+
1851+
const modeChangedHandle = await waitForAnnotationModeChanged(page);
1852+
await page.click(
1853+
`.page[data-page-number="1"] section[data-annotation-id]`,
1854+
{ count: 2 }
1855+
);
1856+
await awaitPromise(modeChangedHandle);
1857+
1858+
const editorSelector = getEditorSelector(0);
1859+
await waitForSelectedEditor(page, editorSelector);
1860+
1861+
const editorRect = await getRect(page, editorSelector);
1862+
const page2Rect = await getRect(
1863+
page,
1864+
`.page[data-page-number="2"] .annotationEditorLayer`
1865+
);
1866+
1867+
const deltaX =
1868+
page2Rect.x +
1869+
page2Rect.width / 2 -
1870+
(editorRect.x + editorRect.width / 2);
1871+
const deltaY =
1872+
page2Rect.y +
1873+
page2Rect.height / 3 -
1874+
(editorRect.y + editorRect.height / 2);
1875+
1876+
await dragAndDrop(page, editorSelector, [[deltaX, deltaY]], 10);
1877+
1878+
await page.waitForFunction(
1879+
sel => {
1880+
const editorDiv = document.querySelector(sel);
1881+
const pageDiv = editorDiv?.closest(".page");
1882+
return pageDiv?.getAttribute("data-page-number") === "2";
1883+
},
1884+
{},
1885+
editorSelector
1886+
);
1887+
1888+
const pageIndex = await page.evaluate(sel => {
1889+
const editorDiv = document.querySelector(sel);
1890+
const pageDiv = editorDiv?.closest(".page");
1891+
const pageNum = pageDiv?.getAttribute("data-page-number");
1892+
return pageNum ? parseInt(pageNum, 10) - 1 : -1;
1893+
}, editorSelector);
1894+
1895+
expect(pageIndex).withContext(`In ${browserName}`).toEqual(1);
1896+
})
1897+
);
1898+
});
1899+
});
18271900
});

0 commit comments

Comments
 (0)