From ced1268ec3e4f4fbd381231fe8e09084f1437c9a Mon Sep 17 00:00:00 2001 From: Tim van der Meij Date: Sun, 9 Feb 2025 16:27:16 +0100 Subject: [PATCH 1/2] Remove the dependency between two ink editor integration tests The second test of the basic operations block for the ink editor depends on the first test to work. This becomes visible if we only run the second test, using `fit`, which always fails with: `ProtocolError: Waiting for selector '.annotationEditorLayer' failed: Runtime.callFunctionOn timed out. Increase the 'protocolTimeout' setting in launch/connect calls for a higher timeout if needed.` The problem is that the second test doesn't enable the ink editor and relies on the first test having done that already (because we don't close the document between tests yet). This commit fixes the issue by unconditionally enabling the ink editor in the second test to remove the dependency between the two tests so they both pass in isolation. --- test/integration/ink_editor_spec.mjs | 2 ++ 1 file changed, 2 insertions(+) diff --git a/test/integration/ink_editor_spec.mjs b/test/integration/ink_editor_spec.mjs index 6fbb91acf7b25..3e41ce469408d 100644 --- a/test/integration/ink_editor_spec.mjs +++ b/test/integration/ink_editor_spec.mjs @@ -113,6 +113,8 @@ describe("Ink Editor", () => { pages.map(async ([browserName, page]) => { await clearAll(page); + await switchToInk(page); + const rect = await getRect(page, ".annotationEditorLayer"); const xStart = rect.x + 300; From 6d9ff346118fb57096f05964f46edfa95d9442df Mon Sep 17 00:00:00 2001 From: Tim van der Meij Date: Sun, 9 Feb 2025 16:35:55 +0100 Subject: [PATCH 2/2] Isolate the ink editor integration tests To avoid being able to introduce dependencies between tests, and to bring existing dependencies to the surface, this commit makes sure that we close the document between tests so that we can't accidentally rely on state set by a previous test. This prevents multiple tests from failing if one of them fails and makes debugging easier by being able to run each test on their own independent of other tests. This commit, combined with the previous one, is enough to make the ink editor integration test suite pass consistently if random mode in Jasmine is enabled, proving that the tests are fully isolated now. --- test/integration/ink_editor_spec.mjs | 74 ++++++++++++++-------------- 1 file changed, 36 insertions(+), 38 deletions(-) diff --git a/test/integration/ink_editor_spec.mjs b/test/integration/ink_editor_spec.mjs index 3e41ce469408d..8e8270dec7754 100644 --- a/test/integration/ink_editor_spec.mjs +++ b/test/integration/ink_editor_spec.mjs @@ -68,11 +68,11 @@ describe("Ink Editor", () => { describe("Basic operations", () => { let pages; - beforeAll(async () => { + beforeEach(async () => { pages = await loadAndWait("aboutstacks.pdf", ".annotationEditorLayer"); }); - afterAll(async () => { + afterEach(async () => { await closePages(pages); }); @@ -111,8 +111,6 @@ describe("Ink Editor", () => { it("must draw, undo/redo and check that the editor don't move", async () => { await Promise.all( pages.map(async ([browserName, page]) => { - await clearAll(page); - await switchToInk(page); const rect = await getRect(page, ".annotationEditorLayer"); @@ -154,11 +152,11 @@ describe("Ink Editor", () => { describe("with a rotated pdf", () => { let pages; - beforeAll(async () => { + beforeEach(async () => { pages = await loadAndWait("issue16278.pdf", ".annotationEditorLayer"); }); - afterAll(async () => { + afterEach(async () => { await closePages(pages); }); @@ -193,11 +191,11 @@ describe("Ink Editor", () => { describe("Invisible layers must be disabled", () => { let pages; - beforeAll(async () => { + beforeEach(async () => { pages = await loadAndWait("tracemonkey.pdf", ".annotationEditorLayer"); }); - afterAll(async () => { + afterEach(async () => { await closePages(pages); }); @@ -248,11 +246,11 @@ describe("Ink Editor", () => { describe("Ink editor must be committed when blurred", () => { let pages; - beforeAll(async () => { + beforeEach(async () => { pages = await loadAndWait("tracemonkey.pdf", ".annotationEditorLayer"); }); - afterAll(async () => { + afterEach(async () => { await closePages(pages); }); @@ -282,11 +280,11 @@ describe("Ink Editor", () => { describe("Undo a draw", () => { let pages; - beforeAll(async () => { + beforeEach(async () => { pages = await loadAndWait("tracemonkey.pdf", ".annotationEditorLayer"); }); - afterAll(async () => { + afterEach(async () => { await closePages(pages); }); @@ -326,11 +324,11 @@ describe("Ink Editor", () => { describe("Delete a draw and undo it on another page", () => { let pages; - beforeAll(async () => { + beforeEach(async () => { pages = await loadAndWait("tracemonkey.pdf", ".annotationEditorLayer"); }); - afterAll(async () => { + afterEach(async () => { await closePages(pages); }); @@ -383,11 +381,11 @@ describe("Ink Editor", () => { describe("Delete a draw, scroll and undo it", () => { let pages; - beforeAll(async () => { + beforeEach(async () => { pages = await loadAndWait("tracemonkey.pdf", ".annotationEditorLayer"); }); - afterAll(async () => { + afterEach(async () => { await closePages(pages); }); @@ -435,11 +433,11 @@ describe("Ink Editor", () => { describe("Draw several times in the same editor", () => { let pages; - beforeAll(async () => { + beforeEach(async () => { pages = await loadAndWait("empty.pdf", ".annotationEditorLayer"); }); - afterAll(async () => { + afterEach(async () => { await closePages(pages); }); @@ -471,11 +469,11 @@ describe("Ink Editor", () => { describe("Drawing must unselect all", () => { let pages; - beforeAll(async () => { + beforeEach(async () => { pages = await loadAndWait("empty.pdf", ".annotationEditorLayer"); }); - afterAll(async () => { + afterEach(async () => { await closePages(pages); }); @@ -510,11 +508,11 @@ describe("Ink Editor", () => { describe("Selected editor must be updated even if the page has been destroyed", () => { let pages; - beforeAll(async () => { + beforeEach(async () => { pages = await loadAndWait("tracemonkey.pdf", ".annotationEditorLayer"); }); - afterAll(async () => { + afterEach(async () => { await closePages(pages); }); @@ -585,11 +583,11 @@ describe("Ink Editor", () => { describe("Can delete the drawing in progress and undo the deletion", () => { let pages; - beforeAll(async () => { + beforeEach(async () => { pages = await loadAndWait("empty.pdf", ".annotationEditorLayer"); }); - afterAll(async () => { + afterEach(async () => { await closePages(pages); }); @@ -629,11 +627,11 @@ describe("Ink Editor", () => { describe("Annotation mustn't take focus if it isn't visible", () => { let pages; - beforeAll(async () => { + beforeEach(async () => { pages = await loadAndWait("tracemonkey.pdf", ".annotationEditorLayer"); }); - afterAll(async () => { + afterEach(async () => { await closePages(pages); }); @@ -686,11 +684,11 @@ describe("Ink Editor", () => { describe("Ink (update existing)", () => { let pages; - beforeAll(async () => { + beforeEach(async () => { pages = await loadAndWait("inks.pdf", ".annotationEditorLayer"); }); - afterAll(async () => { + afterEach(async () => { await closePages(pages); }); @@ -787,11 +785,11 @@ describe("Ink Editor", () => { describe("Ink (move existing)", () => { let pages; - beforeAll(async () => { + beforeEach(async () => { pages = await loadAndWait("inks.pdf", getAnnotationSelector("277R")); }); - afterAll(async () => { + afterEach(async () => { await closePages(pages); }); @@ -955,11 +953,11 @@ describe("Ink Editor", () => { describe("Ink must update its stroke width when not the current active layer", () => { let pages; - beforeAll(async () => { + beforeEach(async () => { pages = await loadAndWait("tracemonkey.pdf", ".annotationEditorLayer"); }); - afterAll(async () => { + afterEach(async () => { await closePages(pages); }); @@ -1017,7 +1015,7 @@ describe("Ink Editor", () => { describe("Draw annotations on several page, move one of them and delete it", () => { let pages; - beforeAll(async () => { + beforeEach(async () => { pages = await loadAndWait( "tracemonkey.pdf", ".annotationEditorLayer", @@ -1025,7 +1023,7 @@ describe("Ink Editor", () => { ); }); - afterAll(async () => { + afterEach(async () => { await closePages(pages); }); @@ -1081,11 +1079,11 @@ describe("Ink Editor", () => { describe("Page position should remain unchanged after drawing", () => { let pages; - beforeAll(async () => { + beforeEach(async () => { pages = await loadAndWait("tracemonkey.pdf", ".annotationEditorLayer"); }); - afterAll(async () => { + afterEach(async () => { await closePages(pages); }); @@ -1132,11 +1130,11 @@ describe("Ink Editor", () => { describe("The pen-drawn shape must maintain correct curvature regardless of the page it is drawn on or whether the curve's endpoint lies within or beyond the page boundaries", () => { let pages; - beforeAll(async () => { + beforeEach(async () => { pages = await loadAndWait("tracemonkey.pdf", ".annotationEditorLayer"); }); - afterAll(async () => { + afterEach(async () => { await closePages(pages); });