Isolate the highlight editor integration tests

To avoid being able to introduce dependencies between tests 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 commit is contained in:
Tim van der Meij 2025-04-13 14:16:04 +02:00
parent 5011d96a62
commit 44243761a5
No known key found for this signature in database
GPG Key ID: 8C3FD2925A5F2762

View File

@ -55,11 +55,11 @@ describe("Highlight Editor", () => {
describe("Editor must be removed without exception", () => { describe("Editor must be removed without exception", () => {
let pages; let pages;
beforeAll(async () => { beforeEach(async () => {
pages = await loadAndWait("tracemonkey.pdf", ".annotationEditorLayer"); pages = await loadAndWait("tracemonkey.pdf", ".annotationEditorLayer");
}); });
afterAll(async () => { afterEach(async () => {
await closePages(pages); await closePages(pages);
}); });
@ -101,11 +101,11 @@ describe("Highlight Editor", () => {
describe("Editor must keep selected", () => { describe("Editor must keep selected", () => {
let pages; let pages;
beforeAll(async () => { beforeEach(async () => {
pages = await loadAndWait("tracemonkey.pdf", ".annotationEditorLayer"); pages = await loadAndWait("tracemonkey.pdf", ".annotationEditorLayer");
}); });
afterAll(async () => { afterEach(async () => {
await closePages(pages); await closePages(pages);
}); });
@ -145,7 +145,7 @@ describe("Highlight Editor", () => {
describe("The default color must have the correct value", () => { describe("The default color must have the correct value", () => {
let pages; let pages;
beforeAll(async () => { beforeEach(async () => {
pages = await loadAndWait( pages = await loadAndWait(
"tracemonkey.pdf", "tracemonkey.pdf",
".annotationEditorLayer", ".annotationEditorLayer",
@ -155,7 +155,7 @@ describe("Highlight Editor", () => {
); );
}); });
afterAll(async () => { afterEach(async () => {
await closePages(pages); await closePages(pages);
}); });
@ -190,7 +190,7 @@ describe("Highlight Editor", () => {
describe("Invisible editor must change its color", () => { describe("Invisible editor must change its color", () => {
let pages; let pages;
beforeAll(async () => { beforeEach(async () => {
pages = await loadAndWait( pages = await loadAndWait(
"tracemonkey.pdf", "tracemonkey.pdf",
".annotationEditorLayer", ".annotationEditorLayer",
@ -200,7 +200,7 @@ describe("Highlight Editor", () => {
); );
}); });
afterAll(async () => { afterEach(async () => {
await closePages(pages); await closePages(pages);
}); });
@ -278,7 +278,7 @@ describe("Highlight Editor", () => {
describe("Highlight data serialization", () => { describe("Highlight data serialization", () => {
let pages; let pages;
beforeAll(async () => { beforeEach(async () => {
pages = await loadAndWait( pages = await loadAndWait(
"tracemonkey.pdf", "tracemonkey.pdf",
".annotationEditorLayer", ".annotationEditorLayer",
@ -288,7 +288,7 @@ describe("Highlight Editor", () => {
); );
}); });
afterAll(async () => { afterEach(async () => {
await closePages(pages); await closePages(pages);
}); });
@ -335,7 +335,7 @@ describe("Highlight Editor", () => {
describe("Color picker and keyboard", () => { describe("Color picker and keyboard", () => {
let pages; let pages;
beforeAll(async () => { beforeEach(async () => {
pages = await loadAndWait( pages = await loadAndWait(
"tracemonkey.pdf", "tracemonkey.pdf",
".annotationEditorLayer", ".annotationEditorLayer",
@ -348,7 +348,7 @@ describe("Highlight Editor", () => {
); );
}); });
afterAll(async () => { afterEach(async () => {
await closePages(pages); await closePages(pages);
}); });
@ -449,7 +449,7 @@ describe("Highlight Editor", () => {
describe("Text highlights aren't draggable", () => { describe("Text highlights aren't draggable", () => {
let pages; let pages;
beforeAll(async () => { beforeEach(async () => {
pages = await loadAndWait( pages = await loadAndWait(
"tracemonkey.pdf", "tracemonkey.pdf",
".annotationEditorLayer", ".annotationEditorLayer",
@ -459,7 +459,7 @@ describe("Highlight Editor", () => {
); );
}); });
afterAll(async () => { afterEach(async () => {
await closePages(pages); await closePages(pages);
}); });
@ -502,11 +502,11 @@ describe("Highlight Editor", () => {
describe("Color picker and click outside", () => { describe("Color picker and click outside", () => {
let pages; let pages;
beforeAll(async () => { beforeEach(async () => {
pages = await loadAndWait("tracemonkey.pdf", ".annotationEditorLayer"); pages = await loadAndWait("tracemonkey.pdf", ".annotationEditorLayer");
}); });
afterAll(async () => { afterEach(async () => {
await closePages(pages); await closePages(pages);
}); });
@ -543,11 +543,11 @@ describe("Highlight Editor", () => {
describe("Color picker can annoy the user when selecting some text", () => { describe("Color picker can annoy the user when selecting some text", () => {
let pages; let pages;
beforeAll(async () => { beforeEach(async () => {
pages = await loadAndWait("tracemonkey.pdf", ".annotationEditorLayer"); pages = await loadAndWait("tracemonkey.pdf", ".annotationEditorLayer");
}); });
afterAll(async () => { afterEach(async () => {
await closePages(pages); await closePages(pages);
}); });
@ -580,7 +580,7 @@ describe("Highlight Editor", () => {
describe("Free highlight thickness can be changed", () => { describe("Free highlight thickness can be changed", () => {
let pages; let pages;
beforeAll(async () => { beforeEach(async () => {
pages = await loadAndWait( pages = await loadAndWait(
"empty.pdf", "empty.pdf",
".annotationEditorLayer", ".annotationEditorLayer",
@ -590,7 +590,7 @@ describe("Highlight Editor", () => {
); );
}); });
afterAll(async () => { afterEach(async () => {
await closePages(pages); await closePages(pages);
}); });
@ -660,11 +660,11 @@ describe("Highlight Editor", () => {
describe("Highlight with the keyboard", () => { describe("Highlight with the keyboard", () => {
let pages; let pages;
beforeAll(async () => { beforeEach(async () => {
pages = await loadAndWait("tracemonkey.pdf", ".annotationEditorLayer"); pages = await loadAndWait("tracemonkey.pdf", ".annotationEditorLayer");
}); });
afterAll(async () => { afterEach(async () => {
await closePages(pages); await closePages(pages);
}); });
@ -723,7 +723,7 @@ describe("Highlight Editor", () => {
describe("Free highlight is drawn at the right place after having been rotated (bug 1879108)", () => { describe("Free highlight is drawn at the right place after having been rotated (bug 1879108)", () => {
let pages; let pages;
beforeAll(async () => { beforeEach(async () => {
pages = await loadAndWait( pages = await loadAndWait(
"empty.pdf", "empty.pdf",
".annotationEditorLayer", ".annotationEditorLayer",
@ -733,7 +733,7 @@ describe("Highlight Editor", () => {
); );
}); });
afterAll(async () => { afterEach(async () => {
await closePages(pages); await closePages(pages);
}); });
@ -807,7 +807,7 @@ describe("Highlight Editor", () => {
describe("Highlight links", () => { describe("Highlight links", () => {
let pages; let pages;
beforeAll(async () => { beforeEach(async () => {
pages = await loadAndWait( pages = await loadAndWait(
"bug1868759.pdf", "bug1868759.pdf",
".annotationEditorLayer", ".annotationEditorLayer",
@ -817,7 +817,7 @@ describe("Highlight Editor", () => {
); );
}); });
afterAll(async () => { afterEach(async () => {
await closePages(pages); await closePages(pages);
}); });
@ -852,7 +852,7 @@ describe("Highlight Editor", () => {
describe("Highlight forms", () => { describe("Highlight forms", () => {
let pages; let pages;
beforeAll(async () => { beforeEach(async () => {
pages = await loadAndWait( pages = await loadAndWait(
"issue12233.pdf", "issue12233.pdf",
".annotationEditorLayer", ".annotationEditorLayer",
@ -862,7 +862,7 @@ describe("Highlight Editor", () => {
); );
}); });
afterAll(async () => { afterEach(async () => {
await closePages(pages); await closePages(pages);
}); });
@ -902,7 +902,7 @@ describe("Highlight Editor", () => {
describe("Send a message when some text is selected", () => { describe("Send a message when some text is selected", () => {
let pages; let pages;
beforeAll(async () => { beforeEach(async () => {
pages = await loadAndWait( pages = await loadAndWait(
"tracemonkey.pdf", "tracemonkey.pdf",
`.page[data-page-number = "1"] .endOfContent`, `.page[data-page-number = "1"] .endOfContent`,
@ -919,7 +919,7 @@ describe("Highlight Editor", () => {
); );
}); });
afterAll(async () => { afterEach(async () => {
await closePages(pages); await closePages(pages);
}); });
@ -982,7 +982,7 @@ describe("Highlight Editor", () => {
describe("Highlight and caret browsing", () => { describe("Highlight and caret browsing", () => {
let pages; let pages;
beforeAll(async () => { beforeEach(async () => {
pages = await loadAndWait( pages = await loadAndWait(
"tracemonkey.pdf", "tracemonkey.pdf",
".annotationEditorLayer", ".annotationEditorLayer",
@ -1002,16 +1002,6 @@ describe("Highlight Editor", () => {
}); });
afterEach(async () => { afterEach(async () => {
for (const [, page] of pages) {
await page.evaluate(() => {
window.uiManager.reset();
});
// Disable editing mode.
await switchToHighlight(page, /* disable */ true);
}
});
afterAll(async () => {
await closePages(pages); await closePages(pages);
}); });
@ -1154,11 +1144,11 @@ describe("Highlight Editor", () => {
describe("Editor must be removed in using the space key on the delete button", () => { describe("Editor must be removed in using the space key on the delete button", () => {
let pages; let pages;
beforeAll(async () => { beforeEach(async () => {
pages = await loadAndWait("tracemonkey.pdf", ".annotationEditorLayer"); pages = await loadAndWait("tracemonkey.pdf", ".annotationEditorLayer");
}); });
afterAll(async () => { afterEach(async () => {
await closePages(pages); await closePages(pages);
}); });
@ -1189,11 +1179,11 @@ describe("Highlight Editor", () => {
describe("Thickness must be enabled when there's no selected highlights", () => { describe("Thickness must be enabled when there's no selected highlights", () => {
let pages; let pages;
beforeAll(async () => { beforeEach(async () => {
pages = await loadAndWait("tracemonkey.pdf", ".annotationEditorLayer"); pages = await loadAndWait("tracemonkey.pdf", ".annotationEditorLayer");
}); });
afterAll(async () => { afterEach(async () => {
await closePages(pages); await closePages(pages);
}); });
@ -1244,11 +1234,11 @@ describe("Highlight Editor", () => {
describe("Quadpoints must be correct", () => { describe("Quadpoints must be correct", () => {
let pages; let pages;
beforeAll(async () => { beforeEach(async () => {
pages = await loadAndWait("tracemonkey.pdf", ".annotationEditorLayer"); pages = await loadAndWait("tracemonkey.pdf", ".annotationEditorLayer");
}); });
afterAll(async () => { afterEach(async () => {
await closePages(pages); await closePages(pages);
}); });
@ -1280,11 +1270,11 @@ describe("Highlight Editor", () => {
describe("Quadpoints must be correct when they're in a translated page", () => { describe("Quadpoints must be correct when they're in a translated page", () => {
let pages; let pages;
beforeAll(async () => { beforeEach(async () => {
pages = await loadAndWait("issue18360.pdf", ".annotationEditorLayer"); pages = await loadAndWait("issue18360.pdf", ".annotationEditorLayer");
}); });
afterAll(async () => { afterEach(async () => {
await closePages(pages); await closePages(pages);
}); });
@ -1316,11 +1306,11 @@ describe("Highlight Editor", () => {
describe("Editor must be unselected when the color picker is Escaped", () => { describe("Editor must be unselected when the color picker is Escaped", () => {
let pages; let pages;
beforeAll(async () => { beforeEach(async () => {
pages = await loadAndWait("tracemonkey.pdf", ".annotationEditorLayer"); pages = await loadAndWait("tracemonkey.pdf", ".annotationEditorLayer");
}); });
afterAll(async () => { afterEach(async () => {
await closePages(pages); await closePages(pages);
}); });
@ -1348,11 +1338,11 @@ describe("Highlight Editor", () => {
describe("Highlight editor mustn't be moved when close to the page limits", () => { describe("Highlight editor mustn't be moved when close to the page limits", () => {
let pages; let pages;
beforeAll(async () => { beforeEach(async () => {
pages = await loadAndWait("empty.pdf", ".annotationEditorLayer"); pages = await loadAndWait("empty.pdf", ".annotationEditorLayer");
}); });
afterAll(async () => { afterEach(async () => {
await closePages(pages); await closePages(pages);
}); });
@ -1386,11 +1376,11 @@ describe("Highlight Editor", () => {
describe("Show/hide all the highlights", () => { describe("Show/hide all the highlights", () => {
let pages; let pages;
beforeAll(async () => { beforeEach(async () => {
pages = await loadAndWait("tracemonkey.pdf", ".annotationEditorLayer"); pages = await loadAndWait("tracemonkey.pdf", ".annotationEditorLayer");
}); });
afterAll(async () => { afterEach(async () => {
await closePages(pages); await closePages(pages);
}); });
@ -1455,7 +1445,7 @@ describe("Highlight Editor", () => {
describe("Highlight from floating highlight button", () => { describe("Highlight from floating highlight button", () => {
let pages; let pages;
beforeAll(async () => { beforeEach(async () => {
pages = await loadAndWait( pages = await loadAndWait(
"tracemonkey.pdf", "tracemonkey.pdf",
".annotationEditorLayer", ".annotationEditorLayer",
@ -1465,7 +1455,7 @@ describe("Highlight Editor", () => {
); );
}); });
afterAll(async () => { afterEach(async () => {
await closePages(pages); await closePages(pages);
}); });
@ -1507,11 +1497,11 @@ describe("Highlight Editor", () => {
describe("Text layer must have the focus before highlights", () => { describe("Text layer must have the focus before highlights", () => {
let pages; let pages;
beforeAll(async () => { beforeEach(async () => {
pages = await loadAndWait("tracemonkey.pdf", ".annotationEditorLayer"); pages = await loadAndWait("tracemonkey.pdf", ".annotationEditorLayer");
}); });
afterAll(async () => { afterEach(async () => {
await closePages(pages); await closePages(pages);
}); });
@ -1550,11 +1540,11 @@ describe("Highlight Editor", () => {
describe("Undo a highlight", () => { describe("Undo a highlight", () => {
let pages; let pages;
beforeAll(async () => { beforeEach(async () => {
pages = await loadAndWait("tracemonkey.pdf", ".annotationEditorLayer"); pages = await loadAndWait("tracemonkey.pdf", ".annotationEditorLayer");
}); });
afterAll(async () => { afterEach(async () => {
await closePages(pages); await closePages(pages);
}); });
@ -1587,7 +1577,7 @@ describe("Highlight Editor", () => {
describe("Delete a highlight and undo it an other page", () => { describe("Delete a highlight and undo it an other page", () => {
let pages; let pages;
beforeAll(async () => { beforeEach(async () => {
pages = await loadAndWait( pages = await loadAndWait(
"tracemonkey.pdf", "tracemonkey.pdf",
".annotationEditorLayer", ".annotationEditorLayer",
@ -1600,7 +1590,7 @@ describe("Highlight Editor", () => {
); );
}); });
afterAll(async () => { afterEach(async () => {
await closePages(pages); await closePages(pages);
}); });
@ -1649,7 +1639,7 @@ describe("Highlight Editor", () => {
describe("Delete a highlight, scroll and undo it", () => { describe("Delete a highlight, scroll and undo it", () => {
let pages; let pages;
beforeAll(async () => { beforeEach(async () => {
pages = await loadAndWait( pages = await loadAndWait(
"tracemonkey.pdf", "tracemonkey.pdf",
".annotationEditorLayer", ".annotationEditorLayer",
@ -1662,7 +1652,7 @@ describe("Highlight Editor", () => {
); );
}); });
afterAll(async () => { afterEach(async () => {
await closePages(pages); await closePages(pages);
}); });
@ -1706,7 +1696,7 @@ describe("Highlight Editor", () => {
describe("Use a toolbar overlapping an other highlight", () => { describe("Use a toolbar overlapping an other highlight", () => {
let pages; let pages;
beforeAll(async () => { beforeEach(async () => {
pages = await loadAndWait( pages = await loadAndWait(
"tracemonkey.pdf", "tracemonkey.pdf",
".annotationEditorLayer", ".annotationEditorLayer",
@ -1719,7 +1709,7 @@ describe("Highlight Editor", () => {
); );
}); });
afterAll(async () => { afterEach(async () => {
await closePages(pages); await closePages(pages);
}); });
@ -1783,11 +1773,11 @@ describe("Highlight Editor", () => {
describe("Draw a free highlight with the pointer hovering an existing highlight", () => { describe("Draw a free highlight with the pointer hovering an existing highlight", () => {
let pages; let pages;
beforeAll(async () => { beforeEach(async () => {
pages = await loadAndWait("tracemonkey.pdf", ".annotationEditorLayer"); pages = await loadAndWait("tracemonkey.pdf", ".annotationEditorLayer");
}); });
afterAll(async () => { afterEach(async () => {
await closePages(pages); await closePages(pages);
}); });
@ -1849,11 +1839,11 @@ describe("Highlight Editor", () => {
describe("Select text with the pointer hovering an existing highlight", () => { describe("Select text with the pointer hovering an existing highlight", () => {
let pages; let pages;
beforeAll(async () => { beforeEach(async () => {
pages = await loadAndWait("tracemonkey.pdf", ".annotationEditorLayer"); pages = await loadAndWait("tracemonkey.pdf", ".annotationEditorLayer");
}); });
afterAll(async () => { afterEach(async () => {
await closePages(pages); await closePages(pages);
}); });
@ -1919,7 +1909,7 @@ describe("Highlight Editor", () => {
describe("Highlight with the floating button in a pdf containing a FreeText", () => { describe("Highlight with the floating button in a pdf containing a FreeText", () => {
let pages; let pages;
beforeAll(async () => { beforeEach(async () => {
pages = await loadAndWait( pages = await loadAndWait(
"file_pdfjs_test.pdf", "file_pdfjs_test.pdf",
".annotationEditorLayer", ".annotationEditorLayer",
@ -1929,7 +1919,7 @@ describe("Highlight Editor", () => {
); );
}); });
afterAll(async () => { afterEach(async () => {
await closePages(pages); await closePages(pages);
}); });
@ -1961,7 +1951,7 @@ describe("Highlight Editor", () => {
describe("Highlight (edit existing in double clicking on it)", () => { describe("Highlight (edit existing in double clicking on it)", () => {
let pages; let pages;
beforeAll(async () => { beforeEach(async () => {
pages = await loadAndWait( pages = await loadAndWait(
"highlights.pdf", "highlights.pdf",
".annotationEditorLayer", ".annotationEditorLayer",
@ -1974,7 +1964,7 @@ describe("Highlight Editor", () => {
); );
}); });
afterAll(async () => { afterEach(async () => {
await closePages(pages); await closePages(pages);
}); });
@ -2008,14 +1998,14 @@ describe("Highlight Editor", () => {
describe("Highlight (delete an existing annotation)", () => { describe("Highlight (delete an existing annotation)", () => {
let pages; let pages;
beforeAll(async () => { beforeEach(async () => {
pages = await loadAndWait( pages = await loadAndWait(
"highlight_popup.pdf", "highlight_popup.pdf",
".annotationEditorLayer" ".annotationEditorLayer"
); );
}); });
afterAll(async () => { afterEach(async () => {
await closePages(pages); await closePages(pages);
}); });
@ -2052,7 +2042,7 @@ describe("Highlight Editor", () => {
describe("Free Highlight (edit existing in double clicking on it)", () => { describe("Free Highlight (edit existing in double clicking on it)", () => {
let pages; let pages;
beforeAll(async () => { beforeEach(async () => {
pages = await loadAndWait( pages = await loadAndWait(
"highlights.pdf", "highlights.pdf",
".annotationEditorLayer", ".annotationEditorLayer",
@ -2065,7 +2055,7 @@ describe("Highlight Editor", () => {
); );
}); });
afterAll(async () => { afterEach(async () => {
await closePages(pages); await closePages(pages);
}); });
@ -2101,14 +2091,14 @@ describe("Highlight Editor", () => {
describe("Highlight editor mustn't throw when disabled", () => { describe("Highlight editor mustn't throw when disabled", () => {
let pages; let pages;
beforeAll(async () => { beforeEach(async () => {
pages = await loadAndWait( pages = await loadAndWait(
"annotation-highlight.pdf", "annotation-highlight.pdf",
".annotationEditorLayer" ".annotationEditorLayer"
); );
}); });
afterAll(async () => { afterEach(async () => {
await closePages(pages); await closePages(pages);
}); });
@ -2134,7 +2124,7 @@ describe("Highlight Editor", () => {
describe("Free Highlight with an image in the struct tree", () => { describe("Free Highlight with an image in the struct tree", () => {
let pages; let pages;
beforeAll(async () => { beforeEach(async () => {
pages = await loadAndWait( pages = await loadAndWait(
"bug1708040.pdf", "bug1708040.pdf",
".annotationEditorLayer", ".annotationEditorLayer",
@ -2144,7 +2134,7 @@ describe("Highlight Editor", () => {
); );
}); });
afterAll(async () => { afterEach(async () => {
await closePages(pages); await closePages(pages);
}); });
@ -2623,11 +2613,11 @@ describe("Highlight Editor", () => {
describe("Highlight mustn't trigger a scroll when edited", () => { describe("Highlight mustn't trigger a scroll when edited", () => {
let pages; let pages;
beforeAll(async () => { beforeEach(async () => {
pages = await loadAndWait("issue18911.pdf", ".annotationEditorLayer"); pages = await loadAndWait("issue18911.pdf", ".annotationEditorLayer");
}); });
afterAll(async () => { afterEach(async () => {
await closePages(pages); await closePages(pages);
}); });
@ -2678,11 +2668,11 @@ describe("Highlight Editor", () => {
describe("Highlight must be rotated when existing in the pdf", () => { describe("Highlight must be rotated when existing in the pdf", () => {
let pages; let pages;
beforeAll(async () => { beforeEach(async () => {
pages = await loadAndWait("issue19424.pdf", ".annotationEditorLayer"); pages = await loadAndWait("issue19424.pdf", ".annotationEditorLayer");
}); });
afterAll(async () => { afterEach(async () => {
await closePages(pages); await closePages(pages);
}); });