Skip to content

Commit 440d519

Browse files
committed
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.
1 parent 72212a8 commit 440d519

1 file changed

Lines changed: 15 additions & 7 deletions

File tree

test/integration/freetext_editor_spec.mjs

Lines changed: 15 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1705,11 +1705,11 @@ describe("FreeText Editor", () => {
17051705
describe("Move editor with arrows", () => {
17061706
let pages;
17071707

1708-
beforeAll(async () => {
1708+
beforeEach(async () => {
17091709
pages = await loadAndWait("empty.pdf", ".annotationEditorLayer");
17101710
});
17111711

1712-
afterAll(async () => {
1712+
afterEach(async () => {
17131713
await closePages(pages);
17141714
});
17151715

@@ -1779,6 +1779,16 @@ describe("FreeText Editor", () => {
17791779
it("must check arrow doesn't move an editor when a slider is focused", async () => {
17801780
await Promise.all(
17811781
pages.map(async ([browserName, page]) => {
1782+
await switchToFreeText(page);
1783+
1784+
const rect = await getRect(page, ".annotationEditorLayer");
1785+
const data = "Hello PDF.js World !!";
1786+
const editorSelector = getEditorSelector(0);
1787+
await page.mouse.click(rect.x + 200, rect.y + 200);
1788+
await page.waitForSelector(editorSelector, { visible: true });
1789+
await page.type(`${editorSelector} .internal`, data);
1790+
await commit(page);
1791+
17821792
await selectAll(page);
17831793
await page.focus("#editorFreeTextFontSize");
17841794

@@ -1788,7 +1798,6 @@ describe("FreeText Editor", () => {
17881798
);
17891799
const pageWidth = page2X - page1X;
17901800

1791-
const editorSelector = getEditorSelector(0);
17921801
await moveEditor(page, editorSelector, 5, () =>
17931802
page.keyboard.press("ArrowRight")
17941803
);
@@ -1808,12 +1817,11 @@ describe("FreeText Editor", () => {
18081817
it("must check the position of an empty freetext", async () => {
18091818
await Promise.all(
18101819
pages.map(async ([browserName, page]) => {
1811-
await clearAll(page);
1820+
await switchToFreeText(page);
18121821

18131822
const rect = await getRect(page, ".annotationEditorLayer");
1814-
18151823
const data = "Hello PDF.js World !!";
1816-
let editorSelector = getEditorSelector(1);
1824+
let editorSelector = getEditorSelector(0);
18171825
await page.mouse.click(rect.x + 100, rect.y + 100);
18181826
await page.waitForSelector(editorSelector, { visible: true });
18191827
await page.type(`${editorSelector} .internal`, data);
@@ -1822,7 +1830,7 @@ describe("FreeText Editor", () => {
18221830
const [pageX, pageY] = await getFirstSerialized(page, x => x.rect);
18231831

18241832
await clearAll(page);
1825-
editorSelector = getEditorSelector(2);
1833+
editorSelector = getEditorSelector(1);
18261834
await page.mouse.click(rect.x + 100, rect.y + 100);
18271835
await page.waitForSelector(editorSelector, { visible: true });
18281836

0 commit comments

Comments
 (0)