From f010565a754c144b04c5fedb414c8b712d289663 Mon Sep 17 00:00:00 2001 From: umaranis Date: Thu, 7 Dec 2023 05:44:55 +1100 Subject: [PATCH] test: list merging --- .../src/__tests__/e2e/CopyAndPaste.spec.mjs | 248 +++++++++++++++--- 1 file changed, 205 insertions(+), 43 deletions(-) diff --git a/demos/playground/src/__tests__/e2e/CopyAndPaste.spec.mjs b/demos/playground/src/__tests__/e2e/CopyAndPaste.spec.mjs index 35ac097..61af85b 100644 --- a/demos/playground/src/__tests__/e2e/CopyAndPaste.spec.mjs +++ b/demos/playground/src/__tests__/e2e/CopyAndPaste.spec.mjs @@ -5,7 +5,7 @@ * LICENSE file in the root directory of this source tree. * */ -import {expect} from '@playwright/test'; +import { expect } from '@playwright/test'; import { extendToNextWord, @@ -42,8 +42,8 @@ import { } from '../utils/index.mjs'; test.describe('CopyAndPaste', () => { - test.beforeEach(({isCollab, page}) => initialize({isCollab, page})); - test('Basic copy + paste', async ({isRichText, page, browserName}) => { + test.beforeEach(({ isCollab, page }) => initialize({ isCollab, page })); + test('Basic copy + paste', async ({ isRichText, page, browserName }) => { await focusEditor(page); // Add paragraph @@ -256,7 +256,7 @@ test.describe('CopyAndPaste', () => { test.fixme( `Copy and paste heading`, - async ({isPlainText, page, browserName}) => { + async ({ isPlainText, page, browserName }) => { test.skip(isPlainText); await focusEditor(page); @@ -309,7 +309,7 @@ test.describe('CopyAndPaste', () => { test.fixme( `Copy and paste between sections`, - async ({isRichText, page, browserName}) => { + async ({ isRichText, page, browserName }) => { await focusEditor(page); await page.keyboard.type('Hello world #foobar test #foobar2 when #not'); @@ -789,7 +789,7 @@ test.describe('CopyAndPaste', () => { test.fixme( 'Copy and paste of partial list items into an empty editor', - async ({page, isPlainText}) => { + async ({ page, isPlainText }) => { test.skip(isPlainText); await focusEditor(page); @@ -869,7 +869,7 @@ test.describe('CopyAndPaste', () => { test.fixme( 'Copy and paste of partial list items into the list', - async ({page, isPlainText, isCollab, browserName}) => { + async ({ page, isPlainText, isCollab, browserName }) => { test.skip(isPlainText); await focusEditor(page); @@ -1045,7 +1045,7 @@ test.describe('CopyAndPaste', () => { test.fixme( 'Copy list items and paste back into list', - async ({page, isPlainText, isCollab}) => { + async ({ page, isPlainText, isCollab }) => { test.skip(isPlainText); await focusEditor(page); @@ -1112,7 +1112,7 @@ test.describe('CopyAndPaste', () => { test.fixme( 'Copy list items and paste into list', - async ({page, isPlainText, isCollab}) => { + async ({ page, isPlainText, isCollab }) => { test.skip(isPlainText); await focusEditor(page); @@ -1298,7 +1298,7 @@ test.describe('CopyAndPaste', () => { test.fixme( 'Copy and paste of list items and paste back into list on an existing item', - async ({page, isPlainText, isCollab}) => { + async ({ page, isPlainText, isCollab }) => { test.skip(isPlainText); await focusEditor(page); @@ -1363,9 +1363,171 @@ test.describe('CopyAndPaste', () => { }, ); + test('Copy list of a different type and paste into list on an existing item - should merge the lists.', async ({ + page, + isPlainText, + isCollab, + }) => { + test.skip(isPlainText); + + await focusEditor(page); + + await page.keyboard.type('- one'); + await page.keyboard.press('Enter'); + await page.keyboard.type('two'); + await page.keyboard.press('Tab'); + await page.keyboard.press('Enter'); + await page.keyboard.type('a'); + + await page.keyboard.press('Enter'); + await page.keyboard.press('Enter'); + await page.keyboard.press('Enter'); + await page.keyboard.press('Enter'); + + await page.keyboard.type('1. four'); + await page.keyboard.press('Enter'); + await page.keyboard.type('five'); + await page.keyboard.press('Tab'); + + await page.keyboard.press('ArrowUp'); + + await moveToLineBeginning(page); + await page.keyboard.down('Shift'); + await page.keyboard.press('ArrowDown'); + await page.keyboard.press('ArrowDown'); + await page.keyboard.up('Shift'); + + await assertHTML( + page, + html` + +


+
    +
  1. + four +
  2. +
  3. +
      +
    1. + five +
    2. +
    +
  4. +
+ `, + ); + + const clipboard = await copyToClipboard(page); + + await page.keyboard.press('ArrowLeft'); + await page.keyboard.press('ArrowLeft'); + await page.keyboard.press('ArrowLeft'); + await page.keyboard.press('Backspace'); + + await pasteFromClipboard(page, clipboard); + + await assertHTML( + page, + html` + +


+
    +
  1. + four +
  2. +
  3. +
      +
    1. + five +
    2. +
    +
  4. +
+ `, + ); + }); + test.fixme( 'Copy and paste two paragraphs into list on an existing item', - async ({page, isPlainText}) => { + async ({ page, isPlainText }) => { test.skip(isPlainText); await focusEditor(page); @@ -1425,7 +1587,7 @@ test.describe('CopyAndPaste', () => { test.fixme( 'Copy and paste two paragraphs at the end of a list', - async ({page, isPlainText}) => { + async ({ page, isPlainText }) => { test.skip(isPlainText); await focusEditor(page); @@ -1481,7 +1643,7 @@ test.describe('CopyAndPaste', () => { test.fixme( 'Copy and paste an inline element into a leaf node', - async ({page, isPlainText}) => { + async ({ page, isPlainText }) => { test.skip(isPlainText); await focusEditor(page); @@ -1541,7 +1703,7 @@ test.describe('CopyAndPaste', () => { await focusEditor(page); - const clipboard = {'text/html': 'Hello!'}; + const clipboard = { 'text/html': 'Hello!' }; await pasteFromClipboard(page, clipboard); @@ -1563,12 +1725,12 @@ test.describe('CopyAndPaste', () => { }); }); - test('HTML Copy + paste a paragraph element', async ({page, isPlainText}) => { + test('HTML Copy + paste a paragraph element', async ({ page, isPlainText }) => { test.skip(isPlainText); await focusEditor(page); - const clipboard = {'text/html': '

Hello!

'}; + const clipboard = { 'text/html': '

Hello!

' }; await pasteFromClipboard(page, clipboard); @@ -1592,7 +1754,7 @@ test.describe('CopyAndPaste', () => { }); }); - test('HTML Copy + paste an anchor element', async ({page, isPlainText}) => { + test('HTML Copy + paste an anchor element', async ({ page, isPlainText }) => { test.skip(isPlainText); await focusEditor(page); @@ -1659,12 +1821,12 @@ test.describe('CopyAndPaste', () => { ); }); - test('HTML Copy + paste a list element', async ({page, isPlainText}) => { + test('HTML Copy + paste a list element', async ({ page, isPlainText }) => { test.skip(isPlainText); await focusEditor(page); - const clipboard = {'text/html': '

'}; + const clipboard = { 'text/html': '' }; await pasteFromClipboard(page, clipboard); @@ -1718,7 +1880,7 @@ test.describe('CopyAndPaste', () => { test.fixme( 'HTML Copy + paste (Nested List - directly nested ul)', - async ({page, isPlainText}) => { + async ({ page, isPlainText }) => { test.skip(isPlainText); await focusEditor(page); @@ -1824,7 +1986,7 @@ test.describe('CopyAndPaste', () => { test.fixme( 'HTML Copy + paste (Nested List - li with non-list content plus ul child)', - async ({page, isPlainText}) => { + async ({ page, isPlainText }) => { test.skip(isPlainText); await focusEditor(page); @@ -1924,7 +2086,7 @@ test.describe('CopyAndPaste', () => { test.fixme( 'HTML Copy + paste (Table - Google Docs)', - async ({page, isPlainText, isCollab}) => { + async ({ page, isPlainText, isCollab }) => { test.skip(isPlainText); test.fixme( @@ -2003,7 +2165,7 @@ test.describe('CopyAndPaste', () => { test.fixme( 'HTML Copy + paste (Table - Quip)', - async ({page, isPlainText}) => { + async ({ page, isPlainText }) => { test.skip(isPlainText); await focusEditor(page); @@ -2077,7 +2239,7 @@ test.describe('CopyAndPaste', () => { test.fixme( 'HTML Copy + paste (Table - Google Sheets)', - async ({page, isPlainText}) => { + async ({ page, isPlainText }) => { test.skip(isPlainText); await focusEditor(page); @@ -2151,7 +2313,7 @@ test.describe('CopyAndPaste', () => { test.fixme( 'Merge Grids on Copy + paste', - async ({page, isPlainText, isCollab}) => { + async ({ page, isPlainText, isCollab }) => { test.skip(isPlainText); await focusEditor(page); @@ -2163,8 +2325,8 @@ test.describe('CopyAndPaste', () => { await selectCellsFromTableCords( page, - {x: 0, y: 0}, - {x: 3, y: 3}, + { x: 0, y: 0 }, + { x: 3, y: 3 }, true, false, ); @@ -2390,8 +2552,8 @@ test.describe('CopyAndPaste', () => { // Explicitly checking inner text, since regular assertHTML will prettify it and strip all // extra newlines, which makes this test less acurate - await expect(paragraphs.nth(0)).toHaveText('Hello', {useInnerText: true}); - await expect(paragraphs.nth(1)).toHaveText('World', {useInnerText: true}); + await expect(paragraphs.nth(0)).toHaveText('Hello', { useInnerText: true }); + await expect(paragraphs.nth(1)).toHaveText('World', { useInnerText: true }); await expect(paragraphs.nth(2)).toHaveText('Hello World !', { useInnerText: true, }); @@ -2402,7 +2564,7 @@ test.describe('CopyAndPaste', () => { test.fixme( 'HTML Copy + paste in front of or after a link', - async ({page, isPlainText}) => { + async ({ page, isPlainText }) => { test.skip(isPlainText); await focusEditor(page); await pasteFromClipboard(page, { @@ -2438,7 +2600,7 @@ test.describe('CopyAndPaste', () => { test.fixme( 'HTML Copy + paste link by selecting its (partial) content', - async ({page, isPlainText}) => { + async ({ page, isPlainText }) => { test.skip(isPlainText); await focusEditor(page); await pasteFromClipboard(page, { @@ -2480,7 +2642,7 @@ test.describe('CopyAndPaste', () => { test.fixme( 'Copy + paste multi-line plain text into rich text produces separate paragraphs', - async ({page, isPlainText}) => { + async ({ page, isPlainText }) => { test.skip(isPlainText); await focusEditor(page); await page.keyboard.type('# Hello '); @@ -2640,7 +2802,7 @@ test.describe('CopyAndPaste', () => { ); }); - test('HTML Copy + paste a checklist', async ({page, isPlainText}) => { + test('HTML Copy + paste a checklist', async ({ page, isPlainText }) => { test.skip(isPlainText); await focusEditor(page); @@ -2716,7 +2878,7 @@ test.describe('CopyAndPaste', () => { test.fixme( 'HTML Copy + paste a code block with BR', - async ({page, isPlainText}) => { + async ({ page, isPlainText }) => { test.skip(isPlainText); await focusEditor(page); @@ -2805,7 +2967,7 @@ test.describe('CopyAndPaste', () => { test.fixme( 'HTML Copy + paste empty link #3193', - async ({page, isPlainText}) => { + async ({ page, isPlainText }) => { test.skip(isPlainText); await focusEditor(page); @@ -2853,7 +3015,7 @@ test.describe('CopyAndPaste', () => { }, ); - test.fixme('HTML Paste a link into text', async ({page, isPlainText}) => { + test.fixme('HTML Paste a link into text', async ({ page, isPlainText }) => { test.skip(isPlainText); await focusEditor(page); @@ -2890,7 +3052,7 @@ test.describe('CopyAndPaste', () => { ); }); - test.fixme('HTML Copy + paste an image', async ({page, isPlainText}) => { + test.fixme('HTML Copy + paste an image', async ({ page, isPlainText }) => { test.skip(isPlainText); await focusEditor(page); @@ -2932,7 +3094,7 @@ test.describe('CopyAndPaste', () => { test.fixme( 'HTML Copy + paste + undo multiple image', - async ({page, isPlainText}) => { + async ({ page, isPlainText }) => { test.skip(isPlainText); await focusEditor(page); @@ -2990,12 +3152,12 @@ test.describe('CopyAndPaste', () => { test.fixme( 'HTML Copy + paste a paragraph element between horizontal rules', - async ({page, isPlainText, isCollab}) => { + async ({ page, isPlainText, isCollab }) => { test.skip(isPlainText); await focusEditor(page); - let clipboard = {'text/html': '

'}; + let clipboard = { 'text/html': '

' }; await pasteFromClipboard(page, clipboard); // Collab doesn't process the cursor correctly @@ -3024,7 +3186,7 @@ test.describe('CopyAndPaste', () => { // sets focus between HRs await page.keyboard.press('ArrowRight'); - clipboard = {'text/html': '

Text between HRs

'}; + clipboard = { 'text/html': '

Text between HRs

' }; await pasteFromClipboard(page, clipboard); await assertHTML( @@ -3051,7 +3213,7 @@ test.describe('CopyAndPaste', () => { test.fixme( 'Paste top level element in the middle of paragraph', - async ({page, isPlainText, isCollab}) => { + async ({ page, isPlainText, isCollab }) => { test.skip(isPlainText || isCollab); await focusEditor(page); await page.keyboard.type('Hello world'); @@ -3081,7 +3243,7 @@ test.describe('CopyAndPaste', () => { test.fixme( 'Paste top level element in the middle of list', - async ({page, isPlainText, isCollab}) => { + async ({ page, isPlainText, isCollab }) => { test.skip(isPlainText || isCollab); await focusEditor(page); // Add three list items