Skip to content

Commit 9f397a6

Browse files
authored
Merge pull request #20378 from timvandermeij/integration-tests-aboutstacks
Don't use the `aboutstacks.pdf` file in the integration tests
2 parents a40df9a + 9ab4de5 commit 9f397a6

File tree

2 files changed

+56
-50
lines changed

2 files changed

+56
-50
lines changed

test/integration/freetext_editor_spec.mjs

Lines changed: 55 additions & 49 deletions
Original file line numberDiff line numberDiff line change
@@ -90,7 +90,7 @@ describe("FreeText Editor", () => {
9090
let pages;
9191

9292
beforeEach(async () => {
93-
pages = await loadAndWait("aboutstacks.pdf", ".annotationEditorLayer");
93+
pages = await loadAndWait("empty.pdf", ".annotationEditorLayer");
9494
});
9595

9696
afterEach(async () => {
@@ -311,53 +311,6 @@ describe("FreeText Editor", () => {
311311
}
312312
});
313313

314-
it("must check that aria-owns is correct", async () => {
315-
await Promise.all(
316-
pages.map(async ([browserName, page]) => {
317-
await switchToFreeText(page);
318-
319-
await page.$eval(".textLayer", el => {
320-
for (const span of el.querySelectorAll(
321-
`span[role="presentation"]`
322-
)) {
323-
if (span.innerText.includes("Stacks are simple to create")) {
324-
span.setAttribute("pdfjs", true);
325-
}
326-
}
327-
});
328-
329-
await scrollIntoView(page, `span[pdfjs="true"]`);
330-
331-
const stacksRect = await getRect(page, `span[pdfjs="true"]`);
332-
const oldAriaOwns = await page.$eval(`span[pdfjs="true"]`, el =>
333-
el.getAttribute("aria-owns")
334-
);
335-
336-
expect(oldAriaOwns).withContext(`In ${browserName}`).toEqual(null);
337-
338-
const editorSelector = getEditorSelector(0);
339-
const data = "Hello PDF.js World !!";
340-
await page.mouse.click(
341-
stacksRect.x + stacksRect.width + 1,
342-
stacksRect.y + stacksRect.height / 2
343-
);
344-
await page.waitForSelector(editorSelector, { visible: true });
345-
await page.type(`${editorSelector} .internal`, data);
346-
await commit(page);
347-
348-
const ariaOwns = await page.$eval(".textLayer", el => {
349-
const span = el.querySelector(`span[pdfjs="true"]`);
350-
return span?.getAttribute("aria-owns") || null;
351-
});
352-
353-
expect(ariaOwns.endsWith("_0-editor"))
354-
.withContext(`In ${browserName}`)
355-
.toEqual(true);
356-
await scrollIntoView(page, ".annotationEditorLayer");
357-
})
358-
);
359-
});
360-
361314
it("must check that right click doesn't select", async () => {
362315
await Promise.all(
363316
pages.map(async ([browserName, page]) => {
@@ -490,7 +443,7 @@ describe("FreeText Editor", () => {
490443
let pages;
491444

492445
beforeEach(async () => {
493-
pages = await loadAndWait("aboutstacks.pdf", ".annotationEditorLayer");
446+
pages = await loadAndWait("empty.pdf", ".annotationEditorLayer");
494447
});
495448

496449
afterEach(async () => {
@@ -643,6 +596,59 @@ describe("FreeText Editor", () => {
643596
});
644597
});
645598

599+
describe("FreeText (accessibility)", () => {
600+
let pages;
601+
602+
beforeEach(async () => {
603+
pages = await loadAndWait("attachment.pdf", ".annotationEditorLayer");
604+
});
605+
606+
afterEach(async () => {
607+
await closePages(pages);
608+
});
609+
610+
it("must check that aria-owns is correct", async () => {
611+
await Promise.all(
612+
pages.map(async ([browserName, page]) => {
613+
await switchToFreeText(page);
614+
615+
await page.$eval(".textLayer", el => {
616+
for (const span of el.querySelectorAll(
617+
`span[role="presentation"]`
618+
)) {
619+
if (span.innerText.includes("This document contains")) {
620+
span.setAttribute("pdfjs", true);
621+
}
622+
}
623+
});
624+
625+
const oldAriaOwns = await page.$eval(`span[pdfjs="true"]`, el =>
626+
el.getAttribute("aria-owns")
627+
);
628+
expect(oldAriaOwns).withContext(`In ${browserName}`).toEqual(null);
629+
630+
const editorSelector = getEditorSelector(0);
631+
const rect = await getRect(page, `span[pdfjs="true"]`);
632+
const data = "Hello PDF.js World !!";
633+
await page.mouse.click(
634+
rect.x + rect.width / 2,
635+
rect.y + rect.height / 2
636+
);
637+
await page.waitForSelector(editorSelector, { visible: true });
638+
await page.type(`${editorSelector} .internal`, data);
639+
await commit(page);
640+
641+
const newAriaOwns = await page.$eval(`span[pdfjs="true"]`, el =>
642+
el.getAttribute("aria-owns")
643+
);
644+
expect(newAriaOwns.endsWith("_0-editor"))
645+
.withContext(`In ${browserName}`)
646+
.toEqual(true);
647+
})
648+
);
649+
});
650+
});
651+
646652
describe("FreeText (bugs)", () => {
647653
let pages;
648654

test/integration/ink_editor_spec.mjs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -57,7 +57,7 @@ describe("Ink Editor", () => {
5757
let pages;
5858

5959
beforeEach(async () => {
60-
pages = await loadAndWait("aboutstacks.pdf", ".annotationEditorLayer");
60+
pages = await loadAndWait("empty.pdf", ".annotationEditorLayer");
6161
});
6262

6363
afterEach(async () => {

0 commit comments

Comments
 (0)