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,
|
kbModifierDown,
|
||||||
kbModifierUp,
|
kbModifierUp,
|
||||||
kbRedo,
|
kbRedo,
|
||||||
kbSelectAll,
|
|
||||||
kbUndo,
|
kbUndo,
|
||||||
loadAndWait,
|
loadAndWait,
|
||||||
moveEditor,
|
moveEditor,
|
||||||
@ -45,6 +44,7 @@ import {
|
|||||||
pasteFromClipboard,
|
pasteFromClipboard,
|
||||||
scrollIntoView,
|
scrollIntoView,
|
||||||
selectEditor,
|
selectEditor,
|
||||||
|
selectEditors,
|
||||||
switchToEditor,
|
switchToEditor,
|
||||||
unselectEditor,
|
unselectEditor,
|
||||||
waitForAnnotationEditorLayer,
|
waitForAnnotationEditorLayer,
|
||||||
@ -57,12 +57,7 @@ import {
|
|||||||
} from "./test_utils.mjs";
|
} from "./test_utils.mjs";
|
||||||
import { PNG } from "pngjs";
|
import { PNG } from "pngjs";
|
||||||
|
|
||||||
const selectAll = async page => {
|
const selectAll = selectEditors.bind(null, "freeText");
|
||||||
await kbSelectAll(page);
|
|
||||||
await page.waitForFunction(
|
|
||||||
() => !document.querySelector(".freeTextEditor:not(.selectedEditor)")
|
|
||||||
);
|
|
||||||
};
|
|
||||||
|
|
||||||
const clearAll = async page => {
|
const clearAll = async page => {
|
||||||
await selectAll(page);
|
await selectAll(page);
|
||||||
|
|||||||
@ -27,10 +27,10 @@ import {
|
|||||||
kbFocusNext,
|
kbFocusNext,
|
||||||
kbFocusPrevious,
|
kbFocusPrevious,
|
||||||
kbSave,
|
kbSave,
|
||||||
kbSelectAll,
|
|
||||||
kbUndo,
|
kbUndo,
|
||||||
loadAndWait,
|
loadAndWait,
|
||||||
scrollIntoView,
|
scrollIntoView,
|
||||||
|
selectEditors,
|
||||||
setCaretAt,
|
setCaretAt,
|
||||||
switchToEditor,
|
switchToEditor,
|
||||||
unselectEditor,
|
unselectEditor,
|
||||||
@ -47,12 +47,7 @@ import path from "path";
|
|||||||
|
|
||||||
const __dirname = path.dirname(fileURLToPath(import.meta.url));
|
const __dirname = path.dirname(fileURLToPath(import.meta.url));
|
||||||
|
|
||||||
const selectAll = async page => {
|
const selectAll = selectEditors.bind(null, "highlight");
|
||||||
await kbSelectAll(page);
|
|
||||||
await page.waitForFunction(
|
|
||||||
() => !document.querySelector(".highlightEditor:not(.selectedEditor)")
|
|
||||||
);
|
|
||||||
};
|
|
||||||
|
|
||||||
const switchToHighlight = switchToEditor.bind(null, "Highlight");
|
const switchToHighlight = switchToEditor.bind(null, "Highlight");
|
||||||
|
|
||||||
|
|||||||
@ -24,12 +24,12 @@ import {
|
|||||||
getSerialized,
|
getSerialized,
|
||||||
isCanvasWhite,
|
isCanvasWhite,
|
||||||
kbRedo,
|
kbRedo,
|
||||||
kbSelectAll,
|
|
||||||
kbUndo,
|
kbUndo,
|
||||||
loadAndWait,
|
loadAndWait,
|
||||||
moveEditor,
|
moveEditor,
|
||||||
scrollIntoView,
|
scrollIntoView,
|
||||||
selectEditor,
|
selectEditor,
|
||||||
|
selectEditors,
|
||||||
switchToEditor,
|
switchToEditor,
|
||||||
waitForAnnotationModeChanged,
|
waitForAnnotationModeChanged,
|
||||||
waitForNoElement,
|
waitForNoElement,
|
||||||
@ -40,12 +40,7 @@ import {
|
|||||||
waitForTimeout,
|
waitForTimeout,
|
||||||
} from "./test_utils.mjs";
|
} from "./test_utils.mjs";
|
||||||
|
|
||||||
const selectAll = async page => {
|
const selectAll = selectEditors.bind(null, "ink");
|
||||||
await kbSelectAll(page);
|
|
||||||
await page.waitForFunction(
|
|
||||||
() => !document.querySelector(".inkEditor.disabled:not(.selectedEditor)")
|
|
||||||
);
|
|
||||||
};
|
|
||||||
|
|
||||||
const clearAll = async page => {
|
const clearAll = async page => {
|
||||||
await selectAll(page);
|
await selectAll(page);
|
||||||
|
|||||||
@ -32,13 +32,13 @@ import {
|
|||||||
isVisible,
|
isVisible,
|
||||||
kbBigMoveDown,
|
kbBigMoveDown,
|
||||||
kbBigMoveRight,
|
kbBigMoveRight,
|
||||||
kbSelectAll,
|
|
||||||
kbUndo,
|
kbUndo,
|
||||||
loadAndWait,
|
loadAndWait,
|
||||||
paste,
|
paste,
|
||||||
pasteFromClipboard,
|
pasteFromClipboard,
|
||||||
scrollIntoView,
|
scrollIntoView,
|
||||||
selectEditor,
|
selectEditor,
|
||||||
|
selectEditors,
|
||||||
serializeBitmapDimensions,
|
serializeBitmapDimensions,
|
||||||
switchToEditor,
|
switchToEditor,
|
||||||
unselectEditor,
|
unselectEditor,
|
||||||
@ -57,12 +57,7 @@ import { PNG } from "pngjs";
|
|||||||
|
|
||||||
const __dirname = path.dirname(fileURLToPath(import.meta.url));
|
const __dirname = path.dirname(fileURLToPath(import.meta.url));
|
||||||
|
|
||||||
const selectAll = async page => {
|
const selectAll = selectEditors.bind(null, "stamp");
|
||||||
await kbSelectAll(page);
|
|
||||||
await page.waitForFunction(
|
|
||||||
() => !document.querySelector(".stampEditor:not(.selectedEditor)")
|
|
||||||
);
|
|
||||||
};
|
|
||||||
|
|
||||||
const clearAll = async page => {
|
const clearAll = async page => {
|
||||||
await selectAll(page);
|
await selectAll(page);
|
||||||
|
|||||||
@ -809,6 +809,13 @@ async function switchToEditor(name, page, disable = false) {
|
|||||||
await awaitPromise(modeChangedHandle);
|
await awaitPromise(modeChangedHandle);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
async function selectEditors(name, page) {
|
||||||
|
await kbSelectAll(page);
|
||||||
|
await page.waitForFunction(
|
||||||
|
() => !document.querySelector(`.${name}Editor:not(.selectedEditor)`)
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
function waitForNoElement(page, selector) {
|
function waitForNoElement(page, selector) {
|
||||||
return page.waitForFunction(
|
return page.waitForFunction(
|
||||||
sel => !document.querySelector(sel),
|
sel => !document.querySelector(sel),
|
||||||
@ -927,6 +934,7 @@ export {
|
|||||||
pasteFromClipboard,
|
pasteFromClipboard,
|
||||||
scrollIntoView,
|
scrollIntoView,
|
||||||
selectEditor,
|
selectEditor,
|
||||||
|
selectEditors,
|
||||||
serializeBitmapDimensions,
|
serializeBitmapDimensions,
|
||||||
setCaretAt,
|
setCaretAt,
|
||||||
switchToEditor,
|
switchToEditor,
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user