Remove the timeouts from the stampEditor integration tests
This commit is contained in:
parent
46940a5a52
commit
b8c118db22
@ -16,13 +16,33 @@
|
|||||||
const {
|
const {
|
||||||
closePages,
|
closePages,
|
||||||
getEditorDimensions,
|
getEditorDimensions,
|
||||||
|
getEditorSelector,
|
||||||
loadAndWait,
|
loadAndWait,
|
||||||
serializeBitmapDimensions,
|
serializeBitmapDimensions,
|
||||||
waitForAnnotationEditorLayer,
|
waitForAnnotationEditorLayer,
|
||||||
|
waitForStorageEntries,
|
||||||
|
waitForSelectedEditor,
|
||||||
} = require("./test_utils.js");
|
} = require("./test_utils.js");
|
||||||
const path = require("path");
|
const path = require("path");
|
||||||
const fs = require("fs");
|
const fs = require("fs");
|
||||||
|
|
||||||
|
const selectAll = async page => {
|
||||||
|
await page.keyboard.down("Control");
|
||||||
|
await page.keyboard.press("a");
|
||||||
|
await page.keyboard.up("Control");
|
||||||
|
await page.waitForFunction(
|
||||||
|
() => !document.querySelector(".stampEditor:not(.selectedEditor)")
|
||||||
|
);
|
||||||
|
};
|
||||||
|
|
||||||
|
const clearAll = async page => {
|
||||||
|
await selectAll(page);
|
||||||
|
await page.keyboard.down("Control");
|
||||||
|
await page.keyboard.press("Backspace");
|
||||||
|
await page.keyboard.up("Control");
|
||||||
|
await waitForStorageEntries(page, 0);
|
||||||
|
};
|
||||||
|
|
||||||
describe("Stamp Editor", () => {
|
describe("Stamp Editor", () => {
|
||||||
describe("Basic operations", () => {
|
describe("Basic operations", () => {
|
||||||
let pages;
|
let pages;
|
||||||
@ -50,8 +70,7 @@ describe("Stamp Editor", () => {
|
|||||||
await input.uploadFile(
|
await input.uploadFile(
|
||||||
`${path.join(__dirname, "../images/firefox_logo.png")}`
|
`${path.join(__dirname, "../images/firefox_logo.png")}`
|
||||||
);
|
);
|
||||||
|
await page.waitForSelector(`${getEditorSelector(0)} .altText`);
|
||||||
await page.waitForTimeout(300);
|
|
||||||
|
|
||||||
const { width } = await getEditorDimensions(page, 0);
|
const { width } = await getEditorDimensions(page, 0);
|
||||||
|
|
||||||
@ -63,12 +82,7 @@ describe("Stamp Editor", () => {
|
|||||||
expect(bitmap.width).toEqual(512);
|
expect(bitmap.width).toEqual(512);
|
||||||
expect(bitmap.height).toEqual(543);
|
expect(bitmap.height).toEqual(543);
|
||||||
|
|
||||||
await page.keyboard.down("Control");
|
await clearAll(page);
|
||||||
await page.keyboard.press("a");
|
|
||||||
await page.keyboard.up("Control");
|
|
||||||
await page.waitForTimeout(10);
|
|
||||||
|
|
||||||
await page.keyboard.press("Backspace");
|
|
||||||
})
|
})
|
||||||
);
|
);
|
||||||
});
|
});
|
||||||
@ -86,8 +100,7 @@ describe("Stamp Editor", () => {
|
|||||||
await input.uploadFile(
|
await input.uploadFile(
|
||||||
`${path.join(__dirname, "../images/firefox_logo.svg")}`
|
`${path.join(__dirname, "../images/firefox_logo.svg")}`
|
||||||
);
|
);
|
||||||
|
await page.waitForSelector(`${getEditorSelector(1)} .altText`);
|
||||||
await page.waitForTimeout(300);
|
|
||||||
|
|
||||||
const { width } = await getEditorDimensions(page, 1);
|
const { width } = await getEditorDimensions(page, 1);
|
||||||
|
|
||||||
@ -102,12 +115,7 @@ describe("Stamp Editor", () => {
|
|||||||
expect(bitmap.width).toEqual(Math.round(242 * ratio));
|
expect(bitmap.width).toEqual(Math.round(242 * ratio));
|
||||||
expect(bitmap.height).toEqual(Math.round(80 * ratio));
|
expect(bitmap.height).toEqual(Math.round(80 * ratio));
|
||||||
|
|
||||||
await page.keyboard.down("Control");
|
await clearAll(page);
|
||||||
await page.keyboard.press("a");
|
|
||||||
await page.keyboard.up("Control");
|
|
||||||
await page.waitForTimeout(10);
|
|
||||||
|
|
||||||
await page.keyboard.press("Backspace");
|
|
||||||
})
|
})
|
||||||
);
|
);
|
||||||
});
|
});
|
||||||
@ -137,27 +145,20 @@ describe("Stamp Editor", () => {
|
|||||||
|
|
||||||
for (let i = 0; i < 4; i++) {
|
for (let i = 0; i < 4; i++) {
|
||||||
if (i !== 0) {
|
if (i !== 0) {
|
||||||
await page.keyboard.down("Control");
|
await clearAll(page);
|
||||||
await page.keyboard.press("a");
|
|
||||||
await page.keyboard.up("Control");
|
|
||||||
await page.waitForTimeout(10);
|
|
||||||
await page.keyboard.press("Backspace");
|
|
||||||
await page.waitForTimeout(10);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
await page.click("#editorStampAddImage");
|
await page.click("#editorStampAddImage");
|
||||||
await page.waitForTimeout(10);
|
|
||||||
const input = await page.$("#stampEditorFileInput");
|
const input = await page.$("#stampEditorFileInput");
|
||||||
await input.uploadFile(
|
await input.uploadFile(
|
||||||
`${path.join(__dirname, "../images/firefox_logo.png")}`
|
`${path.join(__dirname, "../images/firefox_logo.png")}`
|
||||||
);
|
);
|
||||||
|
await page.waitForSelector(`${getEditorSelector(i)} .altText`);
|
||||||
await page.waitForTimeout(300);
|
|
||||||
|
|
||||||
for (let j = 0; j < 4; j++) {
|
for (let j = 0; j < 4; j++) {
|
||||||
await page.keyboard.press("Escape");
|
await page.keyboard.press("Escape");
|
||||||
await page.waitForFunction(
|
await page.waitForSelector(
|
||||||
`getComputedStyle(document.querySelector(".resizers")).display === "none"`
|
`${getEditorSelector(i)} .resizers.hidden`
|
||||||
);
|
);
|
||||||
|
|
||||||
const promise = waitForAnnotationEditorLayer(page);
|
const promise = waitForAnnotationEditorLayer(page);
|
||||||
@ -165,12 +166,13 @@ describe("Stamp Editor", () => {
|
|||||||
window.PDFViewerApplication.rotatePages(90);
|
window.PDFViewerApplication.rotatePages(90);
|
||||||
});
|
});
|
||||||
await promise;
|
await promise;
|
||||||
await page.focus(".stampEditor");
|
|
||||||
|
|
||||||
await page.waitForFunction(
|
await page.focus(".stampEditor");
|
||||||
`getComputedStyle(document.querySelector(".resizers")).display === "block"`
|
await waitForSelectedEditor(page, getEditorSelector(i));
|
||||||
|
|
||||||
|
await page.waitForSelector(
|
||||||
|
`${getEditorSelector(i)} .resizers:not(.hidden)`
|
||||||
);
|
);
|
||||||
await page.waitForTimeout(10);
|
|
||||||
|
|
||||||
const [name, cursor] = await page.evaluate(() => {
|
const [name, cursor] = await page.evaluate(() => {
|
||||||
const { x, y } = document
|
const { x, y } = document
|
||||||
|
Loading…
Reference in New Issue
Block a user