Skip to content

Commit

Permalink
add mention test
Browse files Browse the repository at this point in the history
  • Loading branch information
potatowagon committed May 23, 2024
1 parent 5b0bb73 commit ca2c4d2
Showing 1 changed file with 54 additions and 0 deletions.
54 changes: 54 additions & 0 deletions packages/lexical-playground/__tests__/e2e/Mentions.spec.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,8 @@
*
*/

import {$selectAll} from 'lexical';

import {
deleteNextWord,
moveLeft,
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,55 @@ 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');

$selectAll();

await pasteFromClipboard(page, {
'text/html':
'<meta charset="utf-8"><span data-lexical-mention="true">Luke Skywalker</span>',
});

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 ca2c4d2

Please sign in to comment.