Merge pull request #17969 from timvandermeij/integration-tests-timeout-annotations

Remove all `waitForTimeout` usage from the annotation integration tests
This commit is contained in:
Tim van der Meij 2024-04-24 16:14:54 +02:00 committed by GitHub
commit 7d1eabe2bd
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194

View File

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