From ed51962181fa520f3b6a4a5d0ab62d410a72522b Mon Sep 17 00:00:00 2001 From: umaranis Date: Wed, 6 Dec 2023 21:04:25 +1100 Subject: [PATCH] test: table cell merge --- .../src/__tests__/e2e/Tables.spec.mjs | 173 ++++++++++++++++-- .../playground/src/__tests__/utils/index.mjs | 4 + demos/playground/src/settings/appSettings.ts | 4 +- 3 files changed, 169 insertions(+), 12 deletions(-) diff --git a/demos/playground/src/__tests__/e2e/Tables.spec.mjs b/demos/playground/src/__tests__/e2e/Tables.spec.mjs index 3429b33..7c80e85 100644 --- a/demos/playground/src/__tests__/e2e/Tables.spec.mjs +++ b/demos/playground/src/__tests__/e2e/Tables.spec.mjs @@ -64,11 +64,12 @@ async function fillTablePartiallyWithText(page) { test.describe('Tables', () => { test.fixme(); - test.beforeEach(({ isCollab, page }) => initialize({ isCollab, page })); test(`Can a table be inserted from the toolbar`, async ({ page, isPlainText, + isCollab, }) => { + await initialize({ isCollab, page }); test.skip(isPlainText); await focusEditor(page); @@ -103,7 +104,12 @@ test.describe('Tables', () => { ); }); - test(`Can type inside of table cell`, async ({ page, isPlainText }) => { + test(`Can type inside of table cell`, async ({ + page, + isPlainText, + isCollab, + }) => { + await initialize({ isCollab, page }); test.skip(isPlainText); await focusEditor(page); @@ -140,7 +146,12 @@ test.describe('Tables', () => { ); }); - test(`Can navigate table with keyboard`, async ({ page, isPlainText }) => { + test(`Can navigate table with keyboard`, async ({ + page, + isPlainText, + isCollab, + }) => { + await initialize({ isCollab, page }); test.skip(isPlainText); await focusEditor(page); @@ -186,7 +197,9 @@ test.describe('Tables', () => { test(`Can select cells using Table selection`, async ({ page, isPlainText, + isCollab, }) => { + await initialize({ isCollab, page }); test.skip(isPlainText); await focusEditor(page); @@ -270,7 +283,9 @@ test.describe('Tables', () => { test(`Can select cells using Table selection via keyboard`, async ({ page, isPlainText, + isCollab, }) => { + await initialize({ isCollab, page }); test.skip(isPlainText); await focusEditor(page); @@ -385,7 +400,12 @@ test.describe('Tables', () => { ); }); - test(`Can style text using Table selection`, async ({ page, isPlainText }) => { + test(`Can style text using Table selection`, async ({ + page, + isPlainText, + isCollab, + }) => { + await initialize({ isCollab, page }); test.skip(isPlainText); await focusEditor(page); @@ -474,7 +494,9 @@ test.describe('Tables', () => { test(`Can copy + paste (internal) using Table selection`, async ({ page, isPlainText, + isCollab, }) => { + await initialize({ isCollab, page }); test.skip(isPlainText); await focusEditor(page); @@ -551,7 +573,12 @@ test.describe('Tables', () => { ); }); - test(`Can clear text using Table selection`, async ({ page, isPlainText }) => { + test(`Can clear text using Table selection`, async ({ + page, + isPlainText, + isCollab, + }) => { + await initialize({ isCollab, page }); test.skip(isPlainText); await focusEditor(page); @@ -609,6 +636,7 @@ test.describe('Tables', () => { isPlainText, isCollab, }) => { + await initialize({ isCollab, page }); test.skip(isPlainText); await focusEditor(page); @@ -660,6 +688,7 @@ test.describe('Tables', () => { isPlainText, isCollab, }) => { + await initialize({ isCollab, page }); test.skip(isPlainText); await focusEditor(page); @@ -737,7 +766,8 @@ test.describe('Tables', () => { ); }); - test(`Horizontal rule inside cell`, async ({ page, isPlainText }) => { + test(`Horizontal rule inside cell`, async ({ page, isPlainText, isCollab }) => { + await initialize({ isCollab, page }); test.skip(isPlainText); await focusEditor(page); @@ -771,7 +801,9 @@ test.describe('Tables', () => { test('Grid selection: can select multiple cells and insert an image', async ({ page, isPlainText, + isCollab, }) => { + await initialize({ isCollab, page }); test.skip(isPlainText); await focusEditor(page); @@ -845,7 +877,9 @@ test.describe('Tables', () => { test('Grid selection: can backspace lines, backspacing empty cell does not destroy it #3278', async ({ page, isPlainText, + isCollab, }) => { + await initialize({ isCollab, page }); test.skip(isPlainText); await focusEditor(page); @@ -918,7 +952,8 @@ test.describe('Tables', () => { ); }); - test('Merge/unmerge cells (1)', async ({ page, isPlainText }) => { + test('Merge/unmerge cells (1)', async ({ page, isPlainText, isCollab }) => { + await initialize({ isCollab, page }); test.skip(isPlainText); if (IS_COLLAB) { // The contextual menu positioning needs fixing (it's hardcoded to show on the right side) @@ -1004,7 +1039,8 @@ test.describe('Tables', () => { ); }); - test('Merge/unmerge cells (2)', async ({ page, isPlainText }) => { + test('Merge/unmerge cells (2)', async ({ page, isPlainText, isCollab }) => { + await initialize({ isCollab, page }); test.skip(isPlainText); if (IS_COLLAB) { // The contextual menu positioning needs fixing (it's hardcoded to show on the right side) @@ -1130,7 +1166,8 @@ test.describe('Tables', () => { ); }); - test('Merge with content', async ({ page, isPlainText }) => { + test('Merge with content', async ({ page, isPlainText, isCollab }) => { + await initialize({ isCollab, page }); test.skip(isPlainText); if (IS_COLLAB) { // The contextual menu positioning needs fixing (it's hardcoded to show on the right side) @@ -1223,7 +1260,9 @@ test.describe('Tables', () => { test('Select multiple merged cells (selection expands to a rectangle)', async ({ page, isPlainText, + isCollab, }) => { + await initialize({ isCollab, page }); test.skip(isPlainText); await focusEditor(page); @@ -1349,7 +1388,9 @@ test.describe('Tables', () => { test('Insert row above (with conflicting merged cell)', async ({ page, isPlainText, + isCollab, }) => { + await initialize({ isCollab, page }); test.skip(isPlainText); if (IS_COLLAB) { // The contextual menu positioning needs fixing (it's hardcoded to show on the right side) @@ -1407,7 +1448,9 @@ test.describe('Tables', () => { test('Insert column before (with conflicting merged cell)', async ({ page, isPlainText, + isCollab, }) => { + await initialize({ isCollab, page }); test.skip(isPlainText); if (IS_COLLAB) { // The contextual menu positioning needs fixing (it's hardcoded to show on the right side) @@ -1465,7 +1508,9 @@ test.describe('Tables', () => { test('Insert column before (with selected cell with rowspan > 1)', async ({ page, isPlainText, + isCollab, }) => { + await initialize({ isCollab, page }); test.skip(isPlainText); if (IS_COLLAB) { // The contextual menu positioning needs fixing (it's hardcoded to show on the right side) @@ -1486,7 +1531,6 @@ test.describe('Tables', () => { ); await mergeTableCells(page); await insertTableColumnBefore(page); - await page.pause(); await assertHTML( page, @@ -1517,7 +1561,9 @@ test.describe('Tables', () => { test('Delete rows (with conflicting merged cell)', async ({ page, isPlainText, + isCollab, }) => { + await initialize({ isCollab, page }); test.skip(isPlainText); if (IS_COLLAB) { // The contextual menu positioning needs fixing (it's hardcoded to show on the right side) @@ -1576,7 +1622,9 @@ test.describe('Tables', () => { test('Delete columns (with conflicting merged cell)', async ({ page, isPlainText, + isCollab, }) => { + await initialize({ isCollab, page }); test.skip(isPlainText); if (IS_COLLAB) { // The contextual menu positioning needs fixing (it's hardcoded to show on the right side) @@ -1635,7 +1683,9 @@ test.describe('Tables', () => { test('Deselect when click outside #3785 #4138', async ({ page, isPlainText, + isCollab, }) => { + await initialize({ isCollab, page }); test.skip(isPlainText); if (IS_COLLAB) { // The contextual menu positioning needs fixing (it's hardcoded to show on the right side) @@ -1658,7 +1708,8 @@ test.describe('Tables', () => { }); }); - test('Background color to cell', async ({ page, isPlainText }) => { + test('Background color to cell', async ({ page, isPlainText, isCollab }) => { + await initialize({ isCollab, page }); test.skip(isPlainText); if (IS_COLLAB) { // The contextual menu positioning needs fixing (it's hardcoded to show on the right side) @@ -1689,4 +1740,104 @@ test.describe('Tables', () => { `, ); }); + + test('Cell merge feature disabled', async ({ page, isPlainText, isCollab }) => { + await initialize({ isCollab, page, tableCellMerge: false }); + test.skip(isPlainText); + + await focusEditor(page); + await pasteFromClipboard(page, { + 'text/html': `
+ + + + + + + + + + + + + + + +
+

Hello world

+
+

a

+
+

b

+
+

c

+
+

d

+
+

e

+
+
`, + }); + + await page.pause(); + + await assertHTML( + page, + html` + + + + + + + + + + + + + + + + +
+

+ Hello world +

+

+

+ a +

+


+

+ b +

+
+

+ c +

+
+

+ d +

+
+

+ e +

+
+ `, + ); + }); }); diff --git a/demos/playground/src/__tests__/utils/index.mjs b/demos/playground/src/__tests__/utils/index.mjs index e9236e2..41480b9 100644 --- a/demos/playground/src/__tests__/utils/index.mjs +++ b/demos/playground/src/__tests__/utils/index.mjs @@ -42,6 +42,7 @@ export async function initialize({ isCharLimitUtf8, isMaxLength, showNestedEditorTreeView, + tableCellMerge, }) { const appSettings = {}; appSettings.isRichText = IS_RICH_TEXT; @@ -58,6 +59,9 @@ export async function initialize({ appSettings.isCharLimit = !!isCharLimit; appSettings.isCharLimitUtf8 = !!isCharLimitUtf8; appSettings.isMaxLength = !!isMaxLength; + if (tableCellMerge !== undefined) { + appSettings.tableCellMerge = tableCellMerge; + } const urlParams = appSettingsToURLParams(appSettings); const url = `http://localhost:${E2E_PORT}/${isCollab ? 'split/' : '' diff --git a/demos/playground/src/settings/appSettings.ts b/demos/playground/src/settings/appSettings.ts index 42034a9..fdcbc7c 100644 --- a/demos/playground/src/settings/appSettings.ts +++ b/demos/playground/src/settings/appSettings.ts @@ -18,7 +18,8 @@ export type SettingName = | 'showTreeView' | 'showNestedEditorTreeView' | 'emptyEditor' - | 'showTableOfContents'; + | 'showTableOfContents' + | 'tableCellMerge'; export type Settings = Record; @@ -41,4 +42,5 @@ export const DEFAULT_SETTINGS: Settings = { showNestedEditorTreeView: false, showTableOfContents: false, showTreeView: true, + tableCellMerge: true, };