Merge pull request #17189 from calixteman/mac_integration_test
Fix integration tests on Mac
This commit is contained in:
commit
6115a328ea
@ -15,6 +15,8 @@
|
|||||||
|
|
||||||
import {
|
import {
|
||||||
closePages,
|
closePages,
|
||||||
|
kbCopy,
|
||||||
|
kbSelectAll,
|
||||||
loadAndWait,
|
loadAndWait,
|
||||||
mockClipboard,
|
mockClipboard,
|
||||||
waitForEvent,
|
waitForEvent,
|
||||||
@ -23,9 +25,7 @@ import {
|
|||||||
|
|
||||||
const selectAll = async page => {
|
const selectAll = async page => {
|
||||||
const promise = waitForEvent(page, "selectionchange");
|
const promise = waitForEvent(page, "selectionchange");
|
||||||
await page.keyboard.down("Control");
|
await kbSelectAll(page);
|
||||||
await page.keyboard.press("a");
|
|
||||||
await page.keyboard.up("Control");
|
|
||||||
await promise;
|
await promise;
|
||||||
|
|
||||||
await page.waitForFunction(() => {
|
await page.waitForFunction(() => {
|
||||||
@ -64,9 +64,7 @@ describe("Copy and paste", () => {
|
|||||||
await selectAll(page);
|
await selectAll(page);
|
||||||
|
|
||||||
const promise = waitForEvent(page, "copy");
|
const promise = waitForEvent(page, "copy");
|
||||||
await page.keyboard.down("Control");
|
await kbCopy(page);
|
||||||
await page.keyboard.press("c");
|
|
||||||
await page.keyboard.up("Control");
|
|
||||||
await promise;
|
await promise;
|
||||||
|
|
||||||
await page.waitForFunction(
|
await page.waitForFunction(
|
||||||
@ -173,9 +171,7 @@ describe("Copy and paste", () => {
|
|||||||
await selectAll(page);
|
await selectAll(page);
|
||||||
|
|
||||||
const promise = waitForEvent(page, "copy");
|
const promise = waitForEvent(page, "copy");
|
||||||
await page.keyboard.down("Control");
|
await kbCopy(page);
|
||||||
await page.keyboard.press("c");
|
|
||||||
await page.keyboard.up("Control");
|
|
||||||
await promise;
|
await promise;
|
||||||
|
|
||||||
await page.waitForFunction(
|
await page.waitForFunction(
|
||||||
|
@ -29,7 +29,7 @@ describe("find bar", () => {
|
|||||||
let pages;
|
let pages;
|
||||||
|
|
||||||
beforeAll(async () => {
|
beforeAll(async () => {
|
||||||
pages = await loadAndWait("find_all.pdf#zoom=100", ".textLayer");
|
pages = await loadAndWait("find_all.pdf", ".textLayer", 100);
|
||||||
});
|
});
|
||||||
|
|
||||||
afterAll(async () => {
|
afterAll(async () => {
|
||||||
@ -76,7 +76,7 @@ describe("find bar", () => {
|
|||||||
let pages;
|
let pages;
|
||||||
|
|
||||||
beforeAll(async () => {
|
beforeAll(async () => {
|
||||||
pages = await loadAndWait("xfa_imm5257e.pdf#zoom=100", ".xfaLayer");
|
pages = await loadAndWait("xfa_imm5257e.pdf", ".xfaLayer");
|
||||||
});
|
});
|
||||||
|
|
||||||
afterAll(async () => {
|
afterAll(async () => {
|
||||||
@ -91,6 +91,9 @@ describe("find bar", () => {
|
|||||||
await page.type("#findInput", "preferences");
|
await page.type("#findInput", "preferences");
|
||||||
await page.waitForSelector("#findInput[data-status='']");
|
await page.waitForSelector("#findInput[data-status='']");
|
||||||
await page.waitForSelector(".xfaLayer .highlight");
|
await page.waitForSelector(".xfaLayer .highlight");
|
||||||
|
await page.waitForFunction(
|
||||||
|
() => !!document.querySelector("#findResultsCount")?.textContent
|
||||||
|
);
|
||||||
const resultElement = await page.waitForSelector("#findResultsCount");
|
const resultElement = await page.waitForSelector("#findResultsCount");
|
||||||
const resultText = await resultElement.evaluate(el => el.textContent);
|
const resultText = await resultElement.evaluate(el => el.textContent);
|
||||||
/** Unicode bidi isolation characters. */
|
/** Unicode bidi isolation characters. */
|
||||||
|
@ -21,6 +21,20 @@ import {
|
|||||||
getFirstSerialized,
|
getFirstSerialized,
|
||||||
getSelectedEditors,
|
getSelectedEditors,
|
||||||
getSerialized,
|
getSerialized,
|
||||||
|
hover,
|
||||||
|
kbBigMoveDown,
|
||||||
|
kbBigMoveLeft,
|
||||||
|
kbBigMoveRight,
|
||||||
|
kbBigMoveUp,
|
||||||
|
kbCopy,
|
||||||
|
kbGoToBegin,
|
||||||
|
kbGoToEnd,
|
||||||
|
kbModifierDown,
|
||||||
|
kbModifierUp,
|
||||||
|
kbPaste,
|
||||||
|
kbRedo,
|
||||||
|
kbSelectAll,
|
||||||
|
kbUndo,
|
||||||
loadAndWait,
|
loadAndWait,
|
||||||
scrollIntoView,
|
scrollIntoView,
|
||||||
waitForEvent,
|
waitForEvent,
|
||||||
@ -33,24 +47,18 @@ import { PNG } from "pngjs";
|
|||||||
|
|
||||||
const copyPaste = async page => {
|
const copyPaste = async page => {
|
||||||
let promise = waitForEvent(page, "copy");
|
let promise = waitForEvent(page, "copy");
|
||||||
await page.keyboard.down("Control");
|
await kbCopy(page);
|
||||||
await page.keyboard.press("c");
|
|
||||||
await page.keyboard.up("Control");
|
|
||||||
await promise;
|
await promise;
|
||||||
|
|
||||||
await page.waitForTimeout(10);
|
await page.waitForTimeout(10);
|
||||||
|
|
||||||
promise = waitForEvent(page, "paste");
|
promise = waitForEvent(page, "paste");
|
||||||
await page.keyboard.down("Control");
|
await kbPaste(page);
|
||||||
await page.keyboard.press("v");
|
|
||||||
await page.keyboard.up("Control");
|
|
||||||
await promise;
|
await promise;
|
||||||
};
|
};
|
||||||
|
|
||||||
const selectAll = async page => {
|
const selectAll = async page => {
|
||||||
await page.keyboard.down("Control");
|
await kbSelectAll(page);
|
||||||
await page.keyboard.press("a");
|
|
||||||
await page.keyboard.up("Control");
|
|
||||||
await page.waitForFunction(
|
await page.waitForFunction(
|
||||||
() => !document.querySelector(".freeTextEditor:not(.selectedEditor)")
|
() => !document.querySelector(".freeTextEditor:not(.selectedEditor)")
|
||||||
);
|
);
|
||||||
@ -85,6 +93,20 @@ const waitForPositionChange = (page, selector, xy) =>
|
|||||||
xy
|
xy
|
||||||
);
|
);
|
||||||
|
|
||||||
|
const cancelFocusIn = async (page, selector) => {
|
||||||
|
page.evaluate(sel => {
|
||||||
|
const el = document.querySelector(sel);
|
||||||
|
el.addEventListener(
|
||||||
|
"focusin",
|
||||||
|
evt => {
|
||||||
|
evt.preventDefault();
|
||||||
|
evt.stopPropagation();
|
||||||
|
},
|
||||||
|
{ capture: true, once: true }
|
||||||
|
);
|
||||||
|
}, selector);
|
||||||
|
};
|
||||||
|
|
||||||
describe("FreeText Editor", () => {
|
describe("FreeText Editor", () => {
|
||||||
describe("FreeText", () => {
|
describe("FreeText", () => {
|
||||||
let pages;
|
let pages;
|
||||||
@ -264,9 +286,7 @@ describe("FreeText Editor", () => {
|
|||||||
visible: true,
|
visible: true,
|
||||||
});
|
});
|
||||||
|
|
||||||
await page.keyboard.down("Control");
|
await kbUndo(page);
|
||||||
await page.keyboard.press("z");
|
|
||||||
await page.keyboard.up("Control");
|
|
||||||
await page.waitForFunction(
|
await page.waitForFunction(
|
||||||
sel => !document.querySelector(sel),
|
sel => !document.querySelector(sel),
|
||||||
{},
|
{},
|
||||||
@ -275,17 +295,13 @@ describe("FreeText Editor", () => {
|
|||||||
|
|
||||||
for (let i = 0; i < 2; i++) {
|
for (let i = 0; i < 2; i++) {
|
||||||
const promise = waitForEvent(page, "paste");
|
const promise = waitForEvent(page, "paste");
|
||||||
await page.keyboard.down("Control");
|
await kbPaste(page);
|
||||||
await page.keyboard.press("v");
|
|
||||||
await page.keyboard.up("Control");
|
|
||||||
await promise;
|
await promise;
|
||||||
await page.waitForSelector(getEditorSelector(5 + i));
|
await page.waitForSelector(getEditorSelector(5 + i));
|
||||||
}
|
}
|
||||||
|
|
||||||
for (let i = 0; i < 2; i++) {
|
for (let i = 0; i < 2; i++) {
|
||||||
await page.keyboard.down("Control");
|
await kbUndo(page);
|
||||||
await page.keyboard.press("z");
|
|
||||||
await page.keyboard.up("Control");
|
|
||||||
await page.waitForFunction(
|
await page.waitForFunction(
|
||||||
sel => !document.querySelector(sel),
|
sel => !document.querySelector(sel),
|
||||||
{},
|
{},
|
||||||
@ -298,22 +314,23 @@ describe("FreeText Editor", () => {
|
|||||||
it("must check that aria-owns is correct", async () => {
|
it("must check that aria-owns is correct", async () => {
|
||||||
await Promise.all(
|
await Promise.all(
|
||||||
pages.map(async ([browserName, page]) => {
|
pages.map(async ([browserName, page]) => {
|
||||||
const [stacksRect, oldAriaOwns] = await page.$eval(
|
await page.$eval(".textLayer", el => {
|
||||||
".textLayer",
|
for (const span of el.querySelectorAll(
|
||||||
el => {
|
`span[role="presentation"]`
|
||||||
for (const span of el.querySelectorAll(
|
)) {
|
||||||
`span[role="presentation"]`
|
if (span.innerText.includes("Stacks are simple to create")) {
|
||||||
)) {
|
span.setAttribute("pdfjs", true);
|
||||||
if (span.innerText.includes("Stacks are simple to create")) {
|
|
||||||
span.setAttribute("pdfjs", true);
|
|
||||||
const { x, y, width, height } = span.getBoundingClientRect();
|
|
||||||
return [
|
|
||||||
{ x, y, width, height },
|
|
||||||
span.getAttribute("aria-owns"),
|
|
||||||
];
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
return null;
|
}
|
||||||
|
});
|
||||||
|
|
||||||
|
await scrollIntoView(page, `span[pdfjs="true"]`);
|
||||||
|
|
||||||
|
const [stacksRect, oldAriaOwns] = await page.$eval(
|
||||||
|
`span[pdfjs="true"]`,
|
||||||
|
el => {
|
||||||
|
const { x, y, width, height } = el.getBoundingClientRect();
|
||||||
|
return [{ x, y, width, height }, el.getAttribute("aria-owns")];
|
||||||
}
|
}
|
||||||
);
|
);
|
||||||
|
|
||||||
@ -343,6 +360,7 @@ describe("FreeText Editor", () => {
|
|||||||
expect(ariaOwns.endsWith("_7-editor"))
|
expect(ariaOwns.endsWith("_7-editor"))
|
||||||
.withContext(`In ${browserName}`)
|
.withContext(`In ${browserName}`)
|
||||||
.toEqual(true);
|
.toEqual(true);
|
||||||
|
await scrollIntoView(page, ".annotationEditorLayer");
|
||||||
})
|
})
|
||||||
);
|
);
|
||||||
});
|
});
|
||||||
@ -473,26 +491,20 @@ describe("FreeText Editor", () => {
|
|||||||
page.$eval(`${getEditorSelector(9)} .internal`, el => el.innerText);
|
page.$eval(`${getEditorSelector(9)} .internal`, el => el.innerText);
|
||||||
|
|
||||||
// We're in the middle of the text.
|
// We're in the middle of the text.
|
||||||
await page.keyboard.down("Control");
|
await kbUndo(page);
|
||||||
await page.keyboard.press("z");
|
|
||||||
await page.keyboard.up("Control");
|
|
||||||
await waitForTextChange(prevText);
|
await waitForTextChange(prevText);
|
||||||
|
|
||||||
let text = (prevText = await getText());
|
let text = (prevText = await getText());
|
||||||
expect(text).withContext(`In ${browserName}`).toEqual("AAAA");
|
expect(text).withContext(`In ${browserName}`).toEqual("AAAA");
|
||||||
|
|
||||||
await page.keyboard.down("Control");
|
await kbUndo(page);
|
||||||
await page.keyboard.press("z");
|
|
||||||
await page.keyboard.up("Control");
|
|
||||||
await waitForTextChange(prevText);
|
await waitForTextChange(prevText);
|
||||||
|
|
||||||
text = prevText = await getText();
|
text = prevText = await getText();
|
||||||
|
|
||||||
expect(text).withContext(`In ${browserName}`).toEqual("AAA");
|
expect(text).withContext(`In ${browserName}`).toEqual("AAA");
|
||||||
|
|
||||||
await page.keyboard.down("Control");
|
await kbRedo(page);
|
||||||
await page.keyboard.press("y");
|
|
||||||
await page.keyboard.up("Control");
|
|
||||||
await waitForTextChange(prevText);
|
await waitForTextChange(prevText);
|
||||||
|
|
||||||
text = prevText = await getText();
|
text = prevText = await getText();
|
||||||
@ -500,9 +512,7 @@ describe("FreeText Editor", () => {
|
|||||||
expect(text).withContext(`In ${browserName}`).toEqual("AAAA");
|
expect(text).withContext(`In ${browserName}`).toEqual("AAAA");
|
||||||
|
|
||||||
for (let i = 0; i < 4; i++) {
|
for (let i = 0; i < 4; i++) {
|
||||||
await page.keyboard.down("Control");
|
await kbUndo(page);
|
||||||
await page.keyboard.press("z");
|
|
||||||
await page.keyboard.up("Control");
|
|
||||||
if (i < 3) {
|
if (i < 3) {
|
||||||
await waitForTextChange(prevText);
|
await waitForTextChange(prevText);
|
||||||
prevText = await getText();
|
prevText = await getText();
|
||||||
@ -513,9 +523,7 @@ describe("FreeText Editor", () => {
|
|||||||
() => !document.querySelector(".selectedEditor")
|
() => !document.querySelector(".selectedEditor")
|
||||||
);
|
);
|
||||||
|
|
||||||
await page.keyboard.down("Control");
|
await kbRedo(page);
|
||||||
await page.keyboard.press("y");
|
|
||||||
await page.keyboard.up("Control");
|
|
||||||
await page.waitForSelector(getEditorSelector(9), {
|
await page.waitForSelector(getEditorSelector(9), {
|
||||||
visible: true,
|
visible: true,
|
||||||
});
|
});
|
||||||
@ -570,16 +578,16 @@ describe("FreeText Editor", () => {
|
|||||||
const rect = await page.$eval(".annotationEditorLayer", el => {
|
const rect = await page.$eval(".annotationEditorLayer", el => {
|
||||||
// With Chrome something is wrong when serializing a DomRect,
|
// With Chrome something is wrong when serializing a DomRect,
|
||||||
// hence we extract the values and just return them.
|
// hence we extract the values and just return them.
|
||||||
const { x, y } = el.getBoundingClientRect();
|
const { x, y, width, height } = el.getBoundingClientRect();
|
||||||
return { x, y };
|
return { x, y, width, height };
|
||||||
});
|
});
|
||||||
|
|
||||||
const editorCenters = [];
|
const editorCenters = [];
|
||||||
for (let i = 0; i < 4; i++) {
|
for (let i = 0; i < 4; i++) {
|
||||||
const data = `FreeText ${i}`;
|
const data = `FreeText ${i}`;
|
||||||
await page.mouse.click(
|
await page.mouse.click(
|
||||||
rect.x + (i + 1) * 100,
|
rect.x + ((i + 1) * rect.width) / 10,
|
||||||
rect.y + (i + 1) * 100
|
rect.y + ((i + 1) * rect.height) / 10
|
||||||
);
|
);
|
||||||
await page.waitForSelector(getEditorSelector(i), {
|
await page.waitForSelector(getEditorSelector(i), {
|
||||||
visible: true,
|
visible: true,
|
||||||
@ -617,7 +625,7 @@ describe("FreeText Editor", () => {
|
|||||||
.toEqual([0, 1, 2, 3]);
|
.toEqual([0, 1, 2, 3]);
|
||||||
|
|
||||||
// Unselect the editor.
|
// Unselect the editor.
|
||||||
await page.keyboard.down("Control");
|
await kbModifierDown(page);
|
||||||
await page.mouse.click(editorCenters[1].x, editorCenters[1].y);
|
await page.mouse.click(editorCenters[1].x, editorCenters[1].y);
|
||||||
await waitForUnselectedEditor(page, getEditorSelector(1));
|
await waitForUnselectedEditor(page, getEditorSelector(1));
|
||||||
|
|
||||||
@ -633,7 +641,7 @@ describe("FreeText Editor", () => {
|
|||||||
.toEqual([0, 3]);
|
.toEqual([0, 3]);
|
||||||
|
|
||||||
await page.mouse.click(editorCenters[1].x, editorCenters[1].y);
|
await page.mouse.click(editorCenters[1].x, editorCenters[1].y);
|
||||||
await page.keyboard.up("Control");
|
await kbModifierUp(page);
|
||||||
await waitForSelectedEditor(page, getEditorSelector(1));
|
await waitForSelectedEditor(page, getEditorSelector(1));
|
||||||
|
|
||||||
expect(await getSelectedEditors(page))
|
expect(await getSelectedEditors(page))
|
||||||
@ -663,7 +671,7 @@ describe("FreeText Editor", () => {
|
|||||||
.withContext(`In ${browserName}`)
|
.withContext(`In ${browserName}`)
|
||||||
.toEqual([1]);
|
.toEqual([1]);
|
||||||
|
|
||||||
await page.keyboard.down("Control");
|
await kbModifierDown(page);
|
||||||
|
|
||||||
await page.mouse.click(editorCenters[3].x, editorCenters[3].y);
|
await page.mouse.click(editorCenters[3].x, editorCenters[3].y);
|
||||||
await waitForSelectedEditor(page, getEditorSelector(3));
|
await waitForSelectedEditor(page, getEditorSelector(3));
|
||||||
@ -671,7 +679,7 @@ describe("FreeText Editor", () => {
|
|||||||
.withContext(`In ${browserName}`)
|
.withContext(`In ${browserName}`)
|
||||||
.toEqual([1, 3]);
|
.toEqual([1, 3]);
|
||||||
|
|
||||||
await page.keyboard.up("Control");
|
await kbModifierUp(page);
|
||||||
|
|
||||||
// Delete 1 and 3.
|
// Delete 1 and 3.
|
||||||
await page.keyboard.press("Backspace");
|
await page.keyboard.press("Backspace");
|
||||||
@ -688,7 +696,10 @@ describe("FreeText Editor", () => {
|
|||||||
.toEqual([0, 2, 4, 5, 6]);
|
.toEqual([0, 2, 4, 5, 6]);
|
||||||
|
|
||||||
// Create an empty editor.
|
// Create an empty editor.
|
||||||
await page.mouse.click(rect.x + 700, rect.y + 100);
|
await page.mouse.click(
|
||||||
|
rect.x + (rect.width / 10) * 7,
|
||||||
|
rect.y + rect.height / 10
|
||||||
|
);
|
||||||
await page.waitForSelector(getEditorSelector(7), {
|
await page.waitForSelector(getEditorSelector(7), {
|
||||||
visible: true,
|
visible: true,
|
||||||
});
|
});
|
||||||
@ -704,7 +715,10 @@ describe("FreeText Editor", () => {
|
|||||||
.toEqual([2]);
|
.toEqual([2]);
|
||||||
|
|
||||||
// Create an empty editor.
|
// Create an empty editor.
|
||||||
await page.mouse.click(rect.x + 700, rect.y + 100);
|
await page.mouse.click(
|
||||||
|
rect.x + (rect.width / 10) * 8,
|
||||||
|
rect.y + rect.height / 10
|
||||||
|
);
|
||||||
await page.waitForSelector(getEditorSelector(8), {
|
await page.waitForSelector(getEditorSelector(8), {
|
||||||
visible: true,
|
visible: true,
|
||||||
});
|
});
|
||||||
@ -1057,9 +1071,7 @@ describe("FreeText Editor", () => {
|
|||||||
`${getEditorSelector(0)} .overlay:not(.enabled)`
|
`${getEditorSelector(0)} .overlay:not(.enabled)`
|
||||||
);
|
);
|
||||||
|
|
||||||
await page.keyboard.down("Control");
|
await kbGoToEnd(page);
|
||||||
await page.keyboard.press("End");
|
|
||||||
await page.keyboard.up("Control");
|
|
||||||
await page.waitForFunction(
|
await page.waitForFunction(
|
||||||
sel =>
|
sel =>
|
||||||
document.getSelection().anchorOffset ===
|
document.getSelection().anchorOffset ===
|
||||||
@ -1113,19 +1125,14 @@ describe("FreeText Editor", () => {
|
|||||||
await switchToFreeText(page);
|
await switchToFreeText(page);
|
||||||
await page.focus(".annotationEditorLayer");
|
await page.focus(".annotationEditorLayer");
|
||||||
|
|
||||||
// Undo.
|
await kbUndo(page);
|
||||||
await page.keyboard.down("Control");
|
|
||||||
await page.keyboard.press("z");
|
|
||||||
await page.keyboard.up("Control");
|
|
||||||
await waitForSerialized(page, 0);
|
await waitForSerialized(page, 0);
|
||||||
|
|
||||||
editorIds = await getEditors(page, "freeText");
|
editorIds = await getEditors(page, "freeText");
|
||||||
expect(editorIds.length).withContext(`In ${browserName}`).toEqual(6);
|
expect(editorIds.length).withContext(`In ${browserName}`).toEqual(6);
|
||||||
|
|
||||||
// Undo again.
|
// Undo again.
|
||||||
await page.keyboard.down("Control");
|
await kbUndo(page);
|
||||||
await page.keyboard.press("z");
|
|
||||||
await page.keyboard.up("Control");
|
|
||||||
// Nothing should happen, it's why we can't wait for something
|
// Nothing should happen, it's why we can't wait for something
|
||||||
// specific!
|
// specific!
|
||||||
await page.waitForTimeout(200);
|
await page.waitForTimeout(200);
|
||||||
@ -1224,10 +1231,7 @@ describe("FreeText Editor", () => {
|
|||||||
await switchToFreeText(page);
|
await switchToFreeText(page);
|
||||||
await page.focus(".annotationEditorLayer");
|
await page.focus(".annotationEditorLayer");
|
||||||
|
|
||||||
// Undo.
|
await kbUndo(page);
|
||||||
await page.keyboard.down("Control");
|
|
||||||
await page.keyboard.press("z");
|
|
||||||
await page.keyboard.up("Control");
|
|
||||||
await waitForSerialized(page, 0);
|
await waitForSerialized(page, 0);
|
||||||
})
|
})
|
||||||
);
|
);
|
||||||
@ -1322,7 +1326,11 @@ describe("FreeText Editor", () => {
|
|||||||
it("must not remove an empty annotation", async () => {
|
it("must not remove an empty annotation", async () => {
|
||||||
await Promise.all(
|
await Promise.all(
|
||||||
pages.map(async ([browserName, page]) => {
|
pages.map(async ([browserName, page]) => {
|
||||||
await page.hover("[data-annotation-id='23R']");
|
await page.waitForSelector("[data-annotation-id='23R']");
|
||||||
|
// Cannot use page.hover with Firefox on Mac because of a bug.
|
||||||
|
// TODO: remove this when we switch to BiDi.
|
||||||
|
await hover(page, "[data-annotation-id='23R']");
|
||||||
|
|
||||||
// Wait for the popup to be displayed.
|
// Wait for the popup to be displayed.
|
||||||
await page.waitForFunction(
|
await page.waitForFunction(
|
||||||
() =>
|
() =>
|
||||||
@ -1341,7 +1349,8 @@ describe("FreeText Editor", () => {
|
|||||||
`.annotationEditorLayer:not(.freetextEditing)`
|
`.annotationEditorLayer:not(.freetextEditing)`
|
||||||
);
|
);
|
||||||
|
|
||||||
await page.hover("[data-annotation-id='23R']");
|
// TODO: remove this when we switch to BiDi.
|
||||||
|
await hover(page, "[data-annotation-id='23R']");
|
||||||
// Wait for the popup to be displayed.
|
// Wait for the popup to be displayed.
|
||||||
await page.waitForFunction(
|
await page.waitForFunction(
|
||||||
() =>
|
() =>
|
||||||
@ -1592,11 +1601,7 @@ describe("FreeText Editor", () => {
|
|||||||
let pages;
|
let pages;
|
||||||
|
|
||||||
beforeAll(async () => {
|
beforeAll(async () => {
|
||||||
pages = await loadAndWait(
|
pages = await loadAndWait("issue16633.pdf", ".annotationEditorLayer");
|
||||||
"issue16633.pdf",
|
|
||||||
".annotationEditorLayer",
|
|
||||||
100
|
|
||||||
);
|
|
||||||
});
|
});
|
||||||
|
|
||||||
afterAll(async () => {
|
afterAll(async () => {
|
||||||
@ -1944,10 +1949,7 @@ describe("FreeText Editor", () => {
|
|||||||
);
|
);
|
||||||
|
|
||||||
await page.focus("#editorFreeTextColor");
|
await page.focus("#editorFreeTextColor");
|
||||||
|
await kbUndo(page);
|
||||||
await page.keyboard.down("Control");
|
|
||||||
await page.keyboard.press("z");
|
|
||||||
await page.keyboard.up("Control");
|
|
||||||
|
|
||||||
await page.waitForFunction(
|
await page.waitForFunction(
|
||||||
sel => !document.querySelector(sel),
|
sel => !document.querySelector(sel),
|
||||||
@ -1955,9 +1957,7 @@ describe("FreeText Editor", () => {
|
|||||||
getEditorSelector(0)
|
getEditorSelector(0)
|
||||||
);
|
);
|
||||||
|
|
||||||
await page.keyboard.down("Control");
|
await kbRedo(page);
|
||||||
await page.keyboard.press("y");
|
|
||||||
await page.keyboard.up("Control");
|
|
||||||
await page.waitForFunction(
|
await page.waitForFunction(
|
||||||
sel => !!document.querySelector(sel),
|
sel => !!document.querySelector(sel),
|
||||||
{},
|
{},
|
||||||
@ -2046,9 +2046,7 @@ describe("FreeText Editor", () => {
|
|||||||
.toEqual(Math.round(pageY - 20));
|
.toEqual(Math.round(pageY - 20));
|
||||||
|
|
||||||
for (let i = 0; i < 2; i++) {
|
for (let i = 0; i < 2; i++) {
|
||||||
await page.keyboard.down("Control");
|
await kbBigMoveLeft(page);
|
||||||
await page.keyboard.press("ArrowLeft");
|
|
||||||
await page.keyboard.up("Control");
|
|
||||||
await waitForPositionChange(page, selectorEditor, xy);
|
await waitForPositionChange(page, selectorEditor, xy);
|
||||||
xy = await getXY(page, selectorEditor);
|
xy = await getXY(page, selectorEditor);
|
||||||
}
|
}
|
||||||
@ -2062,9 +2060,7 @@ describe("FreeText Editor", () => {
|
|||||||
.toEqual(Math.round(pageY - 20));
|
.toEqual(Math.round(pageY - 20));
|
||||||
|
|
||||||
for (let i = 0; i < 2; i++) {
|
for (let i = 0; i < 2; i++) {
|
||||||
await page.keyboard.down("Control");
|
await kbBigMoveUp(page);
|
||||||
await page.keyboard.press("ArrowUp");
|
|
||||||
await page.keyboard.up("Control");
|
|
||||||
await waitForPositionChange(page, selectorEditor, xy);
|
await waitForPositionChange(page, selectorEditor, xy);
|
||||||
xy = await getXY(page, selectorEditor);
|
xy = await getXY(page, selectorEditor);
|
||||||
}
|
}
|
||||||
@ -2164,9 +2160,7 @@ describe("FreeText Editor", () => {
|
|||||||
}
|
}
|
||||||
|
|
||||||
for (let i = 0; i < 2; i++) {
|
for (let i = 0; i < 2; i++) {
|
||||||
await page.keyboard.down("Control");
|
await kbBigMoveDown(page);
|
||||||
await page.keyboard.press("ArrowDown");
|
|
||||||
await page.keyboard.up("Control");
|
|
||||||
await waitForPositionChange(page, selectorEditor, xy);
|
await waitForPositionChange(page, selectorEditor, xy);
|
||||||
xy = await getXY(page, selectorEditor);
|
xy = await getXY(page, selectorEditor);
|
||||||
}
|
}
|
||||||
@ -2178,25 +2172,19 @@ describe("FreeText Editor", () => {
|
|||||||
}
|
}
|
||||||
|
|
||||||
for (let i = 0; i < 2; i++) {
|
for (let i = 0; i < 2; i++) {
|
||||||
await page.keyboard.down("Control");
|
await kbBigMoveUp(page);
|
||||||
await page.keyboard.press("ArrowUp");
|
|
||||||
await page.keyboard.up("Control");
|
|
||||||
await waitForPositionChange(page, selectorEditor, xy);
|
await waitForPositionChange(page, selectorEditor, xy);
|
||||||
xy = await getXY(page, selectorEditor);
|
xy = await getXY(page, selectorEditor);
|
||||||
}
|
}
|
||||||
|
|
||||||
for (let i = 0; i < 2; i++) {
|
for (let i = 0; i < 2; i++) {
|
||||||
await page.keyboard.down("Control");
|
await kbBigMoveRight(page);
|
||||||
await page.keyboard.press("ArrowRight");
|
|
||||||
await page.keyboard.up("Control");
|
|
||||||
await waitForPositionChange(page, selectorEditor, xy);
|
await waitForPositionChange(page, selectorEditor, xy);
|
||||||
xy = await getXY(page, selectorEditor);
|
xy = await getXY(page, selectorEditor);
|
||||||
}
|
}
|
||||||
|
|
||||||
for (let i = 0; i < 2; i++) {
|
for (let i = 0; i < 2; i++) {
|
||||||
await page.keyboard.down("Control");
|
await kbBigMoveLeft(page);
|
||||||
await page.keyboard.press("ArrowLeft");
|
|
||||||
await page.keyboard.up("Control");
|
|
||||||
await waitForPositionChange(page, selectorEditor, xy);
|
await waitForPositionChange(page, selectorEditor, xy);
|
||||||
xy = await getXY(page, selectorEditor);
|
xy = await getXY(page, selectorEditor);
|
||||||
}
|
}
|
||||||
@ -2264,6 +2252,7 @@ describe("FreeText Editor", () => {
|
|||||||
});
|
});
|
||||||
await page.type(`${getEditorSelector(0)} .internal`, data);
|
await page.type(`${getEditorSelector(0)} .internal`, data);
|
||||||
// Commit.
|
// Commit.
|
||||||
|
await cancelFocusIn(page, getEditorSelector(0));
|
||||||
await page.keyboard.press("Escape");
|
await page.keyboard.press("Escape");
|
||||||
await page.waitForSelector(
|
await page.waitForSelector(
|
||||||
`${getEditorSelector(0)} .overlay.enabled`
|
`${getEditorSelector(0)} .overlay.enabled`
|
||||||
@ -2342,7 +2331,7 @@ describe("FreeText Editor", () => {
|
|||||||
`${getEditorSelector(1)} .overlay.enabled`
|
`${getEditorSelector(1)} .overlay.enabled`
|
||||||
);
|
);
|
||||||
|
|
||||||
await page.mouse.click(rect.x + 115, rect.y + 155);
|
await page.mouse.click(rect.x + 111, rect.y + 151);
|
||||||
await waitForSelectedEditor(page, getEditorSelector(1));
|
await waitForSelectedEditor(page, getEditorSelector(1));
|
||||||
|
|
||||||
const pos = n =>
|
const pos = n =>
|
||||||
@ -2361,12 +2350,21 @@ describe("FreeText Editor", () => {
|
|||||||
.withContext(`In ${browserName}`)
|
.withContext(`In ${browserName}`)
|
||||||
.toEqual(1);
|
.toEqual(1);
|
||||||
|
|
||||||
|
const getY = selector =>
|
||||||
|
page.evaluate(
|
||||||
|
sel => document.querySelector(sel).getBoundingClientRect().y,
|
||||||
|
selector
|
||||||
|
);
|
||||||
|
const height = await page.evaluate(
|
||||||
|
sel => document.querySelector(sel).getBoundingClientRect().height,
|
||||||
|
getEditorSelector(0)
|
||||||
|
);
|
||||||
|
|
||||||
|
const y0 = await getY(getEditorSelector(0));
|
||||||
const selectorEditor = getEditorSelector(1);
|
const selectorEditor = getEditorSelector(1);
|
||||||
let xy = await getXY(page, selectorEditor);
|
let xy = await getXY(page, selectorEditor);
|
||||||
for (let i = 0; i < 6; i++) {
|
while ((await getY(selectorEditor)) > y0 - height) {
|
||||||
await page.keyboard.down("Control");
|
await kbBigMoveUp(page);
|
||||||
await page.keyboard.press("ArrowUp");
|
|
||||||
await page.keyboard.up("Control");
|
|
||||||
await waitForPositionChange(page, selectorEditor, xy);
|
await waitForPositionChange(page, selectorEditor, xy);
|
||||||
xy = await getXY(page, selectorEditor);
|
xy = await getXY(page, selectorEditor);
|
||||||
}
|
}
|
||||||
@ -2448,12 +2446,12 @@ describe("FreeText Editor", () => {
|
|||||||
return { x, y };
|
return { x, y };
|
||||||
});
|
});
|
||||||
const oldPos = allPositions[i];
|
const oldPos = allPositions[i];
|
||||||
expect(Math.round(pos.x - oldPos.x))
|
expect(Math.abs(Math.round(pos.x - oldPos.x) - 39))
|
||||||
.withContext(`In ${browserName}`)
|
.withContext(`In ${browserName}`)
|
||||||
.toEqual(39);
|
.toBeLessThanOrEqual(1);
|
||||||
expect(Math.round(pos.y - oldPos.y))
|
expect(Math.abs(Math.round(pos.y - oldPos.y) - 74))
|
||||||
.withContext(`In ${browserName}`)
|
.withContext(`In ${browserName}`)
|
||||||
.toEqual(74);
|
.toBeLessThanOrEqual(1);
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
);
|
);
|
||||||
@ -2505,7 +2503,9 @@ describe("FreeText Editor", () => {
|
|||||||
visible: true,
|
visible: true,
|
||||||
});
|
});
|
||||||
await page.type(`${getEditorSelector(0)} .internal`, data);
|
await page.type(`${getEditorSelector(0)} .internal`, data);
|
||||||
|
|
||||||
// Commit.
|
// Commit.
|
||||||
|
await cancelFocusIn(page, getEditorSelector(0));
|
||||||
await page.keyboard.press("Escape");
|
await page.keyboard.press("Escape");
|
||||||
await page.waitForSelector(
|
await page.waitForSelector(
|
||||||
`${getEditorSelector(0)} .overlay.enabled`
|
`${getEditorSelector(0)} .overlay.enabled`
|
||||||
@ -2559,20 +2559,35 @@ describe("FreeText Editor", () => {
|
|||||||
const { x, y } = el.getBoundingClientRect();
|
const { x, y } = el.getBoundingClientRect();
|
||||||
return { x, y };
|
return { x, y };
|
||||||
});
|
});
|
||||||
|
const selectorEditor = getEditorSelector(0);
|
||||||
await page.mouse.click(rect.x + 10, rect.y + 10);
|
await page.mouse.click(rect.x + 10, rect.y + 10);
|
||||||
await page.waitForSelector(getEditorSelector(0), {
|
await page.waitForSelector(selectorEditor, {
|
||||||
visible: true,
|
visible: true,
|
||||||
});
|
});
|
||||||
await page.type(`${getEditorSelector(0)} .internal`, "Hello");
|
await page.type(`${selectorEditor} .internal`, "Hello");
|
||||||
|
|
||||||
// Commit.
|
// Commit.
|
||||||
|
await cancelFocusIn(page, selectorEditor);
|
||||||
await page.keyboard.press("Escape");
|
await page.keyboard.press("Escape");
|
||||||
await page.waitForSelector(
|
await page.waitForSelector(`${selectorEditor} .overlay.enabled`);
|
||||||
`${getEditorSelector(0)} .overlay.enabled`
|
|
||||||
|
// Unselect.
|
||||||
|
await page.keyboard.press("Escape");
|
||||||
|
await waitForUnselectedEditor(page, selectorEditor);
|
||||||
|
|
||||||
|
const editorRect = await page.$eval(selectorEditor, el => {
|
||||||
|
const { x, y, width, height } = el.getBoundingClientRect();
|
||||||
|
return { x, y, width, height };
|
||||||
|
});
|
||||||
|
|
||||||
|
// Select the editor created previously.
|
||||||
|
await page.mouse.click(
|
||||||
|
editorRect.x + editorRect.width / 2,
|
||||||
|
editorRect.y + editorRect.height / 2
|
||||||
);
|
);
|
||||||
|
|
||||||
// Go to the last page.
|
// Go to the last page.
|
||||||
await page.keyboard.press("End");
|
await scrollIntoView(page, `.page[data-page-number = "14"]`);
|
||||||
|
|
||||||
const page14Selector = `.page[data-page-number = "14"] > .annotationEditorLayer.freetextEditing`;
|
const page14Selector = `.page[data-page-number = "14"] > .annotationEditorLayer.freetextEditing`;
|
||||||
await page.waitForSelector(page14Selector, {
|
await page.waitForSelector(page14Selector, {
|
||||||
@ -2656,20 +2671,35 @@ describe("FreeText Editor", () => {
|
|||||||
const { x, y } = el.getBoundingClientRect();
|
const { x, y } = el.getBoundingClientRect();
|
||||||
return { x, y };
|
return { x, y };
|
||||||
});
|
});
|
||||||
|
const selectorEditor = getEditorSelector(0);
|
||||||
await page.mouse.click(rect.x + 10, rect.y + 10);
|
await page.mouse.click(rect.x + 10, rect.y + 10);
|
||||||
await page.waitForSelector(getEditorSelector(0), {
|
await page.waitForSelector(selectorEditor, {
|
||||||
visible: true,
|
visible: true,
|
||||||
});
|
});
|
||||||
await page.type(`${getEditorSelector(0)} .internal`, "Hello");
|
await page.type(`${selectorEditor} .internal`, "Hello");
|
||||||
|
|
||||||
// Commit.
|
// Commit.
|
||||||
|
await cancelFocusIn(page, selectorEditor);
|
||||||
await page.keyboard.press("Escape");
|
await page.keyboard.press("Escape");
|
||||||
await page.waitForSelector(
|
await page.waitForSelector(`${selectorEditor} .overlay.enabled`);
|
||||||
`${getEditorSelector(0)} .overlay.enabled`
|
|
||||||
|
// Unselect.
|
||||||
|
await page.keyboard.press("Escape");
|
||||||
|
await waitForUnselectedEditor(page, selectorEditor);
|
||||||
|
|
||||||
|
const editorRect = await page.$eval(selectorEditor, el => {
|
||||||
|
const { x, y, width, height } = el.getBoundingClientRect();
|
||||||
|
return { x, y, width, height };
|
||||||
|
});
|
||||||
|
|
||||||
|
// Select the editor created previously.
|
||||||
|
await page.mouse.click(
|
||||||
|
editorRect.x + editorRect.width / 2,
|
||||||
|
editorRect.y + editorRect.height / 2
|
||||||
);
|
);
|
||||||
|
|
||||||
// Go to the last page.
|
// Go to the last page.
|
||||||
await page.keyboard.press("End");
|
await scrollIntoView(page, `.page[data-page-number = "14"]`);
|
||||||
await page.waitForSelector(
|
await page.waitForSelector(
|
||||||
`.page[data-page-number = "14"] > .annotationEditorLayer.freetextEditing`,
|
`.page[data-page-number = "14"] > .annotationEditorLayer.freetextEditing`,
|
||||||
{
|
{
|
||||||
@ -2681,7 +2711,7 @@ describe("FreeText Editor", () => {
|
|||||||
await clearAll(page);
|
await clearAll(page);
|
||||||
|
|
||||||
// Go to the first page.
|
// Go to the first page.
|
||||||
await page.keyboard.press("Home");
|
await kbGoToBegin(page);
|
||||||
await page.waitForSelector(page1Selector, {
|
await page.waitForSelector(page1Selector, {
|
||||||
visible: true,
|
visible: true,
|
||||||
timeout: 0,
|
timeout: 0,
|
||||||
@ -2690,10 +2720,7 @@ describe("FreeText Editor", () => {
|
|||||||
// Make sure that nothing has be added.
|
// Make sure that nothing has be added.
|
||||||
await waitForStorageEntries(page, 0);
|
await waitForStorageEntries(page, 0);
|
||||||
|
|
||||||
// Undo.
|
await kbUndo(page);
|
||||||
await page.keyboard.down("Control");
|
|
||||||
await page.keyboard.press("z");
|
|
||||||
await page.keyboard.up("Control");
|
|
||||||
await waitForSerialized(page, 1);
|
await waitForSerialized(page, 1);
|
||||||
|
|
||||||
await page.waitForSelector(getEditorSelector(0), {
|
await page.waitForSelector(getEditorSelector(0), {
|
||||||
@ -2832,9 +2859,7 @@ describe("FreeText Editor", () => {
|
|||||||
|
|
||||||
let xy = await getXY(page, selectorEditor);
|
let xy = await getXY(page, selectorEditor);
|
||||||
for (let i = 0; i < 5; i++) {
|
for (let i = 0; i < 5; i++) {
|
||||||
await page.keyboard.down("Control");
|
await kbBigMoveUp(page);
|
||||||
await page.keyboard.press("ArrowUp");
|
|
||||||
await page.keyboard.up("Control");
|
|
||||||
await waitForPositionChange(page, selectorEditor, xy);
|
await waitForPositionChange(page, selectorEditor, xy);
|
||||||
xy = await getXY(page, selectorEditor);
|
xy = await getXY(page, selectorEditor);
|
||||||
}
|
}
|
||||||
@ -2867,9 +2892,7 @@ describe("FreeText Editor", () => {
|
|||||||
|
|
||||||
xy = await getXY(page, selectorEditor);
|
xy = await getXY(page, selectorEditor);
|
||||||
for (let i = 0; i < 5; i++) {
|
for (let i = 0; i < 5; i++) {
|
||||||
await page.keyboard.down("Control");
|
await kbBigMoveDown(page);
|
||||||
await page.keyboard.press("ArrowDown");
|
|
||||||
await page.keyboard.up("Control");
|
|
||||||
await waitForPositionChange(page, selectorEditor, xy);
|
await waitForPositionChange(page, selectorEditor, xy);
|
||||||
xy = await getXY(page, selectorEditor);
|
xy = await getXY(page, selectorEditor);
|
||||||
}
|
}
|
||||||
@ -2904,9 +2927,7 @@ describe("FreeText Editor", () => {
|
|||||||
|
|
||||||
let xy = await getXY(page, selectorEditor);
|
let xy = await getXY(page, selectorEditor);
|
||||||
for (let i = 0; i < 10; i++) {
|
for (let i = 0; i < 10; i++) {
|
||||||
await page.keyboard.down("Control");
|
await kbBigMoveLeft(page);
|
||||||
await page.keyboard.press("ArrowLeft");
|
|
||||||
await page.keyboard.up("Control");
|
|
||||||
await waitForPositionChange(page, selectorEditor, xy);
|
await waitForPositionChange(page, selectorEditor, xy);
|
||||||
xy = await getXY(page, selectorEditor);
|
xy = await getXY(page, selectorEditor);
|
||||||
}
|
}
|
||||||
@ -2936,9 +2957,7 @@ describe("FreeText Editor", () => {
|
|||||||
|
|
||||||
xy = await getXY(page, selectorEditor);
|
xy = await getXY(page, selectorEditor);
|
||||||
for (let i = 0; i < 10; i++) {
|
for (let i = 0; i < 10; i++) {
|
||||||
await page.keyboard.down("Control");
|
await kbBigMoveRight(page);
|
||||||
await page.keyboard.press("ArrowRight");
|
|
||||||
await page.keyboard.up("Control");
|
|
||||||
await waitForPositionChange(page, selectorEditor, xy);
|
await waitForPositionChange(page, selectorEditor, xy);
|
||||||
xy = await getXY(page, selectorEditor);
|
xy = await getXY(page, selectorEditor);
|
||||||
}
|
}
|
||||||
|
@ -16,6 +16,9 @@
|
|||||||
import {
|
import {
|
||||||
closePages,
|
closePages,
|
||||||
getSelectedEditors,
|
getSelectedEditors,
|
||||||
|
kbRedo,
|
||||||
|
kbSelectAll,
|
||||||
|
kbUndo,
|
||||||
loadAndWait,
|
loadAndWait,
|
||||||
waitForStorageEntries,
|
waitForStorageEntries,
|
||||||
} from "./test_utils.mjs";
|
} from "./test_utils.mjs";
|
||||||
@ -29,9 +32,7 @@ const waitForPointerUp = page =>
|
|||||||
);
|
);
|
||||||
|
|
||||||
const selectAll = async page => {
|
const selectAll = async page => {
|
||||||
await page.keyboard.down("Control");
|
await kbSelectAll(page);
|
||||||
await page.keyboard.press("a");
|
|
||||||
await page.keyboard.up("Control");
|
|
||||||
await page.waitForFunction(
|
await page.waitForFunction(
|
||||||
() => !document.querySelector(".inkEditor.disabled:not(.selectedEditor)")
|
() => !document.querySelector(".inkEditor.disabled:not(.selectedEditor)")
|
||||||
);
|
);
|
||||||
@ -39,9 +40,7 @@ const selectAll = async page => {
|
|||||||
|
|
||||||
const clearAll = async page => {
|
const clearAll = async page => {
|
||||||
await selectAll(page);
|
await selectAll(page);
|
||||||
await page.keyboard.down("Control");
|
|
||||||
await page.keyboard.press("Backspace");
|
await page.keyboard.press("Backspace");
|
||||||
await page.keyboard.up("Control");
|
|
||||||
await waitForStorageEntries(page, 0);
|
await waitForStorageEntries(page, 0);
|
||||||
};
|
};
|
||||||
|
|
||||||
@ -89,9 +88,7 @@ describe("Ink Editor", () => {
|
|||||||
|
|
||||||
await clearAll(page);
|
await clearAll(page);
|
||||||
|
|
||||||
await page.keyboard.down("Control");
|
await kbUndo(page);
|
||||||
await page.keyboard.press("z");
|
|
||||||
await page.keyboard.up("Control");
|
|
||||||
await waitForStorageEntries(page, 3);
|
await waitForStorageEntries(page, 3);
|
||||||
|
|
||||||
expect(await getSelectedEditors(page))
|
expect(await getSelectedEditors(page))
|
||||||
@ -130,16 +127,9 @@ describe("Ink Editor", () => {
|
|||||||
});
|
});
|
||||||
|
|
||||||
for (let i = 0; i < 30; i++) {
|
for (let i = 0; i < 30; i++) {
|
||||||
await page.keyboard.down("Control");
|
await kbUndo(page);
|
||||||
await page.keyboard.press("z");
|
|
||||||
await page.keyboard.up("Control");
|
|
||||||
|
|
||||||
await waitForStorageEntries(page, 0);
|
await waitForStorageEntries(page, 0);
|
||||||
|
await kbRedo(page);
|
||||||
await page.keyboard.down("Control");
|
|
||||||
await page.keyboard.press("y");
|
|
||||||
await page.keyboard.up("Control");
|
|
||||||
|
|
||||||
await waitForStorageEntries(page, 1);
|
await waitForStorageEntries(page, 1);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -20,6 +20,8 @@ import {
|
|||||||
getFirstSerialized,
|
getFirstSerialized,
|
||||||
getQuerySelector,
|
getQuerySelector,
|
||||||
getSelector,
|
getSelector,
|
||||||
|
kbDeleteLastWord,
|
||||||
|
kbSelectAll,
|
||||||
loadAndWait,
|
loadAndWait,
|
||||||
scrollIntoView,
|
scrollIntoView,
|
||||||
} from "./test_utils.mjs";
|
} from "./test_utils.mjs";
|
||||||
@ -1228,9 +1230,7 @@ describe("Interaction", () => {
|
|||||||
|
|
||||||
await page.type(getSelector("27R"), " ", { delay: 200 });
|
await page.type(getSelector("27R"), " ", { delay: 200 });
|
||||||
|
|
||||||
await page.keyboard.down("Control");
|
await kbDeleteLastWord(page);
|
||||||
await page.keyboard.press("Backspace");
|
|
||||||
await page.keyboard.up("Control");
|
|
||||||
|
|
||||||
await page.waitForFunction(
|
await page.waitForFunction(
|
||||||
`${getQuerySelector("27R")}.value !== "HELLO WORDL "`
|
`${getQuerySelector("27R")}.value !== "HELLO WORDL "`
|
||||||
@ -1654,9 +1654,7 @@ describe("Interaction", () => {
|
|||||||
value = await page.$eval(getSelector("28R"), el => el.value);
|
value = await page.$eval(getSelector("28R"), el => el.value);
|
||||||
expect(value).withContext(`In ${browserName}`).toEqual("abcdef");
|
expect(value).withContext(`In ${browserName}`).toEqual("abcdef");
|
||||||
|
|
||||||
await page.keyboard.down("Control");
|
await kbSelectAll(page);
|
||||||
await page.keyboard.press("A");
|
|
||||||
await page.keyboard.up("Control");
|
|
||||||
await page.keyboard.press("Backspace");
|
await page.keyboard.press("Backspace");
|
||||||
|
|
||||||
await page.keyboard.press("Enter");
|
await page.keyboard.press("Enter");
|
||||||
@ -1962,9 +1960,7 @@ describe("Interaction", () => {
|
|||||||
await page.waitForTimeout(10);
|
await page.waitForTimeout(10);
|
||||||
await page.click(getSelector("26R"));
|
await page.click(getSelector("26R"));
|
||||||
|
|
||||||
await page.keyboard.down("Control");
|
await kbSelectAll(page);
|
||||||
await page.keyboard.press("A");
|
|
||||||
await page.keyboard.up("Control");
|
|
||||||
await page.keyboard.press("Backspace");
|
await page.keyboard.press("Backspace");
|
||||||
|
|
||||||
await page.click(getSelector("23R"));
|
await page.click(getSelector("23R"));
|
||||||
|
@ -18,6 +18,10 @@ import {
|
|||||||
getEditorDimensions,
|
getEditorDimensions,
|
||||||
getEditorSelector,
|
getEditorSelector,
|
||||||
getFirstSerialized,
|
getFirstSerialized,
|
||||||
|
kbBigMoveDown,
|
||||||
|
kbBigMoveRight,
|
||||||
|
kbPaste,
|
||||||
|
kbSelectAll,
|
||||||
loadAndWait,
|
loadAndWait,
|
||||||
serializeBitmapDimensions,
|
serializeBitmapDimensions,
|
||||||
waitForAnnotationEditorLayer,
|
waitForAnnotationEditorLayer,
|
||||||
@ -31,9 +35,7 @@ import path from "path";
|
|||||||
const __dirname = path.dirname(fileURLToPath(import.meta.url));
|
const __dirname = path.dirname(fileURLToPath(import.meta.url));
|
||||||
|
|
||||||
const selectAll = async page => {
|
const selectAll = async page => {
|
||||||
await page.keyboard.down("Control");
|
await kbSelectAll(page);
|
||||||
await page.keyboard.press("a");
|
|
||||||
await page.keyboard.up("Control");
|
|
||||||
await page.waitForFunction(
|
await page.waitForFunction(
|
||||||
() => !document.querySelector(".stampEditor:not(.selectedEditor)")
|
() => !document.querySelector(".stampEditor:not(.selectedEditor)")
|
||||||
);
|
);
|
||||||
@ -41,9 +43,7 @@ const selectAll = async page => {
|
|||||||
|
|
||||||
const clearAll = async page => {
|
const clearAll = async page => {
|
||||||
await selectAll(page);
|
await selectAll(page);
|
||||||
await page.keyboard.down("Control");
|
|
||||||
await page.keyboard.press("Backspace");
|
await page.keyboard.press("Backspace");
|
||||||
await page.keyboard.up("Control");
|
|
||||||
await waitForStorageEntries(page, 0);
|
await waitForStorageEntries(page, 0);
|
||||||
};
|
};
|
||||||
|
|
||||||
@ -101,9 +101,7 @@ const copyImage = async (page, imagePath, number) => {
|
|||||||
})
|
})
|
||||||
),
|
),
|
||||||
]);
|
]);
|
||||||
await page.keyboard.down("Control");
|
await kbPaste(page);
|
||||||
await page.keyboard.press("v");
|
|
||||||
await page.keyboard.up("Control");
|
|
||||||
hasPasteEvent = await promise;
|
hasPasteEvent = await promise;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -521,9 +519,7 @@ describe("Stamp Editor", () => {
|
|||||||
.toEqual(true);
|
.toEqual(true);
|
||||||
|
|
||||||
for (let i = 0; i < 4; i++) {
|
for (let i = 0; i < 4; i++) {
|
||||||
await page.keyboard.down("Control");
|
await kbBigMoveRight(page);
|
||||||
await page.keyboard.press("ArrowRight");
|
|
||||||
await page.keyboard.up("Control");
|
|
||||||
await waitForDimsChange(prevWidth, prevHeight);
|
await waitForDimsChange(prevWidth, prevHeight);
|
||||||
[prevWidth, prevHeight] = await getDims();
|
[prevWidth, prevHeight] = await getDims();
|
||||||
}
|
}
|
||||||
@ -554,9 +550,7 @@ describe("Stamp Editor", () => {
|
|||||||
.toEqual(true);
|
.toEqual(true);
|
||||||
|
|
||||||
for (let i = 0; i < 4; i++) {
|
for (let i = 0; i < 4; i++) {
|
||||||
await page.keyboard.down("Control");
|
await kbBigMoveDown(page);
|
||||||
await page.keyboard.press("ArrowDown");
|
|
||||||
await page.keyboard.up("Control");
|
|
||||||
await waitForDimsChange(prevWidth, prevHeight);
|
await waitForDimsChange(prevWidth, prevHeight);
|
||||||
[prevWidth, prevHeight] = await getDims();
|
[prevWidth, prevHeight] = await getDims();
|
||||||
}
|
}
|
||||||
|
@ -13,6 +13,9 @@
|
|||||||
* limitations under the License.
|
* limitations under the License.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
|
import os from "os";
|
||||||
|
const isMac = os.platform() === "darwin";
|
||||||
|
|
||||||
function loadAndWait(filename, selector, zoom, pageSetup) {
|
function loadAndWait(filename, selector, zoom, pageSetup) {
|
||||||
return Promise.all(
|
return Promise.all(
|
||||||
global.integrationSessions.map(async session => {
|
global.integrationSessions.map(async session => {
|
||||||
@ -33,10 +36,10 @@ function loadAndWait(filename, selector, zoom, pageSetup) {
|
|||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
let url = `${global.integrationBaseUrl}?file=/test/pdfs/${filename}`;
|
const url = `${
|
||||||
if (zoom) {
|
global.integrationBaseUrl
|
||||||
url += `#zoom=${zoom}`;
|
}?file=/test/pdfs/${filename}#zoom=${zoom ?? "page-fit"}`;
|
||||||
}
|
|
||||||
await page.goto(url);
|
await page.goto(url);
|
||||||
if (pageSetup) {
|
if (pageSetup) {
|
||||||
await pageSetup(page);
|
await pageSetup(page);
|
||||||
@ -63,9 +66,7 @@ function closePages(pages) {
|
|||||||
|
|
||||||
async function clearInput(page, selector) {
|
async function clearInput(page, selector) {
|
||||||
await page.click(selector);
|
await page.click(selector);
|
||||||
await page.keyboard.down("Control");
|
await kbSelectAll(page);
|
||||||
await page.keyboard.press("A");
|
|
||||||
await page.keyboard.up("Control");
|
|
||||||
await page.keyboard.press("Backspace");
|
await page.keyboard.press("Backspace");
|
||||||
await page.waitForTimeout(10);
|
await page.waitForTimeout(10);
|
||||||
}
|
}
|
||||||
@ -251,40 +252,159 @@ async function waitForTextLayer(page) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
async function scrollIntoView(page, selector) {
|
async function scrollIntoView(page, selector) {
|
||||||
const promise = page.evaluate(
|
|
||||||
sel =>
|
|
||||||
new Promise(resolve => {
|
|
||||||
const el = document.querySelector(sel);
|
|
||||||
const observer = new IntersectionObserver(
|
|
||||||
() => {
|
|
||||||
observer.disconnect();
|
|
||||||
resolve();
|
|
||||||
},
|
|
||||||
{
|
|
||||||
root: document.querySelector("#viewerContainer"),
|
|
||||||
threshold: 0.1,
|
|
||||||
}
|
|
||||||
);
|
|
||||||
observer.observe(el);
|
|
||||||
}),
|
|
||||||
selector
|
|
||||||
);
|
|
||||||
await page.evaluate(sel => {
|
await page.evaluate(sel => {
|
||||||
const element = document.querySelector(sel);
|
const element = document.querySelector(sel);
|
||||||
element.scrollIntoView({ behavior: "instant", block: "start" });
|
element.scrollIntoView({ behavior: "instant", block: "start" });
|
||||||
}, selector);
|
}, selector);
|
||||||
await promise;
|
|
||||||
await page.waitForFunction(
|
await page.waitForFunction(
|
||||||
sel => {
|
sel => {
|
||||||
|
const toolbarHeight = document
|
||||||
|
.querySelector("#toolbarContainer")
|
||||||
|
.getBoundingClientRect().height;
|
||||||
const element = document.querySelector(sel);
|
const element = document.querySelector(sel);
|
||||||
const { top, bottom } = element.getBoundingClientRect();
|
const { top, bottom } = element.getBoundingClientRect();
|
||||||
return Math.abs(top) < 100 || Math.abs(bottom - window.innerHeight) < 100;
|
return (
|
||||||
|
Math.abs(top) < toolbarHeight + 100 ||
|
||||||
|
Math.abs(bottom - window.innerHeight) < 100 ||
|
||||||
|
(top > toolbarHeight && bottom < window.innerHeight)
|
||||||
|
);
|
||||||
},
|
},
|
||||||
{},
|
{},
|
||||||
selector
|
selector
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
async function hover(page, selector) {
|
||||||
|
const rect = await page.$eval(selector, el => {
|
||||||
|
const { x, y, width, height } = el.getBoundingClientRect();
|
||||||
|
return { x, y, width, height };
|
||||||
|
});
|
||||||
|
await page.mouse.move(rect.x + rect.width / 2, rect.y + rect.height / 2);
|
||||||
|
}
|
||||||
|
|
||||||
|
const modifier = isMac ? "Meta" : "Control";
|
||||||
|
async function kbCopy(page) {
|
||||||
|
await page.keyboard.down(modifier);
|
||||||
|
await page.keyboard.press("c", { commands: ["Copy"] });
|
||||||
|
await page.keyboard.up(modifier);
|
||||||
|
}
|
||||||
|
async function kbPaste(page) {
|
||||||
|
await page.keyboard.down(modifier);
|
||||||
|
await page.keyboard.press("v", { commands: ["Paste"] });
|
||||||
|
await page.keyboard.up(modifier);
|
||||||
|
}
|
||||||
|
async function kbUndo(page) {
|
||||||
|
await page.keyboard.down(modifier);
|
||||||
|
await page.keyboard.press("z");
|
||||||
|
await page.keyboard.up(modifier);
|
||||||
|
}
|
||||||
|
async function kbRedo(page) {
|
||||||
|
if (isMac) {
|
||||||
|
await page.keyboard.down("Meta");
|
||||||
|
await page.keyboard.down("Shift");
|
||||||
|
await page.keyboard.press("z");
|
||||||
|
await page.keyboard.up("Shift");
|
||||||
|
await page.keyboard.up("Meta");
|
||||||
|
} else {
|
||||||
|
await page.keyboard.down("Control");
|
||||||
|
await page.keyboard.press("y");
|
||||||
|
await page.keyboard.up("Control");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
async function kbSelectAll(page) {
|
||||||
|
await page.keyboard.down(modifier);
|
||||||
|
await page.keyboard.press("a", { commands: ["SelectAll"] });
|
||||||
|
await page.keyboard.up(modifier);
|
||||||
|
}
|
||||||
|
async function kbModifierDown(page) {
|
||||||
|
await page.keyboard.down(modifier);
|
||||||
|
}
|
||||||
|
async function kbModifierUp(page) {
|
||||||
|
await page.keyboard.up(modifier);
|
||||||
|
}
|
||||||
|
async function kbGoToEnd(page) {
|
||||||
|
if (isMac) {
|
||||||
|
await page.keyboard.down("Meta");
|
||||||
|
await page.keyboard.press("ArrowDown", {
|
||||||
|
commands: ["MoveToEndOfDocument"],
|
||||||
|
});
|
||||||
|
await page.keyboard.up("Meta");
|
||||||
|
} else {
|
||||||
|
await page.keyboard.down("Control");
|
||||||
|
await page.keyboard.press("End");
|
||||||
|
await page.keyboard.up("Control");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
async function kbGoToBegin(page) {
|
||||||
|
if (isMac) {
|
||||||
|
await page.keyboard.down("Meta");
|
||||||
|
await page.keyboard.press("ArrowUp", {
|
||||||
|
commands: ["MoveToBeginningOfDocument"],
|
||||||
|
});
|
||||||
|
await page.keyboard.up("Meta");
|
||||||
|
} else {
|
||||||
|
await page.keyboard.down("Control");
|
||||||
|
await page.keyboard.press("Home");
|
||||||
|
await page.keyboard.up("Control");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
async function kbBigMoveLeft(page) {
|
||||||
|
if (isMac) {
|
||||||
|
await page.keyboard.down("Shift");
|
||||||
|
await page.keyboard.press("ArrowLeft");
|
||||||
|
await page.keyboard.up("Shift");
|
||||||
|
} else {
|
||||||
|
await page.keyboard.down("Control");
|
||||||
|
await page.keyboard.press("ArrowLeft");
|
||||||
|
await page.keyboard.up("Control");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
async function kbBigMoveRight(page) {
|
||||||
|
if (isMac) {
|
||||||
|
await page.keyboard.down("Shift");
|
||||||
|
await page.keyboard.press("ArrowRight");
|
||||||
|
await page.keyboard.up("Shift");
|
||||||
|
} else {
|
||||||
|
await page.keyboard.down("Control");
|
||||||
|
await page.keyboard.press("ArrowRight");
|
||||||
|
await page.keyboard.up("Control");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
async function kbBigMoveUp(page) {
|
||||||
|
if (isMac) {
|
||||||
|
await page.keyboard.down("Shift");
|
||||||
|
await page.keyboard.press("ArrowUp");
|
||||||
|
await page.keyboard.up("Shift");
|
||||||
|
} else {
|
||||||
|
await page.keyboard.down("Control");
|
||||||
|
await page.keyboard.press("ArrowUp");
|
||||||
|
await page.keyboard.up("Control");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
async function kbBigMoveDown(page) {
|
||||||
|
if (isMac) {
|
||||||
|
await page.keyboard.down("Shift");
|
||||||
|
await page.keyboard.press("ArrowDown");
|
||||||
|
await page.keyboard.up("Shift");
|
||||||
|
} else {
|
||||||
|
await page.keyboard.down("Control");
|
||||||
|
await page.keyboard.press("ArrowDown");
|
||||||
|
await page.keyboard.up("Control");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
async function kbDeleteLastWord(page) {
|
||||||
|
if (isMac) {
|
||||||
|
await page.keyboard.down("Alt");
|
||||||
|
await page.keyboard.press("Backspace");
|
||||||
|
await page.keyboard.up("Alt");
|
||||||
|
} else {
|
||||||
|
await page.keyboard.down("Control");
|
||||||
|
await page.keyboard.press("Backspace");
|
||||||
|
await page.keyboard.up("Control");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
export {
|
export {
|
||||||
clearInput,
|
clearInput,
|
||||||
closePages,
|
closePages,
|
||||||
@ -298,6 +418,21 @@ export {
|
|||||||
getSelectedEditors,
|
getSelectedEditors,
|
||||||
getSelector,
|
getSelector,
|
||||||
getSerialized,
|
getSerialized,
|
||||||
|
hover,
|
||||||
|
kbBigMoveDown,
|
||||||
|
kbBigMoveLeft,
|
||||||
|
kbBigMoveRight,
|
||||||
|
kbBigMoveUp,
|
||||||
|
kbCopy,
|
||||||
|
kbDeleteLastWord,
|
||||||
|
kbGoToBegin,
|
||||||
|
kbGoToEnd,
|
||||||
|
kbModifierDown,
|
||||||
|
kbModifierUp,
|
||||||
|
kbPaste,
|
||||||
|
kbRedo,
|
||||||
|
kbSelectAll,
|
||||||
|
kbUndo,
|
||||||
loadAndWait,
|
loadAndWait,
|
||||||
mockClipboard,
|
mockClipboard,
|
||||||
scrollIntoView,
|
scrollIntoView,
|
||||||
|
Loading…
Reference in New Issue
Block a user