Skip to content

Commit

Permalink
.
Browse files Browse the repository at this point in the history
  • Loading branch information
potatowagon committed Jul 26, 2024
1 parent 96c37e2 commit 465e556
Show file tree
Hide file tree
Showing 3 changed files with 88 additions and 77 deletions.
119 changes: 61 additions & 58 deletions packages/lexical-playground/__tests__/e2e/List.spec.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -1304,68 +1304,71 @@ test.describe.parallel('Nested List', () => {
);
});

test('can navigate and check/uncheck with keyboard', async ({
page,
isCollab,
}) => {
await focusEditor(page);
await toggleCheckList(page);
//
// [ ] a
// [ ] b
// [ ] c
// [ ] d
// [ ] e
// [ ] f
await page.keyboard.type('a');
await page.keyboard.press('Enter');
await page.keyboard.type('b');
await page.keyboard.press('Enter');
await click(page, '.toolbar-item.alignment');
await click(page, 'button:has-text("Indent")');
await page.keyboard.type('c');
await page.keyboard.press('Enter');
await click(page, '.toolbar-item.alignment');
await click(page, 'button:has-text("Indent")');
await page.keyboard.type('d');
await page.keyboard.press('Enter');
await page.keyboard.type('e');
await page.keyboard.press('Enter');
await page.keyboard.press('Backspace');
await page.keyboard.press('Backspace');
await page.keyboard.type('f');

const assertCheckCount = async (checkCount, uncheckCount) => {
const pageOrFrame = await (isCollab ? page.frame('left') : page);
await expect(
pageOrFrame.locator('li[role="checkbox"][aria-checked="true"]'),
).toHaveCount(checkCount);
await expect(
pageOrFrame.locator('li[role="checkbox"][aria-checked="false"]'),
).toHaveCount(uncheckCount);
};

await assertCheckCount(0, 6);

// Go back to select checkbox
await page.keyboard.press('ArrowLeft');
await page.keyboard.press('ArrowLeft');
await page.keyboard.press('Space');

await repeat(5, async () => {
await page.keyboard.press('ArrowUp', {delay: 50});
test(
'can navigate and check/uncheck with keyboard',
{
tag: '@flaky',
},
async ({page, isCollab}) => {
await focusEditor(page);
await toggleCheckList(page);
//
// [ ] a
// [ ] b
// [ ] c
// [ ] d
// [ ] e
// [ ] f
await page.keyboard.type('a');
await page.keyboard.press('Enter');
await page.keyboard.type('b');
await page.keyboard.press('Enter');
await click(page, '.toolbar-item.alignment');
await click(page, 'button:has-text("Indent")');
await page.keyboard.type('c');
await page.keyboard.press('Enter');
await click(page, '.toolbar-item.alignment');
await click(page, 'button:has-text("Indent")');
await page.keyboard.type('d');
await page.keyboard.press('Enter');
await page.keyboard.type('e');
await page.keyboard.press('Enter');
await page.keyboard.press('Backspace');
await page.keyboard.press('Backspace');
await page.keyboard.type('f');

const assertCheckCount = async (checkCount, uncheckCount) => {
const pageOrFrame = await (isCollab ? page.frame('left') : page);
await expect(
pageOrFrame.locator('li[role="checkbox"][aria-checked="true"]'),
).toHaveCount(checkCount);
await expect(
pageOrFrame.locator('li[role="checkbox"][aria-checked="false"]'),
).toHaveCount(uncheckCount);
};

await assertCheckCount(0, 6);

// Go back to select checkbox
await page.keyboard.press('ArrowLeft');
await page.keyboard.press('ArrowLeft');
await page.keyboard.press('Space');
});

await assertCheckCount(6, 0);
await repeat(5, async () => {
await page.keyboard.press('ArrowUp', {delay: 50});
await page.keyboard.press('Space');
});

await repeat(3, async () => {
await page.keyboard.press('ArrowDown', {delay: 50});
await page.keyboard.press('Space');
});
await assertCheckCount(6, 0);

await assertCheckCount(3, 3);
});
await repeat(3, async () => {
await page.keyboard.press('ArrowDown', {delay: 50});
await page.keyboard.press('Space');
});

await assertCheckCount(3, 3);
},
);

test('replaces existing element node', async ({page}) => {
// Create two quote blocks, select it and format to a list
Expand Down
42 changes: 24 additions & 18 deletions packages/lexical-playground/__tests__/e2e/Selection.spec.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -480,25 +480,31 @@ test.describe.parallel('Selection', () => {
);
});

test('Can delete sibling elements forward', async ({page, isPlainText}) => {
test.skip(isPlainText);
test(
'Can delete sibling elements forward',
{
tag: '@flaky',
},
async ({page, isPlainText}) => {
test.skip(isPlainText);

await focusEditor(page);
await page.keyboard.press('Enter');
await page.keyboard.type('# Title');
await page.keyboard.press('ArrowUp');
await deleteForward(page);
await assertHTML(
page,
html`
<h1
class="PlaygroundEditorTheme__h1 PlaygroundEditorTheme__ltr"
dir="ltr">
<span data-lexical-text="true">Title</span>
</h1>
`,
);
});
await focusEditor(page);
await page.keyboard.press('Enter');
await page.keyboard.type('# Title');
await page.keyboard.press('ArrowUp');
await deleteForward(page);
await assertHTML(
page,
html`
<h1
class="PlaygroundEditorTheme__h1 PlaygroundEditorTheme__ltr"
dir="ltr">
<span data-lexical-text="true">Title</span>
</h1>
`,
);
},
);

test('Can adjust tripple click selection', async ({
page,
Expand Down
4 changes: 3 additions & 1 deletion packages/lexical-playground/__tests__/e2e/Tables.spec.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -877,7 +877,9 @@ test.describe.parallel('Tables', () => {

test(
`Can style text using Table selection`,
{tag: '@flaky'},
{
tag: '@flaky',
},
async ({page, isPlainText, isCollab}) => {
await initialize({isCollab, page});
test.skip(isPlainText);
Expand Down

0 comments on commit 465e556

Please sign in to comment.