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] Move more tests related to Copy Paste from e2e to unit #6181

Merged
merged 2 commits into from
May 28, 2024
Merged
Show file tree
Hide file tree
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
Original file line number Diff line number Diff line change
Expand Up @@ -22,62 +22,6 @@ import {
test.describe('HTML CopyAndPaste', () => {
test.beforeEach(({isCollab, page}) => initialize({isCollab, page}));

test('Copy + paste a plain DOM text node', async ({page, isPlainText}) => {
test.skip(isPlainText);

await focusEditor(page);

const clipboard = {'text/html': 'Hello!'};

await pasteFromClipboard(page, clipboard);

await assertHTML(
page,
html`
<p
class="PlaygroundEditorTheme__paragraph PlaygroundEditorTheme__ltr"
dir="ltr">
<span data-lexical-text="true">Hello!</span>
</p>
`,
);
await assertSelection(page, {
anchorOffset: 6,
anchorPath: [0, 0, 0],
focusOffset: 6,
focusPath: [0, 0, 0],
});
});

test('Copy + paste a paragraph element', async ({page, isPlainText}) => {
test.skip(isPlainText);

await focusEditor(page);

const clipboard = {'text/html': '<p>Hello!<p>'};

await pasteFromClipboard(page, clipboard);

await assertHTML(
page,
html`
<p
class="PlaygroundEditorTheme__paragraph PlaygroundEditorTheme__ltr"
dir="ltr">
<span data-lexical-text="true">Hello!</span>
</p>
<p class="PlaygroundEditorTheme__paragraph"><br /></p>
`,
);

await assertSelection(page, {
anchorOffset: 0,
anchorPath: [1],
focusOffset: 0,
focusPath: [1],
});
});

test('Copy + paste multi line html with extra newlines', async ({
page,
isPlainText,
Expand Down Expand Up @@ -290,229 +234,4 @@ test.describe('HTML CopyAndPaste', () => {
`,
);
});

test('Copy + paste single div', async ({page, isPlainText}) => {
test.skip(isPlainText);

await focusEditor(page);

const clipboard = {
'text/html': `
123
<div>
456
</div>`,
};

await pasteFromClipboard(page, clipboard);

await assertHTML(
page,
html`
<p class="PlaygroundEditorTheme__paragraph">
<span data-lexical-text="true">123</span>
</p>
<p class="PlaygroundEditorTheme__paragraph">
<span data-lexical-text="true">456</span>
</p>
`,
);
await assertSelection(page, {
anchorOffset: 3,
anchorPath: [1, 0, 0],
focusOffset: 3,
focusPath: [1, 0, 0],
});
});

test('Copy + paste nested divs', async ({page, isPlainText}) => {
test.skip(isPlainText);

await focusEditor(page);

const clipboard = {
'text/html': html`
<div>
a
<div>
b b
<div>
c
<div>
<div></div>
z
</div>
</div>
d e
</div>
fg
</div>
`,
};

await pasteFromClipboard(page, clipboard);

await assertHTML(
page,
html`
<p
class="PlaygroundEditorTheme__paragraph PlaygroundEditorTheme__ltr"
dir="ltr">
<span data-lexical-text="true">a</span>
</p>
<p
class="PlaygroundEditorTheme__paragraph PlaygroundEditorTheme__ltr"
dir="ltr">
<span data-lexical-text="true">b b</span>
</p>
<p
class="PlaygroundEditorTheme__paragraph PlaygroundEditorTheme__ltr"
dir="ltr">
<span data-lexical-text="true">c</span>
</p>
<p
class="PlaygroundEditorTheme__paragraph PlaygroundEditorTheme__ltr"
dir="ltr">
<span data-lexical-text="true">z</span>
</p>
<p
class="PlaygroundEditorTheme__paragraph PlaygroundEditorTheme__ltr"
dir="ltr">
<span data-lexical-text="true">d e</span>
</p>
<p
class="PlaygroundEditorTheme__paragraph PlaygroundEditorTheme__ltr"
dir="ltr">
<span data-lexical-text="true">fg</span>
</p>
`,
);
await assertSelection(page, {
anchorOffset: 2,
anchorPath: [5, 0, 0],
focusOffset: 2,
focusPath: [5, 0, 0],
});
});

test('Copy + paste nested div in a span', async ({page, isPlainText}) => {
test.skip(isPlainText);

await focusEditor(page);

const clipboard = {
'text/html': html`
<span>
123
<div>456</div>
</span>
`,
};

await pasteFromClipboard(page, clipboard);

await assertHTML(
page,
html`
<p class="PlaygroundEditorTheme__paragraph">
<span data-lexical-text="true">123</span>
</p>
<p class="PlaygroundEditorTheme__paragraph">
<span data-lexical-text="true">456</span>
</p>
`,
);
await assertSelection(page, {
anchorOffset: 3,
anchorPath: [1, 0, 0],
focusOffset: 3,
focusPath: [1, 0, 0],
});
});

test('Copy + paste nested span in a div', async ({page, isPlainText}) => {
test.skip(isPlainText);

await focusEditor(page);

const clipboard = {
'text/html': html`
<div>
<span>
123
<div>456</div>
</span>
</div>
`,
};

await pasteFromClipboard(page, clipboard);

await assertHTML(
page,
html`
<p class="PlaygroundEditorTheme__paragraph">
<span data-lexical-text="true">123</span>
</p>
<p class="PlaygroundEditorTheme__paragraph">
<span data-lexical-text="true">456</span>
</p>
`,
);
await assertSelection(page, {
anchorOffset: 3,
anchorPath: [1, 0, 0],
focusOffset: 3,
focusPath: [1, 0, 0],
});
});

test('Copy + paste multiple nested spans and divs', async ({
page,
isPlainText,
}) => {
test.skip(isPlainText);

await focusEditor(page);

const clipboard = {
'text/html': html`
<div>
a b
<span>
c d
<span>e</span>
</span>
<div>
f
<span>g h</span>
</div>
</div>
`,
};

await pasteFromClipboard(page, clipboard);

await assertHTML(
page,
html`
<p
class="PlaygroundEditorTheme__paragraph PlaygroundEditorTheme__ltr"
dir="ltr">
<span data-lexical-text="true">a b c d e</span>
</p>
<p
class="PlaygroundEditorTheme__paragraph PlaygroundEditorTheme__ltr"
dir="ltr">
<span data-lexical-text="true">f g h</span>
</p>
`,
);
await assertSelection(page, {
anchorOffset: 5,
anchorPath: [1, 0, 0],
focusOffset: 5,
focusPath: [1, 0, 0],
});
});
});
Loading
Loading