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 most waitForTimeout usage from the freetext editor integration tests #18041

Merged
Merged
Show file tree
Hide file tree
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
8 changes: 1 addition & 7 deletions test/integration/annotation_spec.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -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`);
}
})
);
Expand Down
15 changes: 1 addition & 14 deletions test/integration/freetext_editor_spec.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -56,9 +56,6 @@ const copyPaste = async page => {
await kbCopy(page);
await promise;

// eslint-disable-next-line no-restricted-syntax
await waitForTimeout(10);
timvandermeij marked this conversation as resolved.
Show resolved Hide resolved

promise = waitForEvent(page, "paste");
await kbPaste(page);
await promise;
Expand Down Expand Up @@ -1364,9 +1361,6 @@ describe("FreeText Editor", () => {
// Enter in editing mode.
await switchToFreeText(page);

// eslint-disable-next-line no-restricted-syntax
await waitForTimeout(200);
timvandermeij marked this conversation as resolved.
Show resolved Hide resolved

// Disable editing mode.
await page.click("#editorFreeText");
await page.waitForSelector(
Expand Down Expand Up @@ -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}`)
Expand Down
12 changes: 3 additions & 9 deletions test/integration/highlight_editor_spec.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -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`);
})
);
});
Expand Down