Merge pull request #19543 from timvandermeij/integration-tests-helpers
Refactor the editor integration test helper functions
This commit is contained in:
commit
ed64faa88c
@ -15,6 +15,7 @@
|
|||||||
|
|
||||||
import {
|
import {
|
||||||
awaitPromise,
|
awaitPromise,
|
||||||
|
clearEditors,
|
||||||
closePages,
|
closePages,
|
||||||
copy,
|
copy,
|
||||||
copyToClipboard,
|
copyToClipboard,
|
||||||
@ -37,7 +38,6 @@ import {
|
|||||||
kbModifierDown,
|
kbModifierDown,
|
||||||
kbModifierUp,
|
kbModifierUp,
|
||||||
kbRedo,
|
kbRedo,
|
||||||
kbSelectAll,
|
|
||||||
kbUndo,
|
kbUndo,
|
||||||
loadAndWait,
|
loadAndWait,
|
||||||
moveEditor,
|
moveEditor,
|
||||||
@ -45,6 +45,7 @@ import {
|
|||||||
pasteFromClipboard,
|
pasteFromClipboard,
|
||||||
scrollIntoView,
|
scrollIntoView,
|
||||||
selectEditor,
|
selectEditor,
|
||||||
|
selectEditors,
|
||||||
switchToEditor,
|
switchToEditor,
|
||||||
unselectEditor,
|
unselectEditor,
|
||||||
waitForAnnotationEditorLayer,
|
waitForAnnotationEditorLayer,
|
||||||
@ -57,20 +58,9 @@ 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 = clearEditors.bind(null, "freeText");
|
||||||
await selectAll(page);
|
|
||||||
await page.keyboard.down("Control");
|
|
||||||
await page.keyboard.press("Backspace");
|
|
||||||
await page.keyboard.up("Control");
|
|
||||||
await waitForStorageEntries(page, 0);
|
|
||||||
};
|
|
||||||
|
|
||||||
const commit = async page => {
|
const commit = async page => {
|
||||||
await page.keyboard.press("Escape");
|
await page.keyboard.press("Escape");
|
||||||
|
|||||||
@ -16,26 +16,27 @@
|
|||||||
import {
|
import {
|
||||||
awaitPromise,
|
awaitPromise,
|
||||||
closePages,
|
closePages,
|
||||||
createPromise,
|
|
||||||
getEditorSelector,
|
getEditorSelector,
|
||||||
getFirstSerialized,
|
getFirstSerialized,
|
||||||
getRect,
|
getRect,
|
||||||
getSerialized,
|
getSerialized,
|
||||||
getSpanRectFromText,
|
getSpanRectFromText,
|
||||||
|
getXY,
|
||||||
kbBigMoveLeft,
|
kbBigMoveLeft,
|
||||||
kbBigMoveUp,
|
kbBigMoveUp,
|
||||||
kbFocusNext,
|
kbFocusNext,
|
||||||
kbFocusPrevious,
|
kbFocusPrevious,
|
||||||
kbSave,
|
kbSave,
|
||||||
kbSelectAll,
|
|
||||||
kbUndo,
|
kbUndo,
|
||||||
loadAndWait,
|
loadAndWait,
|
||||||
scrollIntoView,
|
scrollIntoView,
|
||||||
|
selectEditors,
|
||||||
setCaretAt,
|
setCaretAt,
|
||||||
switchToEditor,
|
switchToEditor,
|
||||||
unselectEditor,
|
unselectEditor,
|
||||||
waitAndClick,
|
waitAndClick,
|
||||||
waitForAnnotationModeChanged,
|
waitForAnnotationModeChanged,
|
||||||
|
waitForPointerUp,
|
||||||
waitForSelectedEditor,
|
waitForSelectedEditor,
|
||||||
waitForSerialized,
|
waitForSerialized,
|
||||||
waitForTimeout,
|
waitForTimeout,
|
||||||
@ -46,25 +47,10 @@ 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 waitForPointerUp = page =>
|
|
||||||
createPromise(page, resolve => {
|
|
||||||
window.addEventListener("pointerup", resolve, { once: true });
|
|
||||||
});
|
|
||||||
|
|
||||||
const switchToHighlight = switchToEditor.bind(null, "Highlight");
|
const switchToHighlight = switchToEditor.bind(null, "Highlight");
|
||||||
|
|
||||||
const getXY = async (page, selector) => {
|
|
||||||
const rect = await getRect(page, selector);
|
|
||||||
return `${rect.x}::${rect.y}`;
|
|
||||||
};
|
|
||||||
|
|
||||||
describe("Highlight Editor", () => {
|
describe("Highlight Editor", () => {
|
||||||
describe("Editor must be removed without exception", () => {
|
describe("Editor must be removed without exception", () => {
|
||||||
let pages;
|
let pages;
|
||||||
|
|||||||
@ -15,6 +15,7 @@
|
|||||||
|
|
||||||
import {
|
import {
|
||||||
awaitPromise,
|
awaitPromise,
|
||||||
|
clearEditors,
|
||||||
closePages,
|
closePages,
|
||||||
dragAndDrop,
|
dragAndDrop,
|
||||||
getAnnotationSelector,
|
getAnnotationSelector,
|
||||||
@ -24,12 +25,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,18 +41,9 @@ 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 = clearEditors.bind(null, "ink");
|
||||||
await selectAll(page);
|
|
||||||
await page.keyboard.press("Backspace");
|
|
||||||
await waitForStorageEntries(page, 0);
|
|
||||||
};
|
|
||||||
|
|
||||||
const commit = async page => {
|
const commit = async page => {
|
||||||
await page.keyboard.press("Escape");
|
await page.keyboard.press("Escape");
|
||||||
|
|||||||
@ -17,6 +17,7 @@ import {
|
|||||||
applyFunctionToEditor,
|
applyFunctionToEditor,
|
||||||
awaitPromise,
|
awaitPromise,
|
||||||
cleanupEditing,
|
cleanupEditing,
|
||||||
|
clearEditors,
|
||||||
clearInput,
|
clearInput,
|
||||||
closePages,
|
closePages,
|
||||||
copy,
|
copy,
|
||||||
@ -32,7 +33,6 @@ import {
|
|||||||
isVisible,
|
isVisible,
|
||||||
kbBigMoveDown,
|
kbBigMoveDown,
|
||||||
kbBigMoveRight,
|
kbBigMoveRight,
|
||||||
kbSelectAll,
|
|
||||||
kbUndo,
|
kbUndo,
|
||||||
loadAndWait,
|
loadAndWait,
|
||||||
paste,
|
paste,
|
||||||
@ -47,7 +47,6 @@ import {
|
|||||||
waitForEntryInStorage,
|
waitForEntryInStorage,
|
||||||
waitForSelectedEditor,
|
waitForSelectedEditor,
|
||||||
waitForSerialized,
|
waitForSerialized,
|
||||||
waitForStorageEntries,
|
|
||||||
waitForTimeout,
|
waitForTimeout,
|
||||||
} from "./test_utils.mjs";
|
} from "./test_utils.mjs";
|
||||||
import { fileURLToPath } from "url";
|
import { fileURLToPath } from "url";
|
||||||
@ -57,18 +56,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 clearAll = clearEditors.bind(null, "stamp");
|
||||||
await kbSelectAll(page);
|
|
||||||
await page.waitForFunction(
|
|
||||||
() => !document.querySelector(".stampEditor:not(.selectedEditor)")
|
|
||||||
);
|
|
||||||
};
|
|
||||||
|
|
||||||
const clearAll = async page => {
|
|
||||||
await selectAll(page);
|
|
||||||
await page.keyboard.press("Backspace");
|
|
||||||
await waitForStorageEntries(page, 0);
|
|
||||||
};
|
|
||||||
|
|
||||||
const waitForImage = async (page, selector) => {
|
const waitForImage = async (page, selector) => {
|
||||||
await page.waitForSelector(`${selector} canvas`);
|
await page.waitForSelector(`${selector} canvas`);
|
||||||
|
|||||||
@ -809,6 +809,19 @@ 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)`)
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
async function clearEditors(name, page) {
|
||||||
|
await selectEditors(name, page);
|
||||||
|
await page.keyboard.press("Backspace");
|
||||||
|
await waitForStorageEntries(page, 0);
|
||||||
|
}
|
||||||
|
|
||||||
function waitForNoElement(page, selector) {
|
function waitForNoElement(page, selector) {
|
||||||
return page.waitForFunction(
|
return page.waitForFunction(
|
||||||
sel => !document.querySelector(sel),
|
sel => !document.querySelector(sel),
|
||||||
@ -881,6 +894,7 @@ export {
|
|||||||
applyFunctionToEditor,
|
applyFunctionToEditor,
|
||||||
awaitPromise,
|
awaitPromise,
|
||||||
cleanupEditing,
|
cleanupEditing,
|
||||||
|
clearEditors,
|
||||||
clearInput,
|
clearInput,
|
||||||
closePages,
|
closePages,
|
||||||
closeSinglePage,
|
closeSinglePage,
|
||||||
@ -901,6 +915,7 @@ export {
|
|||||||
getSelector,
|
getSelector,
|
||||||
getSerialized,
|
getSerialized,
|
||||||
getSpanRectFromText,
|
getSpanRectFromText,
|
||||||
|
getXY,
|
||||||
hover,
|
hover,
|
||||||
isCanvasWhite,
|
isCanvasWhite,
|
||||||
isVisible,
|
isVisible,
|
||||||
@ -926,6 +941,7 @@ export {
|
|||||||
pasteFromClipboard,
|
pasteFromClipboard,
|
||||||
scrollIntoView,
|
scrollIntoView,
|
||||||
selectEditor,
|
selectEditor,
|
||||||
|
selectEditors,
|
||||||
serializeBitmapDimensions,
|
serializeBitmapDimensions,
|
||||||
setCaretAt,
|
setCaretAt,
|
||||||
switchToEditor,
|
switchToEditor,
|
||||||
@ -933,7 +949,6 @@ export {
|
|||||||
waitAndClick,
|
waitAndClick,
|
||||||
waitForAnnotationEditorLayer,
|
waitForAnnotationEditorLayer,
|
||||||
waitForAnnotationModeChanged,
|
waitForAnnotationModeChanged,
|
||||||
waitForEditorMovedInDOM,
|
|
||||||
waitForEntryInStorage,
|
waitForEntryInStorage,
|
||||||
waitForEvent,
|
waitForEvent,
|
||||||
waitForNoElement,
|
waitForNoElement,
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user