Implement a helper function for unselecting an editor in the integration tests
This has multiple advantages: - it improves consistency between the various editor integration tests; - it makes the code easier to read/understand; - it reduces code duplication.
This commit is contained in:
parent
c051dd78cf
commit
895edafc23
@ -45,6 +45,7 @@ import {
|
|||||||
scrollIntoView,
|
scrollIntoView,
|
||||||
selectEditor,
|
selectEditor,
|
||||||
switchToEditor,
|
switchToEditor,
|
||||||
|
unselectEditor,
|
||||||
waitForAnnotationEditorLayer,
|
waitForAnnotationEditorLayer,
|
||||||
waitForAnnotationModeChanged,
|
waitForAnnotationModeChanged,
|
||||||
waitForEditorMovedInDOM,
|
waitForEditorMovedInDOM,
|
||||||
@ -2225,8 +2226,7 @@ describe("FreeText Editor", () => {
|
|||||||
await commit(page);
|
await commit(page);
|
||||||
|
|
||||||
// Unselect.
|
// Unselect.
|
||||||
await page.keyboard.press("Escape");
|
await unselectEditor(page, editorSelector);
|
||||||
await waitForUnselectedEditor(page, editorSelector);
|
|
||||||
|
|
||||||
// Select the editor created previously.
|
// Select the editor created previously.
|
||||||
await selectEditor(page, editorSelector);
|
await selectEditor(page, editorSelector);
|
||||||
@ -2300,8 +2300,7 @@ describe("FreeText Editor", () => {
|
|||||||
await commit(page);
|
await commit(page);
|
||||||
|
|
||||||
// Unselect.
|
// Unselect.
|
||||||
await page.keyboard.press("Escape");
|
await unselectEditor(page, editorSelector);
|
||||||
await waitForUnselectedEditor(page, editorSelector);
|
|
||||||
|
|
||||||
// Select the editor created previously.
|
// Select the editor created previously.
|
||||||
await selectEditor(page, editorSelector);
|
await selectEditor(page, editorSelector);
|
||||||
@ -2481,8 +2480,7 @@ describe("FreeText Editor", () => {
|
|||||||
await commit(page);
|
await commit(page);
|
||||||
|
|
||||||
// Unselect.
|
// Unselect.
|
||||||
await page.keyboard.press("Escape");
|
await unselectEditor(page, editorSelector);
|
||||||
await waitForUnselectedEditor(page, editorSelector);
|
|
||||||
|
|
||||||
content = await page.$eval(getEditorSelector(1), el =>
|
content = await page.$eval(getEditorSelector(1), el =>
|
||||||
el.innerText.trimEnd()
|
el.innerText.trimEnd()
|
||||||
@ -2509,8 +2507,7 @@ describe("FreeText Editor", () => {
|
|||||||
await commit(page);
|
await commit(page);
|
||||||
|
|
||||||
// Unselect.
|
// Unselect.
|
||||||
await page.keyboard.press("Escape");
|
await unselectEditor(page, editorSelector);
|
||||||
await waitForUnselectedEditor(page, editorSelector);
|
|
||||||
|
|
||||||
let content = await page.$eval(getEditorSelector(2), el =>
|
let content = await page.$eval(getEditorSelector(2), el =>
|
||||||
el.innerText.trimEnd()
|
el.innerText.trimEnd()
|
||||||
@ -2532,8 +2529,7 @@ describe("FreeText Editor", () => {
|
|||||||
await commit(page);
|
await commit(page);
|
||||||
|
|
||||||
// Unselect.
|
// Unselect.
|
||||||
await page.keyboard.press("Escape");
|
await unselectEditor(page, editorSelector);
|
||||||
await waitForUnselectedEditor(page, editorSelector);
|
|
||||||
|
|
||||||
content = await page.$eval(editorSelector, el =>
|
content = await page.$eval(editorSelector, el =>
|
||||||
el.innerText.trimEnd()
|
el.innerText.trimEnd()
|
||||||
|
|||||||
@ -33,12 +33,12 @@ import {
|
|||||||
scrollIntoView,
|
scrollIntoView,
|
||||||
setCaretAt,
|
setCaretAt,
|
||||||
switchToEditor,
|
switchToEditor,
|
||||||
|
unselectEditor,
|
||||||
waitAndClick,
|
waitAndClick,
|
||||||
waitForAnnotationModeChanged,
|
waitForAnnotationModeChanged,
|
||||||
waitForSelectedEditor,
|
waitForSelectedEditor,
|
||||||
waitForSerialized,
|
waitForSerialized,
|
||||||
waitForTimeout,
|
waitForTimeout,
|
||||||
waitForUnselectedEditor,
|
|
||||||
} from "./test_utils.mjs";
|
} from "./test_utils.mjs";
|
||||||
import { fileURLToPath } from "url";
|
import { fileURLToPath } from "url";
|
||||||
import fs from "fs";
|
import fs from "fs";
|
||||||
@ -1044,8 +1044,7 @@ describe("Highlight Editor", () => {
|
|||||||
const y = rect.y + rect.height / 2;
|
const y = rect.y + rect.height / 2;
|
||||||
await page.mouse.click(x, y, { count: 2, delay: 100 });
|
await page.mouse.click(x, y, { count: 2, delay: 100 });
|
||||||
await page.waitForSelector(`${getEditorSelector(0)}`);
|
await page.waitForSelector(`${getEditorSelector(0)}`);
|
||||||
await page.keyboard.press("Escape");
|
await unselectEditor(page, getEditorSelector(0));
|
||||||
await waitForUnselectedEditor(page, getEditorSelector(0));
|
|
||||||
|
|
||||||
await setCaretAt(
|
await setCaretAt(
|
||||||
page,
|
page,
|
||||||
@ -1795,8 +1794,7 @@ describe("Highlight Editor", () => {
|
|||||||
await page.mouse.click(x, y, { count: 2, delay: 100 });
|
await page.mouse.click(x, y, { count: 2, delay: 100 });
|
||||||
await page.waitForSelector(editorSelector);
|
await page.waitForSelector(editorSelector);
|
||||||
await waitForSerialized(page, 1);
|
await waitForSerialized(page, 1);
|
||||||
await page.keyboard.press("Escape");
|
await unselectEditor(page, editorSelector);
|
||||||
await waitForUnselectedEditor(page, editorSelector);
|
|
||||||
|
|
||||||
const clickHandle = await waitForPointerUp(page);
|
const clickHandle = await waitForPointerUp(page);
|
||||||
y = rect.y - rect.height;
|
y = rect.y - rect.height;
|
||||||
@ -1866,8 +1864,7 @@ describe("Highlight Editor", () => {
|
|||||||
await page.mouse.click(x, y, { count: 3, delay: 100 });
|
await page.mouse.click(x, y, { count: 3, delay: 100 });
|
||||||
await page.waitForSelector(editorSelector);
|
await page.waitForSelector(editorSelector);
|
||||||
await waitForSerialized(page, 1);
|
await waitForSerialized(page, 1);
|
||||||
await page.keyboard.press("Escape");
|
await unselectEditor(page, editorSelector);
|
||||||
await waitForUnselectedEditor(page, editorSelector);
|
|
||||||
|
|
||||||
const clickHandle = await waitForPointerUp(page);
|
const clickHandle = await waitForPointerUp(page);
|
||||||
y = rect.y - 3 * rect.height;
|
y = rect.y - 3 * rect.height;
|
||||||
|
|||||||
@ -41,6 +41,7 @@ import {
|
|||||||
selectEditor,
|
selectEditor,
|
||||||
serializeBitmapDimensions,
|
serializeBitmapDimensions,
|
||||||
switchToEditor,
|
switchToEditor,
|
||||||
|
unselectEditor,
|
||||||
waitForAnnotationEditorLayer,
|
waitForAnnotationEditorLayer,
|
||||||
waitForAnnotationModeChanged,
|
waitForAnnotationModeChanged,
|
||||||
waitForEntryInStorage,
|
waitForEntryInStorage,
|
||||||
@ -48,7 +49,6 @@ import {
|
|||||||
waitForSerialized,
|
waitForSerialized,
|
||||||
waitForStorageEntries,
|
waitForStorageEntries,
|
||||||
waitForTimeout,
|
waitForTimeout,
|
||||||
waitForUnselectedEditor,
|
|
||||||
} from "./test_utils.mjs";
|
} from "./test_utils.mjs";
|
||||||
import { fileURLToPath } from "url";
|
import { fileURLToPath } from "url";
|
||||||
import fs from "fs";
|
import fs from "fs";
|
||||||
@ -1056,8 +1056,7 @@ describe("Stamp Editor", () => {
|
|||||||
.toEqual("Review alt text");
|
.toEqual("Review alt text");
|
||||||
|
|
||||||
// Unselect and select the editor and check that the badge is visible.
|
// Unselect and select the editor and check that the badge is visible.
|
||||||
await page.keyboard.press("Escape");
|
await unselectEditor(page, editorSelector);
|
||||||
await waitForUnselectedEditor(page, editorSelector);
|
|
||||||
await page.waitForSelector(".editToolbar", { visible: false });
|
await page.waitForSelector(".editToolbar", { visible: false });
|
||||||
await page.waitForSelector(".noAltTextBadge", { visible: true });
|
await page.waitForSelector(".noAltTextBadge", { visible: true });
|
||||||
|
|
||||||
@ -1106,8 +1105,7 @@ describe("Stamp Editor", () => {
|
|||||||
.toEqual("Missing alt text");
|
.toEqual("Missing alt text");
|
||||||
|
|
||||||
// Unselect and select the editor and check that the badge is visible.
|
// Unselect and select the editor and check that the badge is visible.
|
||||||
await page.keyboard.press("Escape");
|
await unselectEditor(page, editorSelector);
|
||||||
await waitForUnselectedEditor(page, editorSelector);
|
|
||||||
await page.waitForSelector(".editToolbar", { visible: false });
|
await page.waitForSelector(".editToolbar", { visible: false });
|
||||||
await page.waitForSelector(".noAltTextBadge", { visible: true });
|
await page.waitForSelector(".noAltTextBadge", { visible: true });
|
||||||
await page.evaluate(() => {
|
await page.evaluate(() => {
|
||||||
|
|||||||
@ -361,6 +361,11 @@ async function waitForSelectedEditor(page, selector) {
|
|||||||
return page.waitForSelector(`${selector}.selectedEditor`);
|
return page.waitForSelector(`${selector}.selectedEditor`);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
async function unselectEditor(page, selector) {
|
||||||
|
await page.keyboard.press("Escape");
|
||||||
|
await waitForUnselectedEditor(page, selector);
|
||||||
|
}
|
||||||
|
|
||||||
async function waitForUnselectedEditor(page, selector) {
|
async function waitForUnselectedEditor(page, selector) {
|
||||||
return page.waitForSelector(`${selector}:not(.selectedEditor)`);
|
return page.waitForSelector(`${selector}:not(.selectedEditor)`);
|
||||||
}
|
}
|
||||||
@ -882,6 +887,7 @@ export {
|
|||||||
serializeBitmapDimensions,
|
serializeBitmapDimensions,
|
||||||
setCaretAt,
|
setCaretAt,
|
||||||
switchToEditor,
|
switchToEditor,
|
||||||
|
unselectEditor,
|
||||||
waitAndClick,
|
waitAndClick,
|
||||||
waitForAnnotationEditorLayer,
|
waitForAnnotationEditorLayer,
|
||||||
waitForAnnotationModeChanged,
|
waitForAnnotationModeChanged,
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user