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 all waitForTimeout usage from the annotation integration tests #17969

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
34 changes: 15 additions & 19 deletions test/integration/annotation_spec.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,6 @@ import {
getQuerySelector,
getSelector,
loadAndWait,
waitForTimeout,
} from "./test_utils.mjs";

describe("Annotation highlight", () => {
Expand Down Expand Up @@ -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`
);
Expand Down Expand Up @@ -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");
Expand Down Expand Up @@ -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`
);
Expand Down Expand Up @@ -587,35 +579,39 @@ 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
);
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
);
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
);
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
Expand Down