From 440d5193268e90b98ec28f4942e956c343d5d927 Mon Sep 17 00:00:00 2001 From: Tim van der Meij Date: Sat, 22 Mar 2025 20:07:12 +0100 Subject: [PATCH] Isolate the "move editor with arrows" freetext editor integration tests This commit reduces the number of freetext editor integration test suite failures, in full isolation, from 8 to 6 by fixing the following issues in the "move editor with arrows" block: - The second and third test relied on the first test to enable freetext editing mode. For isolation we now do it explicitly in both tests. - The second test relied on the first test having created an editor. For isolation we now create the editor explicitly in the second test. - The third test relied on the previous tests for the editor numbering. For isolation we change the editor numbering to the one after initial document load. Since we can't have state (editors) from a previous test anymore we can remove the `clearAll` call as well. --- test/integration/freetext_editor_spec.mjs | 22 +++++++++++++++------- 1 file changed, 15 insertions(+), 7 deletions(-) diff --git a/test/integration/freetext_editor_spec.mjs b/test/integration/freetext_editor_spec.mjs index 84b886b70..3708a9db3 100644 --- a/test/integration/freetext_editor_spec.mjs +++ b/test/integration/freetext_editor_spec.mjs @@ -1705,11 +1705,11 @@ describe("FreeText Editor", () => { describe("Move editor with arrows", () => { let pages; - beforeAll(async () => { + beforeEach(async () => { pages = await loadAndWait("empty.pdf", ".annotationEditorLayer"); }); - afterAll(async () => { + afterEach(async () => { await closePages(pages); }); @@ -1779,6 +1779,16 @@ describe("FreeText Editor", () => { it("must check arrow doesn't move an editor when a slider is focused", async () => { await Promise.all( pages.map(async ([browserName, page]) => { + await switchToFreeText(page); + + const rect = await getRect(page, ".annotationEditorLayer"); + const data = "Hello PDF.js World !!"; + const editorSelector = getEditorSelector(0); + await page.mouse.click(rect.x + 200, rect.y + 200); + await page.waitForSelector(editorSelector, { visible: true }); + await page.type(`${editorSelector} .internal`, data); + await commit(page); + await selectAll(page); await page.focus("#editorFreeTextFontSize"); @@ -1788,7 +1798,6 @@ describe("FreeText Editor", () => { ); const pageWidth = page2X - page1X; - const editorSelector = getEditorSelector(0); await moveEditor(page, editorSelector, 5, () => page.keyboard.press("ArrowRight") ); @@ -1808,12 +1817,11 @@ describe("FreeText Editor", () => { it("must check the position of an empty freetext", async () => { await Promise.all( pages.map(async ([browserName, page]) => { - await clearAll(page); + await switchToFreeText(page); const rect = await getRect(page, ".annotationEditorLayer"); - const data = "Hello PDF.js World !!"; - let editorSelector = getEditorSelector(1); + let editorSelector = getEditorSelector(0); await page.mouse.click(rect.x + 100, rect.y + 100); await page.waitForSelector(editorSelector, { visible: true }); await page.type(`${editorSelector} .internal`, data); @@ -1822,7 +1830,7 @@ describe("FreeText Editor", () => { const [pageX, pageY] = await getFirstSerialized(page, x => x.rect); await clearAll(page); - editorSelector = getEditorSelector(2); + editorSelector = getEditorSelector(1); await page.mouse.click(rect.x + 100, rect.y + 100); await page.waitForSelector(editorSelector, { visible: true });