Don't use the aboutstacks.pdf file in the integration tests
For the integration tests we prefer non-linked test cases because those PDF files are directly checked into the Git repository and thus don't need a separate download step that linked test cases do. However, for the freetext and ink integration tests we currently use `aboutstacks.pdf` which is a linked test case. Fortunately we don't need to use it because for most tests we don't actually use any properties of it: we only create editors on top of the canvas, but for that any PDF file works, so we can simply use the non-linked `empty.pdf` file instead. The only exception is the "aria-owns" test that needs a line of text from the PDF file, so we move that particular test to a dedicated `describe` block and adapt it to use the non-linked `attachment.pdf` file that just contains a single line of text that can be used for this purpose. The changes combined make 12 more integration tests run out-of-the-box after a Git clone, which also simplifies running on GitHub Actions.
This commit is contained in:
parent
b87c999815
commit
9ab4de5c04
@ -90,7 +90,7 @@ describe("FreeText Editor", () => {
|
||||
let pages;
|
||||
|
||||
beforeEach(async () => {
|
||||
pages = await loadAndWait("aboutstacks.pdf", ".annotationEditorLayer");
|
||||
pages = await loadAndWait("empty.pdf", ".annotationEditorLayer");
|
||||
});
|
||||
|
||||
afterEach(async () => {
|
||||
@ -311,53 +311,6 @@ describe("FreeText Editor", () => {
|
||||
}
|
||||
});
|
||||
|
||||
it("must check that aria-owns is correct", async () => {
|
||||
await Promise.all(
|
||||
pages.map(async ([browserName, page]) => {
|
||||
await switchToFreeText(page);
|
||||
|
||||
await page.$eval(".textLayer", el => {
|
||||
for (const span of el.querySelectorAll(
|
||||
`span[role="presentation"]`
|
||||
)) {
|
||||
if (span.innerText.includes("Stacks are simple to create")) {
|
||||
span.setAttribute("pdfjs", true);
|
||||
}
|
||||
}
|
||||
});
|
||||
|
||||
await scrollIntoView(page, `span[pdfjs="true"]`);
|
||||
|
||||
const stacksRect = await getRect(page, `span[pdfjs="true"]`);
|
||||
const oldAriaOwns = await page.$eval(`span[pdfjs="true"]`, el =>
|
||||
el.getAttribute("aria-owns")
|
||||
);
|
||||
|
||||
expect(oldAriaOwns).withContext(`In ${browserName}`).toEqual(null);
|
||||
|
||||
const editorSelector = getEditorSelector(0);
|
||||
const data = "Hello PDF.js World !!";
|
||||
await page.mouse.click(
|
||||
stacksRect.x + stacksRect.width + 1,
|
||||
stacksRect.y + stacksRect.height / 2
|
||||
);
|
||||
await page.waitForSelector(editorSelector, { visible: true });
|
||||
await page.type(`${editorSelector} .internal`, data);
|
||||
await commit(page);
|
||||
|
||||
const ariaOwns = await page.$eval(".textLayer", el => {
|
||||
const span = el.querySelector(`span[pdfjs="true"]`);
|
||||
return span?.getAttribute("aria-owns") || null;
|
||||
});
|
||||
|
||||
expect(ariaOwns.endsWith("_0-editor"))
|
||||
.withContext(`In ${browserName}`)
|
||||
.toEqual(true);
|
||||
await scrollIntoView(page, ".annotationEditorLayer");
|
||||
})
|
||||
);
|
||||
});
|
||||
|
||||
it("must check that right click doesn't select", async () => {
|
||||
await Promise.all(
|
||||
pages.map(async ([browserName, page]) => {
|
||||
@ -490,7 +443,7 @@ describe("FreeText Editor", () => {
|
||||
let pages;
|
||||
|
||||
beforeEach(async () => {
|
||||
pages = await loadAndWait("aboutstacks.pdf", ".annotationEditorLayer");
|
||||
pages = await loadAndWait("empty.pdf", ".annotationEditorLayer");
|
||||
});
|
||||
|
||||
afterEach(async () => {
|
||||
@ -643,6 +596,59 @@ describe("FreeText Editor", () => {
|
||||
});
|
||||
});
|
||||
|
||||
describe("FreeText (accessibility)", () => {
|
||||
let pages;
|
||||
|
||||
beforeEach(async () => {
|
||||
pages = await loadAndWait("attachment.pdf", ".annotationEditorLayer");
|
||||
});
|
||||
|
||||
afterEach(async () => {
|
||||
await closePages(pages);
|
||||
});
|
||||
|
||||
it("must check that aria-owns is correct", async () => {
|
||||
await Promise.all(
|
||||
pages.map(async ([browserName, page]) => {
|
||||
await switchToFreeText(page);
|
||||
|
||||
await page.$eval(".textLayer", el => {
|
||||
for (const span of el.querySelectorAll(
|
||||
`span[role="presentation"]`
|
||||
)) {
|
||||
if (span.innerText.includes("This document contains")) {
|
||||
span.setAttribute("pdfjs", true);
|
||||
}
|
||||
}
|
||||
});
|
||||
|
||||
const oldAriaOwns = await page.$eval(`span[pdfjs="true"]`, el =>
|
||||
el.getAttribute("aria-owns")
|
||||
);
|
||||
expect(oldAriaOwns).withContext(`In ${browserName}`).toEqual(null);
|
||||
|
||||
const editorSelector = getEditorSelector(0);
|
||||
const rect = await getRect(page, `span[pdfjs="true"]`);
|
||||
const data = "Hello PDF.js World !!";
|
||||
await page.mouse.click(
|
||||
rect.x + rect.width / 2,
|
||||
rect.y + rect.height / 2
|
||||
);
|
||||
await page.waitForSelector(editorSelector, { visible: true });
|
||||
await page.type(`${editorSelector} .internal`, data);
|
||||
await commit(page);
|
||||
|
||||
const newAriaOwns = await page.$eval(`span[pdfjs="true"]`, el =>
|
||||
el.getAttribute("aria-owns")
|
||||
);
|
||||
expect(newAriaOwns.endsWith("_0-editor"))
|
||||
.withContext(`In ${browserName}`)
|
||||
.toEqual(true);
|
||||
})
|
||||
);
|
||||
});
|
||||
});
|
||||
|
||||
describe("FreeText (bugs)", () => {
|
||||
let pages;
|
||||
|
||||
|
||||
@ -57,7 +57,7 @@ describe("Ink Editor", () => {
|
||||
let pages;
|
||||
|
||||
beforeEach(async () => {
|
||||
pages = await loadAndWait("aboutstacks.pdf", ".annotationEditorLayer");
|
||||
pages = await loadAndWait("empty.pdf", ".annotationEditorLayer");
|
||||
});
|
||||
|
||||
afterEach(async () => {
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user