diff --git a/test/integration/freetext_editor_spec.mjs b/test/integration/freetext_editor_spec.mjs index 404e24eb9..9056ca222 100644 --- a/test/integration/freetext_editor_spec.mjs +++ b/test/integration/freetext_editor_spec.mjs @@ -37,7 +37,6 @@ import { kbModifierDown, kbModifierUp, kbRedo, - kbSelectAll, kbUndo, loadAndWait, moveEditor, @@ -45,6 +44,7 @@ import { pasteFromClipboard, scrollIntoView, selectEditor, + selectEditors, switchToEditor, unselectEditor, waitForAnnotationEditorLayer, @@ -57,12 +57,7 @@ import { } from "./test_utils.mjs"; import { PNG } from "pngjs"; -const selectAll = async page => { - await kbSelectAll(page); - await page.waitForFunction( - () => !document.querySelector(".freeTextEditor:not(.selectedEditor)") - ); -}; +const selectAll = selectEditors.bind(null, "freeText"); const clearAll = async page => { await selectAll(page); diff --git a/test/integration/highlight_editor_spec.mjs b/test/integration/highlight_editor_spec.mjs index 6241195d2..f9d4199c2 100644 --- a/test/integration/highlight_editor_spec.mjs +++ b/test/integration/highlight_editor_spec.mjs @@ -27,10 +27,10 @@ import { kbFocusNext, kbFocusPrevious, kbSave, - kbSelectAll, kbUndo, loadAndWait, scrollIntoView, + selectEditors, setCaretAt, switchToEditor, unselectEditor, @@ -47,12 +47,7 @@ import path from "path"; const __dirname = path.dirname(fileURLToPath(import.meta.url)); -const selectAll = async page => { - await kbSelectAll(page); - await page.waitForFunction( - () => !document.querySelector(".highlightEditor:not(.selectedEditor)") - ); -}; +const selectAll = selectEditors.bind(null, "highlight"); const switchToHighlight = switchToEditor.bind(null, "Highlight"); diff --git a/test/integration/ink_editor_spec.mjs b/test/integration/ink_editor_spec.mjs index 2e927231f..a9de1bd3e 100644 --- a/test/integration/ink_editor_spec.mjs +++ b/test/integration/ink_editor_spec.mjs @@ -24,12 +24,12 @@ import { getSerialized, isCanvasWhite, kbRedo, - kbSelectAll, kbUndo, loadAndWait, moveEditor, scrollIntoView, selectEditor, + selectEditors, switchToEditor, waitForAnnotationModeChanged, waitForNoElement, @@ -40,12 +40,7 @@ import { waitForTimeout, } from "./test_utils.mjs"; -const selectAll = async page => { - await kbSelectAll(page); - await page.waitForFunction( - () => !document.querySelector(".inkEditor.disabled:not(.selectedEditor)") - ); -}; +const selectAll = selectEditors.bind(null, "ink"); const clearAll = async page => { await selectAll(page); diff --git a/test/integration/stamp_editor_spec.mjs b/test/integration/stamp_editor_spec.mjs index be3780230..8f319ba75 100644 --- a/test/integration/stamp_editor_spec.mjs +++ b/test/integration/stamp_editor_spec.mjs @@ -32,13 +32,13 @@ import { isVisible, kbBigMoveDown, kbBigMoveRight, - kbSelectAll, kbUndo, loadAndWait, paste, pasteFromClipboard, scrollIntoView, selectEditor, + selectEditors, serializeBitmapDimensions, switchToEditor, unselectEditor, @@ -57,12 +57,7 @@ import { PNG } from "pngjs"; const __dirname = path.dirname(fileURLToPath(import.meta.url)); -const selectAll = async page => { - await kbSelectAll(page); - await page.waitForFunction( - () => !document.querySelector(".stampEditor:not(.selectedEditor)") - ); -}; +const selectAll = selectEditors.bind(null, "stamp"); const clearAll = async page => { await selectAll(page); diff --git a/test/integration/test_utils.mjs b/test/integration/test_utils.mjs index 68761f187..d204a59d3 100644 --- a/test/integration/test_utils.mjs +++ b/test/integration/test_utils.mjs @@ -809,6 +809,13 @@ async function switchToEditor(name, page, disable = false) { await awaitPromise(modeChangedHandle); } +async function selectEditors(name, page) { + await kbSelectAll(page); + await page.waitForFunction( + () => !document.querySelector(`.${name}Editor:not(.selectedEditor)`) + ); +} + function waitForNoElement(page, selector) { return page.waitForFunction( sel => !document.querySelector(sel), @@ -927,6 +934,7 @@ export { pasteFromClipboard, scrollIntoView, selectEditor, + selectEditors, serializeBitmapDimensions, setCaretAt, switchToEditor,