Skip to content

Commit

Permalink
test: selection
Browse files Browse the repository at this point in the history
  • Loading branch information
umaranis committed Dec 5, 2023
1 parent e9b3a6a commit 47de26d
Show file tree
Hide file tree
Showing 2 changed files with 75 additions and 0 deletions.
71 changes: 71 additions & 0 deletions demos/playground/src/__tests__/e2e/Selection.spec.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,10 @@
*/

import {
deleteForward,
moveLeft,
moveRight,
moveToEditorBeginning,
moveToLineBeginning,
moveToPrevWord,
pressShiftEnter,
Expand All @@ -22,8 +25,10 @@ import {
focusEditor,
html,
initialize,
insertCollapsible,
insertImageCaption,
insertSampleImage,
insertTable,
IS_MAC,
keyDownCtrlOrMeta,
keyUpCtrlOrMeta,
Expand Down Expand Up @@ -281,4 +286,70 @@ test.describe('Selection', () => {
`,
);
});

test.fixme('Can delete forward a Collapsible', async ({ page, isPlainText }) => {
test.skip(isPlainText);
if (!IS_MAC) {
// Do Windows/Linux have equivalent shortcuts?
return;
}
await focusEditor(page);
await page.keyboard.type('abc');
await insertCollapsible(page);
await moveToEditorBeginning(page);
await moveRight(page, 3);
await deleteForward(page);

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

// TODO I don't think this test is correct but at least this test will prevent it from regressing
// even further
test.fixme('Can delete forward a Table', async ({ page, isPlainText }) => {
test.skip(isPlainText);
if (!IS_MAC) {
// Do Windows/Linux have equivalent shortcuts?
return;
}
await focusEditor(page);
await page.keyboard.type('abc');
await insertTable(page, 1, 2);
await moveToEditorBeginning(page);
await moveRight(page, 3);
await deleteForward(page);

await assertHTML(
page,
html`
<p
class="PlaygroundEditorTheme__paragraph PlaygroundEditorTheme__ltr"
dir="ltr">
<span data-lexical-text="true">abc</span>
</p>
<table class="PlaygroundEditorTheme__table">
<tr>
<th
class="PlaygroundEditorTheme__tableCell PlaygroundEditorTheme__tableCellHeader">
<p class="PlaygroundEditorTheme__paragraph"><br /></p>
</th>
<th
class="PlaygroundEditorTheme__tableCell PlaygroundEditorTheme__tableCellHeader">
<p class="PlaygroundEditorTheme__paragraph"><br /></p>
</th>
</tr>
</table>
<p class="PlaygroundEditorTheme__paragraph"><br /></p>
`,
);
});
});
4 changes: 4 additions & 0 deletions demos/playground/src/__tests__/utils/index.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -743,6 +743,10 @@ export async function insertTable(page, rows = 2, columns = 3) {
);
}

export async function insertCollapsible(page) {
await selectFromInsertDropdown(page, '.item .caret-right');
}

export async function selectCellsFromTableCords(
page,
firstCords,
Expand Down

0 comments on commit 47de26d

Please sign in to comment.