diff --git a/packages/lexical-playground/__tests__/e2e/Mentions.spec.mjs b/packages/lexical-playground/__tests__/e2e/Mentions.spec.mjs index 756790f6670..197f106a132 100644 --- a/packages/lexical-playground/__tests__/e2e/Mentions.spec.mjs +++ b/packages/lexical-playground/__tests__/e2e/Mentions.spec.mjs @@ -9,7 +9,9 @@ import { deleteNextWord, moveLeft, + moveRight, moveToEditorBeginning, + selectAll, } from '../keyboardShortcuts/index.mjs'; import { assertHTML, @@ -18,6 +20,7 @@ import { html, initialize, IS_WINDOWS, + pasteFromClipboard, test, waitForSelector, } from '../utils/index.mjs'; @@ -930,4 +933,57 @@ test.describe('Mentions', () => { focusPath: [0, 0, 0], }); }); + + test(`Pasting over a mention does not lead to crash`, async ({page}) => { + await focusEditor(page); + await page.keyboard.type('@Luke'); + await assertSelection(page, { + anchorOffset: 5, + anchorPath: [0, 0, 0], + focusOffset: 5, + focusPath: [0, 0, 0], + }); + + await waitForSelector( + page, + '#typeahead-menu ul li:has-text("Luke Skywalker")', + ); + await page.keyboard.press('Enter'); + + await waitForSelector(page, '.mention'); + + await selectAll(page); + + await pasteFromClipboard(page, { + 'text/html': + 'Luke Skywalker', + }); + + await moveRight(page, 2); + + await page.keyboard.type(' foo bar'); + + await assertHTML( + page, + html` +
+ + Luke Skywalker + + foo bar +
+ `, + ); + await assertSelection(page, { + anchorOffset: 8, + anchorPath: [0, 1, 0], + focusOffset: 8, + focusPath: [0, 1, 0], + }); + }); });