Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Remove the timeouts from the stampEditor integration tests #17049

Merged
merged 1 commit into from
Sep 29, 2023
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
62 changes: 32 additions & 30 deletions test/integration/stamp_editor_spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -16,13 +16,33 @@
const {
closePages,
getEditorDimensions,
getEditorSelector,
loadAndWait,
serializeBitmapDimensions,
waitForAnnotationEditorLayer,
waitForStorageEntries,
waitForSelectedEditor,
} = require("./test_utils.js");
const path = require("path");
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("Basic operations", () => {
let pages;
Expand Down Expand Up @@ -50,8 +70,7 @@ describe("Stamp Editor", () => {
await input.uploadFile(
`${path.join(__dirname, "../images/firefox_logo.png")}`
);

await page.waitForTimeout(300);
await page.waitForSelector(`${getEditorSelector(0)} .altText`);

const { width } = await getEditorDimensions(page, 0);

Expand All @@ -63,12 +82,7 @@ describe("Stamp Editor", () => {
expect(bitmap.width).toEqual(512);
expect(bitmap.height).toEqual(543);

await page.keyboard.down("Control");
await page.keyboard.press("a");
await page.keyboard.up("Control");
await page.waitForTimeout(10);

await page.keyboard.press("Backspace");
await clearAll(page);
})
);
});
Expand All @@ -86,8 +100,7 @@ describe("Stamp Editor", () => {
await input.uploadFile(
`${path.join(__dirname, "../images/firefox_logo.svg")}`
);

await page.waitForTimeout(300);
await page.waitForSelector(`${getEditorSelector(1)} .altText`);

const { width } = await getEditorDimensions(page, 1);

Expand All @@ -102,12 +115,7 @@ describe("Stamp Editor", () => {
expect(bitmap.width).toEqual(Math.round(242 * ratio));
expect(bitmap.height).toEqual(Math.round(80 * ratio));

await page.keyboard.down("Control");
await page.keyboard.press("a");
await page.keyboard.up("Control");
await page.waitForTimeout(10);

await page.keyboard.press("Backspace");
await clearAll(page);
})
);
});
Expand Down Expand Up @@ -137,40 +145,34 @@ describe("Stamp Editor", () => {

for (let i = 0; i < 4; i++) {
if (i !== 0) {
await page.keyboard.down("Control");
await page.keyboard.press("a");
await page.keyboard.up("Control");
await page.waitForTimeout(10);
await page.keyboard.press("Backspace");
await page.waitForTimeout(10);
await clearAll(page);
}

await page.click("#editorStampAddImage");
await page.waitForTimeout(10);
const input = await page.$("#stampEditorFileInput");
await input.uploadFile(
`${path.join(__dirname, "../images/firefox_logo.png")}`
);

await page.waitForTimeout(300);
await page.waitForSelector(`${getEditorSelector(i)} .altText`);

for (let j = 0; j < 4; j++) {
await page.keyboard.press("Escape");
await page.waitForFunction(
`getComputedStyle(document.querySelector(".resizers")).display === "none"`
await page.waitForSelector(
`${getEditorSelector(i)} .resizers.hidden`
);

const promise = waitForAnnotationEditorLayer(page);
await page.evaluate(() => {
window.PDFViewerApplication.rotatePages(90);
});
await promise;

await page.focus(".stampEditor");
await waitForSelectedEditor(page, getEditorSelector(i));

await page.waitForFunction(
`getComputedStyle(document.querySelector(".resizers")).display === "block"`
await page.waitForSelector(
`${getEditorSelector(i)} .resizers:not(.hidden)`
);
await page.waitForTimeout(10);

const [name, cursor] = await page.evaluate(() => {
const { x, y } = document
Expand Down