Introduce a generic selectEditors helper function
This replaces the various copies of this logic with a single helper that we template for each editor type, similar to what we already do for the `switchToEditor` helper.
This commit is contained in:
parent
060ef0e15e
commit
f155b69c07
@ -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);
|
||||
|
||||
@ -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");
|
||||
|
||||
|
||||
@ -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);
|
||||
|
||||
@ -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);
|
||||
|
||||
@ -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,
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user