1
0
Fork 0
mirror of https://github.com/mozilla/pdf.js.git synced 2025-04-19 14:48:08 +02:00

Remove all waitForTimeout usage from the annotation integration tests

This commit replaces all `waitForTimeout` occurrences with the
appropriate `waitForFunction` calls. Note that in some places they were
already present, so in those cases we could simply remove the
`waitForTimeout` call altogether.
This commit is contained in:
Tim van der Meij 2024-04-18 18:50:29 +02:00
parent bda98b91cb
commit 10641d5af0
No known key found for this signature in database
GPG key ID: 8C3FD2925A5F2762

View file

@ -18,7 +18,6 @@ import {
getQuerySelector,
getSelector,
loadAndWait,
waitForTimeout,
} from "./test_utils.mjs";
describe("Annotation highlight", () => {
@ -170,10 +169,6 @@ describe("Checkbox annotation", () => {
);
for (const selector of selectors) {
await page.click(selector);
// eslint-disable-next-line no-restricted-syntax
await waitForTimeout(10);
}
for (const selector of selectors) {
await page.waitForFunction(
`document.querySelector("${selector} > :first-child").checked`
);
@ -230,8 +225,9 @@ describe("Text widget", () => {
pages.map(async ([browserName, page]) => {
await page.type(getSelector("22R"), "a");
await page.keyboard.press("Tab");
// eslint-disable-next-line no-restricted-syntax
await waitForTimeout(10);
await page.waitForFunction(
`${getQuerySelector("22R")}.value !== "Hello world"`
);
const text = await page.$eval(getSelector("22R"), el => el.value);
expect(text).withContext(`In ${browserName}`).toEqual("aHello World");
@ -517,14 +513,10 @@ describe("ResetForm action", () => {
`document.querySelector("[data-annotation-id='25R']").hidden === false`
);
await page.click("#editorFreeText");
// eslint-disable-next-line no-restricted-syntax
await waitForTimeout(10);
await page.waitForFunction(
`document.querySelector("[data-annotation-id='25R']").hidden === true`
);
await page.click("#editorFreeText");
// eslint-disable-next-line no-restricted-syntax
await waitForTimeout(10);
await page.waitForFunction(
`document.querySelector("[data-annotation-id='25R']").hidden === false`
);
@ -587,8 +579,9 @@ describe("ResetForm action", () => {
expect(hidden).withContext(`In ${browserName}`).toEqual(true);
await page.focus("[data-annotation-id='20R']");
await page.keyboard.press("Enter");
// eslint-disable-next-line no-restricted-syntax
await waitForTimeout(10);
await page.waitForFunction(
`document.querySelector("[data-annotation-id='21R']").hidden !== true`
);
hidden = await page.$eval(
"[data-annotation-id='21R']",
el => el.hidden
@ -596,8 +589,9 @@ describe("ResetForm action", () => {
expect(hidden).withContext(`In ${browserName}`).toEqual(false);
await page.keyboard.press("Enter");
// eslint-disable-next-line no-restricted-syntax
await waitForTimeout(10);
await page.waitForFunction(
`document.querySelector("[data-annotation-id='21R']").hidden !== false`
);
hidden = await page.$eval(
"[data-annotation-id='21R']",
el => el.hidden
@ -605,8 +599,9 @@ describe("ResetForm action", () => {
expect(hidden).withContext(`In ${browserName}`).toEqual(true);
await page.keyboard.press("Enter");
// eslint-disable-next-line no-restricted-syntax
await waitForTimeout(10);
await page.waitForFunction(
`document.querySelector("[data-annotation-id='21R']").hidden !== true`
);
hidden = await page.$eval(
"[data-annotation-id='21R']",
el => el.hidden
@ -614,8 +609,9 @@ describe("ResetForm action", () => {
expect(hidden).withContext(`In ${browserName}`).toEqual(false);
await page.keyboard.press("Escape");
// eslint-disable-next-line no-restricted-syntax
await waitForTimeout(10);
await page.waitForFunction(
`document.querySelector("[data-annotation-id='21R']").hidden !== false`
);
hidden = await page.$eval(
"[data-annotation-id='21R']",
el => el.hidden