Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[lexical-playground] Chore: add test for pasting over mentions #6024

Merged
merged 3 commits into from
May 29, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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],
});
});
});
Loading