Merge pull request #19277 from timvandermeij/integration-tests-remove-getselectededitors

Remove the `getSelectedEditors` integration test helper function
This commit is contained in:
Tim van der Meij 2025-01-04 13:21:45 +01:00 committed by GitHub
commit 7f5f4d0e66
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
3 changed files with 20 additions and 34 deletions

View File

@ -25,7 +25,6 @@ import {
getEditorSelector, getEditorSelector,
getFirstSerialized, getFirstSerialized,
getRect, getRect,
getSelectedEditors,
getSerialized, getSerialized,
hover, hover,
isCanvasWhite, isCanvasWhite,
@ -371,7 +370,7 @@ describe("FreeText Editor", () => {
`${getEditorSelector(8)} .overlay.enabled` `${getEditorSelector(8)} .overlay.enabled`
); );
expect(await getSelectedEditors(page)) expect(await getEditors(page, "selected"))
.withContext(`In ${browserName}`) .withContext(`In ${browserName}`)
.toEqual([8]); .toEqual([8]);
@ -387,7 +386,7 @@ describe("FreeText Editor", () => {
await waitForSelectedEditor(page, getEditorSelector(8)); await waitForSelectedEditor(page, getEditorSelector(8));
expect(await getSelectedEditors(page)) expect(await getEditors(page, "selected"))
.withContext(`In ${browserName}`) .withContext(`In ${browserName}`)
.toEqual([8]); .toEqual([8]);
@ -574,7 +573,7 @@ describe("FreeText Editor", () => {
await selectAll(page); await selectAll(page);
expect(await getSelectedEditors(page)) expect(await getEditors(page, "selected"))
.withContext(`In ${browserName}`) .withContext(`In ${browserName}`)
.toEqual([0, 1, 2, 3]); .toEqual([0, 1, 2, 3]);
@ -583,14 +582,14 @@ describe("FreeText Editor", () => {
await page.mouse.click(editorCenters[1].x, editorCenters[1].y); await page.mouse.click(editorCenters[1].x, editorCenters[1].y);
await waitForUnselectedEditor(page, getEditorSelector(1)); await waitForUnselectedEditor(page, getEditorSelector(1));
expect(await getSelectedEditors(page)) expect(await getEditors(page, "selected"))
.withContext(`In ${browserName}`) .withContext(`In ${browserName}`)
.toEqual([0, 2, 3]); .toEqual([0, 2, 3]);
await page.mouse.click(editorCenters[2].x, editorCenters[2].y); await page.mouse.click(editorCenters[2].x, editorCenters[2].y);
await waitForUnselectedEditor(page, getEditorSelector(2)); await waitForUnselectedEditor(page, getEditorSelector(2));
expect(await getSelectedEditors(page)) expect(await getEditors(page, "selected"))
.withContext(`In ${browserName}`) .withContext(`In ${browserName}`)
.toEqual([0, 3]); .toEqual([0, 3]);
@ -598,7 +597,7 @@ describe("FreeText Editor", () => {
await kbModifierUp(page); await kbModifierUp(page);
await waitForSelectedEditor(page, getEditorSelector(1)); await waitForSelectedEditor(page, getEditorSelector(1));
expect(await getSelectedEditors(page)) expect(await getEditors(page, "selected"))
.withContext(`In ${browserName}`) .withContext(`In ${browserName}`)
.toEqual([0, 1, 3]); .toEqual([0, 1, 3]);
@ -609,20 +608,20 @@ describe("FreeText Editor", () => {
}); });
// 0,1,3 are unselected and new pasted editors are selected. // 0,1,3 are unselected and new pasted editors are selected.
expect(await getSelectedEditors(page)) expect(await getEditors(page, "selected"))
.withContext(`In ${browserName}`) .withContext(`In ${browserName}`)
.toEqual([4, 5, 6]); .toEqual([4, 5, 6]);
// No ctrl here, hence all are unselected and 2 is selected. // No ctrl here, hence all are unselected and 2 is selected.
await page.mouse.click(editorCenters[2].x, editorCenters[2].y); await page.mouse.click(editorCenters[2].x, editorCenters[2].y);
await waitForSelectedEditor(page, getEditorSelector(2)); await waitForSelectedEditor(page, getEditorSelector(2));
expect(await getSelectedEditors(page)) expect(await getEditors(page, "selected"))
.withContext(`In ${browserName}`) .withContext(`In ${browserName}`)
.toEqual([2]); .toEqual([2]);
await page.mouse.click(editorCenters[1].x, editorCenters[1].y); await page.mouse.click(editorCenters[1].x, editorCenters[1].y);
await waitForSelectedEditor(page, getEditorSelector(1)); await waitForSelectedEditor(page, getEditorSelector(1));
expect(await getSelectedEditors(page)) expect(await getEditors(page, "selected"))
.withContext(`In ${browserName}`) .withContext(`In ${browserName}`)
.toEqual([1]); .toEqual([1]);
@ -630,7 +629,7 @@ describe("FreeText Editor", () => {
await page.mouse.click(editorCenters[3].x, editorCenters[3].y); await page.mouse.click(editorCenters[3].x, editorCenters[3].y);
await waitForSelectedEditor(page, getEditorSelector(3)); await waitForSelectedEditor(page, getEditorSelector(3));
expect(await getSelectedEditors(page)) expect(await getEditors(page, "selected"))
.withContext(`In ${browserName}`) .withContext(`In ${browserName}`)
.toEqual([1, 3]); .toEqual([1, 3]);
@ -646,7 +645,7 @@ describe("FreeText Editor", () => {
await selectAll(page); await selectAll(page);
expect(await getSelectedEditors(page)) expect(await getEditors(page, "selected"))
.withContext(`In ${browserName}`) .withContext(`In ${browserName}`)
.toEqual([0, 2, 4, 5, 6]); .toEqual([0, 2, 4, 5, 6]);
@ -658,14 +657,14 @@ describe("FreeText Editor", () => {
await page.waitForSelector(getEditorSelector(7), { await page.waitForSelector(getEditorSelector(7), {
visible: true, visible: true,
}); });
expect(await getSelectedEditors(page)) expect(await getEditors(page, "selected"))
.withContext(`In ${browserName}`) .withContext(`In ${browserName}`)
.toEqual([7]); .toEqual([7]);
// Set the focus to 2 and check that only 2 is selected. // Set the focus to 2 and check that only 2 is selected.
await page.mouse.click(editorCenters[2].x, editorCenters[2].y); await page.mouse.click(editorCenters[2].x, editorCenters[2].y);
await waitForSelectedEditor(page, getEditorSelector(2)); await waitForSelectedEditor(page, getEditorSelector(2));
expect(await getSelectedEditors(page)) expect(await getEditors(page, "selected"))
.withContext(`In ${browserName}`) .withContext(`In ${browserName}`)
.toEqual([2]); .toEqual([2]);
@ -677,7 +676,7 @@ describe("FreeText Editor", () => {
await page.waitForSelector(getEditorSelector(8), { await page.waitForSelector(getEditorSelector(8), {
visible: true, visible: true,
}); });
expect(await getSelectedEditors(page)) expect(await getEditors(page, "selected"))
.withContext(`In ${browserName}`) .withContext(`In ${browserName}`)
.toEqual([8]); .toEqual([8]);
// Dismiss it. // Dismiss it.
@ -692,7 +691,7 @@ describe("FreeText Editor", () => {
// Check that all the editors are correctly selected (and the focus // Check that all the editors are correctly selected (and the focus
// didn't move to the body when the empty editor was removed). // didn't move to the body when the empty editor was removed).
expect(await getSelectedEditors(page)) expect(await getEditors(page, "selected"))
.withContext(`In ${browserName}`) .withContext(`In ${browserName}`)
.toEqual([0, 2, 4, 5, 6]); .toEqual([0, 2, 4, 5, 6]);
} }

View File

@ -22,7 +22,6 @@ import {
getEditors, getEditors,
getEditorSelector, getEditorSelector,
getRect, getRect,
getSelectedEditors,
getSerialized, getSerialized,
isCanvasWhite, isCanvasWhite,
kbRedo, kbRedo,
@ -101,7 +100,7 @@ describe("Ink Editor", () => {
await kbUndo(page); await kbUndo(page);
await waitForStorageEntries(page, 3); await waitForStorageEntries(page, 3);
expect(await getSelectedEditors(page)) expect(await getEditors(page, "selected"))
.withContext(`In ${browserName}`) .withContext(`In ${browserName}`)
.toEqual([]); .toEqual([]);
}) })
@ -180,7 +179,7 @@ describe("Ink Editor", () => {
await selectAll(page); await selectAll(page);
expect(await getSelectedEditors(page)) expect(await getEditors(page, "selected"))
.withContext(`In ${browserName}`) .withContext(`In ${browserName}`)
.toEqual([0]); .toEqual([0]);
}) })
@ -487,7 +486,7 @@ describe("Ink Editor", () => {
await page.mouse.move(xStart, yStart); await page.mouse.move(xStart, yStart);
await page.mouse.down(); await page.mouse.down();
if (i === 1) { if (i === 1) {
expect(await getSelectedEditors(page)) expect(await getEditors(page, "selected"))
.withContext(`In ${browserName}`) .withContext(`In ${browserName}`)
.toEqual([]); .toEqual([]);
} }

View File

@ -229,18 +229,6 @@ function getAnnotationSelector(id) {
return `[data-annotation-id="${id}"]`; return `[data-annotation-id="${id}"]`;
} }
function getSelectedEditors(page) {
return page.evaluate(() => {
const elements = document.querySelectorAll(".selectedEditor");
const results = [];
for (const { id } of elements) {
results.push(parseInt(id.split("_").at(-1)));
}
results.sort();
return results;
});
}
async function getSpanRectFromText(page, pageNumber, text) { async function getSpanRectFromText(page, pageNumber, text) {
await page.waitForSelector( await page.waitForSelector(
`.page[data-page-number="${pageNumber}"] > .textLayer .endOfContent` `.page[data-page-number="${pageNumber}"] > .textLayer .endOfContent`
@ -479,8 +467,9 @@ function getEditors(page, kind) {
const elements = document.querySelectorAll(`.${aKind}Editor`); const elements = document.querySelectorAll(`.${aKind}Editor`);
const results = []; const results = [];
for (const { id } of elements) { for (const { id } of elements) {
results.push(id); results.push(parseInt(id.split("_").at(-1)));
} }
results.sort();
return results; return results;
}, kind); }, kind);
} }
@ -853,7 +842,6 @@ export {
getFirstSerialized, getFirstSerialized,
getQuerySelector, getQuerySelector,
getRect, getRect,
getSelectedEditors,
getSelector, getSelector,
getSerialized, getSerialized,
getSpanRectFromText, getSpanRectFromText,