Skip to content

Commit

Permalink
Centralize the editor selector definitions in the ink editor integrat…
Browse files Browse the repository at this point in the history
…ion tests

In most integration tests we already use the pattern of defining the
editor selector once and reusing it in the rest of the test, but it's
not fully consistent everywhere yet. This commit fixes that for the
ink editor integration tests, which has multiple advantages:

- it improves consistency between the various editor integration tests;
- it removes duplicate function calls and aligns variable definitions;
- it reduces the number of `getEditorSelector` calls that contained
  hardcoded IDs, which helps to isolate the tests and to simplify
  follow-up patches.
  • Loading branch information
timvandermeij committed Jan 19, 2025
1 parent ac57939 commit bd67156
Showing 1 changed file with 15 additions and 13 deletions.
28 changes: 15 additions & 13 deletions test/integration/ink_editor_spec.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -305,16 +305,17 @@ describe("Ink Editor", () => {
await awaitPromise(clickHandle);
await commit(page);

await page.waitForSelector(getEditorSelector(0));
const editorSelector = getEditorSelector(0);
await page.waitForSelector(editorSelector);
await waitForSerialized(page, 1);

await page.waitForSelector(`${getEditorSelector(0)} button.delete`);
await page.click(`${getEditorSelector(0)} button.delete`);
await page.waitForSelector(`${editorSelector} button.delete`);
await page.click(`${editorSelector} button.delete`);
await waitForSerialized(page, 0);

await kbUndo(page);
await waitForSerialized(page, 1);
await page.waitForSelector(getEditorSelector(0));
await page.waitForSelector(editorSelector);
})
);
});
Expand Down Expand Up @@ -348,11 +349,12 @@ describe("Ink Editor", () => {
await awaitPromise(clickHandle);
await commit(page);

await page.waitForSelector(getEditorSelector(0));
const editorSelector = getEditorSelector(0);
await page.waitForSelector(editorSelector);
await waitForSerialized(page, 1);

await page.waitForSelector(`${getEditorSelector(0)} button.delete`);
await page.click(`${getEditorSelector(0)} button.delete`);
await page.waitForSelector(`${editorSelector} button.delete`);
await page.click(`${editorSelector} button.delete`);
await waitForSerialized(page, 0);

const twoToFourteen = Array.from(new Array(13).keys(), n => n + 2);
Expand All @@ -370,7 +372,7 @@ describe("Ink Editor", () => {
await scrollIntoView(page, pageSelector);
}

await page.waitForSelector(getEditorSelector(0));
await page.waitForSelector(editorSelector);
})
);
});
Expand Down Expand Up @@ -404,11 +406,12 @@ describe("Ink Editor", () => {
await awaitPromise(clickHandle);
await commit(page);

await page.waitForSelector(getEditorSelector(0));
const editorSelector = getEditorSelector(0);
await page.waitForSelector(editorSelector);
await waitForSerialized(page, 1);

await page.waitForSelector(`${getEditorSelector(0)} button.delete`);
await page.click(`${getEditorSelector(0)} button.delete`);
await page.waitForSelector(`${editorSelector} button.delete`);
await page.click(`${editorSelector} button.delete`);
await waitForSerialized(page, 0);

const twoToOne = Array.from(new Array(13).keys(), n => n + 2).concat(
Expand All @@ -421,7 +424,7 @@ describe("Ink Editor", () => {

await kbUndo(page);
await waitForSerialized(page, 1);
await page.waitForSelector(getEditorSelector(0));
await page.waitForSelector(editorSelector);
})
);
});
Expand Down Expand Up @@ -941,7 +944,6 @@ describe("Ink Editor", () => {

await page.waitForSelector(getEditorSelector(1));
await waitForSerialized(page, 1);
await page.waitForSelector(getEditorSelector(1));
await page.waitForSelector("#editorUndoBar", { hidden: true });
})
);
Expand Down

0 comments on commit bd67156

Please sign in to comment.