Skip to content

Commit

Permalink
Merge pull request #18165 from calixteman/integrationtest_switch_foo
Browse files Browse the repository at this point in the history
Simplify the integration test in adding a function to turn on/off an editing tool
  • Loading branch information
calixteman committed May 27, 2024
2 parents 17e09e5 + b6b02cc commit 4bdc75f
Show file tree
Hide file tree
Showing 5 changed files with 86 additions and 138 deletions.
56 changes: 12 additions & 44 deletions test/integration/freetext_editor_spec.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,7 @@ import {
loadAndWait,
pasteFromClipboard,
scrollIntoView,
switchToEditor,
waitForAnnotationEditorLayer,
waitForEvent,
waitForSelectedEditor,
Expand Down Expand Up @@ -77,10 +78,7 @@ const clearAll = async page => {
await waitForStorageEntries(page, 0);
};

const switchToFreeText = async page => {
await page.click("#editorFreeText");
await page.waitForSelector(".annotationEditorLayer.freetextEditing");
};
const switchToFreeText = switchToEditor.bind(null, "FreeText");

const getXY = async (page, selector) => {
const rect = await getRect(page, selector);
Expand Down Expand Up @@ -1045,10 +1043,7 @@ describe("FreeText Editor", () => {
);

// Disable editing mode.
await page.click("#editorFreeText");
await page.waitForSelector(
`.annotationEditorLayer:not(.freetextEditing)`
);
await switchToFreeText(page, /* disable = */ true);

// We want to check that the editor is displayed but not the original
// canvas.
Expand Down Expand Up @@ -1149,10 +1144,7 @@ describe("FreeText Editor", () => {
await page.waitForSelector(`${editorSelector} .overlay.enabled`);

// Disable editing mode.
await page.click("#editorFreeText");
await page.waitForSelector(
`.annotationEditorLayer:not(.freetextEditing)`
);
await switchToFreeText(page, /* disable = */ true);

await page.waitForSelector(`[data-annotation-id='popup_32R']`, {
visible: true,
Expand Down Expand Up @@ -1235,10 +1227,7 @@ describe("FreeText Editor", () => {
]);

// Disable editing mode.
await page.click("#editorFreeText");
await page.waitForSelector(
`.annotationEditorLayer:not(.freetextEditing)`
);
await switchToFreeText(page, /* disable = */ true);

// We want to check that nothing is displayed.
editorIds = await getEditors(page, "freeText");
Expand Down Expand Up @@ -1361,10 +1350,7 @@ describe("FreeText Editor", () => {
await switchToFreeText(page);

// Disable editing mode.
await page.click("#editorFreeText");
await page.waitForSelector(
`.annotationEditorLayer:not(.freetextEditing)`
);
await switchToFreeText(page, /* disable = */ true);

// TODO: remove this when we switch to BiDi.
await hover(page, "[data-annotation-id='23R']");
Expand Down Expand Up @@ -1399,10 +1385,7 @@ describe("FreeText Editor", () => {
);

// Exit editing mode.
await page.click("#editorFreeText");
await page.waitForSelector(
`.annotationEditorLayer:not(.freetextEditing)`
);
await switchToFreeText(page, /* disable = */ true);

// Wait for the popup to be visible.
await page.waitForFunction(
Expand Down Expand Up @@ -2782,10 +2765,7 @@ describe("FreeText Editor", () => {
expect(content).withContext(`In ${browserName}`).toEqual(data);

// Disable editing mode.
await page.click("#editorFreeText");
await page.waitForSelector(
`.annotationEditorLayer:not(.freetextEditing)`
);
await switchToFreeText(page, /* disable = */ true);

await page.focus("#editorFreeText");
await page.keyboard.press(" ");
Expand Down Expand Up @@ -3086,10 +3066,7 @@ describe("FreeText Editor", () => {
await page.click(getEditorSelector(0), { count: 2 });
await page.type(`${getEditorSelector(0)} .internal`, "C");

await page.click("#editorFreeText");
await page.waitForSelector(
`.annotationEditorLayer:not(.freetextEditing)`
);
await switchToFreeText(page, /* disable = */ true);

const [value] = await getSerialized(page, x => x.value);
expect(value)
Expand Down Expand Up @@ -3118,10 +3095,7 @@ describe("FreeText Editor", () => {
await page.click(getEditorSelector(0), { count: 2 });
await page.type(`${getEditorSelector(0)} .internal`, "Z");

await page.click("#editorFreeText");
await page.waitForSelector(
`.annotationEditorLayer:not(.freetextEditing)`
);
await switchToFreeText(page, /* disable = */ true);

const [value] = await getSerialized(page, x => x.value);
expect(value)
Expand Down Expand Up @@ -3593,10 +3567,7 @@ describe("FreeText Editor", () => {
);

// Disable editing mode.
await page.click("#editorFreeText");
await page.waitForSelector(
`.annotationEditorLayer:not(.freetextEditing)`
);
await switchToFreeText(page, /* disable = */ true);

const oneToOne = Array.from(new Array(13).keys(), n => n + 2).concat(
Array.from(new Array(13).keys(), n => 13 - n)
Expand Down Expand Up @@ -3640,10 +3611,7 @@ describe("FreeText Editor", () => {
await waitForSerialized(page, 0);

// Disable editing mode.
await page.click("#editorFreeText");
await page.waitForSelector(
`.annotationEditorLayer:not(.freetextEditing)`
);
await switchToFreeText(page, /* disable = */ true);

const thirteenToOne = Array.from(new Array(13).keys(), n => 13 - n);
for (const pageNumber of thirteenToOne) {
Expand Down
Loading

0 comments on commit 4bdc75f

Please sign in to comment.