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

Merge pull request #18041 from timvandermeij/integration-tests-timeout-freetext

Remove most `waitForTimeout` usage from the freetext editor integration tests
This commit is contained in:
Tim van der Meij 2024-05-06 20:00:03 +02:00 committed by GitHub
commit 14e87469db
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
3 changed files with 5 additions and 30 deletions

View file

@ -74,13 +74,7 @@ describe("Annotation highlight", () => {
pages.map(async ([browserName, page]) => {
for (const i of [23, 22, 14]) {
await page.click(`[data-annotation-id='${i}R']`);
await page.waitForFunction(
id =>
document.activeElement ===
document.querySelector(`#pdfjs_internal_id_${id}R`),
{},
i
);
await page.waitForSelector(`#pdfjs_internal_id_${i}R:focus`);
}
})
);

View file

@ -56,9 +56,6 @@ const copyPaste = async page => {
await kbCopy(page);
await promise;
// eslint-disable-next-line no-restricted-syntax
await waitForTimeout(10);
promise = waitForEvent(page, "paste");
await kbPaste(page);
await promise;
@ -1364,9 +1361,6 @@ describe("FreeText Editor", () => {
// Enter in editing mode.
await switchToFreeText(page);
// eslint-disable-next-line no-restricted-syntax
await waitForTimeout(200);
// Disable editing mode.
await page.click("#editorFreeText");
await page.waitForSelector(
@ -2411,14 +2405,7 @@ describe("FreeText Editor", () => {
// The editor must be moved in the DOM and potentially the focus
// will be lost, hence there's a callback will get back the focus.
// eslint-disable-next-line no-restricted-syntax
await waitForTimeout(200);
const focused = await page.evaluate(sel => {
const editor = document.querySelector(sel);
return editor === document.activeElement;
}, getEditorSelector(1));
expect(focused).withContext(`In ${browserName}`).toEqual(true);
await page.waitForSelector(`${getEditorSelector(1)}:focus`);
expect(await pos(0))
.withContext(`In ${browserName}`)

View file

@ -1591,18 +1591,12 @@ describe("Highlight Editor", () => {
await page.focus(getEditorSelector(1));
await kbFocusPrevious(page);
await page.waitForFunction(
sel => document.querySelector(sel) === document.activeElement,
{},
`.page[data-page-number="1"] > .textLayer`
await page.waitForSelector(
`.page[data-page-number="1"] > .textLayer:focus`
);
await kbFocusNext(page);
await page.waitForFunction(
sel => document.querySelector(sel) === document.activeElement,
{},
getEditorSelector(1)
);
await page.waitForSelector(`${getEditorSelector(1)}:focus`);
})
);
});