Skip to content

Commit

Permalink
[lexical-playground] Chore: add test for pasting over mentions (#6024)
Browse files Browse the repository at this point in the history
  • Loading branch information
potatowagon authored May 29, 2024
1 parent 1a129e7 commit 8c0ef8e
Showing 1 changed file with 56 additions and 0 deletions.
56 changes: 56 additions & 0 deletions packages/lexical-playground/__tests__/e2e/Mentions.spec.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,9 @@
import {
deleteNextWord,
moveLeft,
moveRight,
moveToEditorBeginning,
selectAll,
} from '../keyboardShortcuts/index.mjs';
import {
assertHTML,
Expand All @@ -18,6 +20,7 @@ import {
html,
initialize,
IS_WINDOWS,
pasteFromClipboard,
test,
waitForSelector,
} from '../utils/index.mjs';
Expand Down Expand Up @@ -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':
'<meta charset="utf-8"><span data-lexical-mention="true">Luke Skywalker</span>',
});

await moveRight(page, 2);

await page.keyboard.type(' foo bar');

await assertHTML(
page,
html`
<p
class="PlaygroundEditorTheme__paragraph PlaygroundEditorTheme__ltr"
dir="ltr">
<span
class="mention"
style="background-color: rgba(24, 119, 232, 0.2);"
data-lexical-text="true">
Luke Skywalker
</span>
<span data-lexical-text="true">foo bar</span>
</p>
`,
);
await assertSelection(page, {
anchorOffset: 8,
anchorPath: [0, 1, 0],
focusOffset: 8,
focusPath: [0, 1, 0],
});
});
});

0 comments on commit 8c0ef8e

Please sign in to comment.