Skip to content

Commit e3f286f

Browse files
add 'fixme' tests for broken nested table behaviour
1 parent 04e908f commit e3f286f

File tree

1 file changed

+158
-152
lines changed

1 file changed

+158
-152
lines changed

packages/lexical-playground/__tests__/e2e/Tables.spec.mjs

Lines changed: 158 additions & 152 deletions
Original file line numberDiff line numberDiff line change
@@ -7393,165 +7393,171 @@ test.describe.parallel('Tables', () => {
73937393
});
73947394
});
73957395

7396-
test('Drag-select inside nested table to outside table (backwards) selects nested table only', async ({
7397-
page,
7398-
isPlainText,
7399-
isCollab,
7400-
}) => {
7401-
test.skip(isPlainText);
7402-
await initialize({hasNestedTables: true, isCollab, page});
7403-
7404-
await focusEditor(page);
7405-
7406-
await insertTable(page, 2, 2);
7407-
await page.locator('table:first-of-type td').click();
7408-
await page.keyboard.type('beforeText');
7409-
await insertTable(page, 1, 1);
7410-
await page.keyboard.press('ArrowDown');
7411-
await page.keyboard.type('afterText');
7412-
7413-
const nestedBeforeText = await selectorBoundingBox(
7414-
page,
7415-
'p:has-text("beforeText")',
7416-
);
7417-
const nestedFirstCell = await selectorBoundingBox(
7418-
page,
7419-
'table table > tr:first-of-type > th:first-of-type',
7420-
);
7421-
7422-
await dragMouse(page, nestedFirstCell, nestedBeforeText, {
7423-
positionEnd: 'start',
7424-
steps: 5,
7425-
});
7426-
7427-
// selection starts in the text and ends in the last cell of the nested table
7428-
await assertSelection(page, {
7429-
anchorOffset: 0,
7430-
anchorPath: [1, 0, 1, 1, 1],
7431-
focusOffset: 0,
7432-
focusPath: [1, 0, 1, 1, 1],
7433-
});
7434-
});
7435-
7436-
test('Drag-select into nested table (forward) does not select parent cell', async ({
7437-
page,
7438-
isPlainText,
7439-
isCollab,
7440-
}) => {
7441-
test.skip(isPlainText);
7442-
await initialize({hasNestedTables: true, isCollab, page});
7443-
7444-
await focusEditor(page);
7445-
7446-
await insertTable(page, 2, 2);
7447-
await page.locator('table:first-of-type td').click();
7448-
await page.keyboard.type('beforeText');
7449-
await insertTable(page, 1, 1);
7450-
await page.keyboard.press('ArrowDown');
7451-
await page.keyboard.type('afterText');
7452-
7453-
const nestedBeforeText = await selectorBoundingBox(
7454-
page,
7455-
'p:has-text("beforeText")',
7456-
);
7457-
const nestedFirstCell = await selectorBoundingBox(
7458-
page,
7459-
'table table > tr:first-of-type > th:first-of-type',
7460-
);
7461-
7462-
await dragMouse(page, nestedBeforeText, nestedFirstCell, {
7463-
positionStart: 'start',
7464-
steps: 5,
7465-
});
7466-
7467-
// selection starts in the text and ends in the last cell of the nested table
7468-
await assertSelection(page, {
7469-
anchorOffset: 0,
7470-
anchorPath: [1, 0, 1, 1, 1],
7471-
focusOffset: 0,
7472-
focusPath: [1, 0, 1, 1, 1],
7473-
});
7474-
});
7475-
7476-
test('Drag-select inside nested table to outside table (forward) selects nested table only', async ({
7477-
page,
7478-
isPlainText,
7479-
isCollab,
7480-
}) => {
7481-
test.skip(isPlainText);
7482-
await initialize({hasNestedTables: true, isCollab, page});
7483-
7484-
await focusEditor(page);
7485-
7486-
await insertTable(page, 2, 2);
7487-
await page.locator('table:first-of-type td').click();
7488-
await page.keyboard.type('beforeText');
7489-
await insertTable(page, 1, 1);
7490-
await page.keyboard.press('ArrowDown');
7491-
await page.keyboard.type('afterText');
7492-
7493-
const nestedLastRow = await selectorBoundingBox(
7494-
page,
7495-
'table table > tr:last-of-type > th:first-of-type',
7496-
);
7497-
const nestedAfterText = await selectorBoundingBox(
7498-
page,
7499-
'p:has-text("afterText")',
7500-
);
7501-
7502-
await dragMouse(page, nestedLastRow, nestedAfterText, {
7503-
positionEnd: 'start',
7504-
steps: 5,
7505-
});
7396+
test.describe.fixme(
7397+
'Drag-select nested table tests',
7398+
'These tests are all erroneously selecting the parent cell',
7399+
() => {
7400+
test('Drag-select out of nested table (backwards) does not select parent cell', async ({
7401+
page,
7402+
isPlainText,
7403+
isCollab,
7404+
}) => {
7405+
test.skip(isPlainText);
7406+
await initialize({hasNestedTables: true, isCollab, page});
7407+
7408+
await focusEditor(page);
7409+
7410+
await insertTable(page, 2, 2);
7411+
await page.locator('table:first-of-type td').click();
7412+
await page.keyboard.type('beforeText');
7413+
await insertTable(page, 1, 1);
7414+
await page.keyboard.press('ArrowDown');
7415+
await page.keyboard.type('afterText');
7416+
7417+
const nestedBeforeText = await selectorBoundingBox(
7418+
page,
7419+
'p:has-text("beforeText")',
7420+
);
7421+
const nestedFirstCell = await selectorBoundingBox(
7422+
page,
7423+
'table table > tr:first-of-type > th:first-of-type',
7424+
);
7425+
7426+
await dragMouse(page, nestedFirstCell, nestedBeforeText, {
7427+
positionEnd: 'start',
7428+
steps: 5,
7429+
});
75067430

7507-
// selection starts in the first nested cell and ends at end of the text
7508-
await assertSelection(page, {
7509-
anchorOffset: 0,
7510-
anchorPath: [1, 0, 1, 1, 1],
7511-
focusOffset: 0,
7512-
focusPath: [1, 0, 1, 1, 1],
7513-
});
7514-
});
7431+
// fixme: this is the whole cell of the parent table
7432+
await assertSelection(page, {
7433+
anchorOffset: 0,
7434+
anchorPath: [1, 0, 2, 1, 0, 0, 0],
7435+
focusOffset: 0,
7436+
focusPath: [1, 0, 2, 1, 0, 0, 0],
7437+
});
7438+
});
75157439

7516-
test('Drag-select into nested table (backwards) does not select parent cell', async ({
7517-
page,
7518-
isPlainText,
7519-
isCollab,
7520-
}) => {
7521-
test.skip(isPlainText);
7522-
await initialize({hasNestedTables: true, isCollab, page});
7440+
test('Drag-select into nested table (forward) does not select parent cell', async ({
7441+
page,
7442+
isPlainText,
7443+
isCollab,
7444+
}) => {
7445+
test.skip(isPlainText);
7446+
await initialize({hasNestedTables: true, isCollab, page});
7447+
7448+
await focusEditor(page);
7449+
7450+
await insertTable(page, 2, 2);
7451+
await page.locator('table:first-of-type td').click();
7452+
await page.keyboard.type('beforeText');
7453+
await insertTable(page, 1, 1);
7454+
await page.keyboard.press('ArrowDown');
7455+
await page.keyboard.type('afterText');
7456+
7457+
const nestedBeforeText = await selectorBoundingBox(
7458+
page,
7459+
'p:has-text("beforeText")',
7460+
);
7461+
const nestedFirstCell = await selectorBoundingBox(
7462+
page,
7463+
'table table > tr:first-of-type > th:first-of-type',
7464+
);
7465+
7466+
await dragMouse(page, nestedBeforeText, nestedFirstCell, {
7467+
positionStart: 'start',
7468+
steps: 5,
7469+
});
75237470

7524-
await focusEditor(page);
7471+
// fixme: this is the whole cell of the parent table
7472+
await assertSelection(page, {
7473+
anchorOffset: 0,
7474+
anchorPath: [1, 0, 2, 1, 1, 0, 1, 0, 0],
7475+
focusOffset: 0,
7476+
focusPath: [1, 0, 2, 1, 1, 0, 1, 0, 0],
7477+
});
7478+
});
75257479

7526-
await insertTable(page, 2, 2);
7527-
await page.locator('table:first-of-type td').click();
7528-
await page.keyboard.type('beforeText');
7529-
await insertTable(page, 1, 1);
7530-
await page.keyboard.press('ArrowDown');
7531-
await page.keyboard.type('afterText');
7480+
test('Drag-select out of nested table (forward) does not select parent cell', async ({
7481+
page,
7482+
isPlainText,
7483+
isCollab,
7484+
}) => {
7485+
test.skip(isPlainText);
7486+
await initialize({hasNestedTables: true, isCollab, page});
7487+
7488+
await focusEditor(page);
7489+
7490+
await insertTable(page, 2, 2);
7491+
await page.locator('table:first-of-type td').click();
7492+
await page.keyboard.type('beforeText');
7493+
await insertTable(page, 1, 1);
7494+
await page.keyboard.press('ArrowDown');
7495+
await page.keyboard.type('afterText');
7496+
7497+
const nestedLastRow = await selectorBoundingBox(
7498+
page,
7499+
'table table > tr:last-of-type > th:first-of-type',
7500+
);
7501+
const nestedAfterText = await selectorBoundingBox(
7502+
page,
7503+
'p:has-text("afterText")',
7504+
);
7505+
7506+
await dragMouse(page, nestedLastRow, nestedAfterText, {
7507+
positionEnd: 'start',
7508+
steps: 5,
7509+
});
75327510

7533-
const nestedLastRow = await selectorBoundingBox(
7534-
page,
7535-
'table table > tr:last-of-type > th:first-of-type',
7536-
);
7537-
const nestedAfterText = await selectorBoundingBox(
7538-
page,
7539-
'p:has-text("afterText")',
7540-
);
7511+
// fixme: this is the whole cell of the parent table
7512+
await assertSelection(page, {
7513+
anchorOffset: 0,
7514+
anchorPath: [1, 0, 2, 1, 2, 0, 0],
7515+
focusOffset: 0,
7516+
focusPath: [1, 0, 2, 1, 2, 0, 0],
7517+
});
7518+
});
75417519

7542-
await dragMouse(page, nestedAfterText, nestedLastRow, {
7543-
positionStart: 'start',
7544-
steps: 5,
7545-
});
7520+
test('Drag-select into nested table (backwards) does not select parent cell', async ({
7521+
page,
7522+
isPlainText,
7523+
isCollab,
7524+
}) => {
7525+
test.skip(isPlainText);
7526+
await initialize({hasNestedTables: true, isCollab, page});
7527+
7528+
await focusEditor(page);
7529+
7530+
await insertTable(page, 2, 2);
7531+
await page.locator('table:first-of-type td').click();
7532+
await page.keyboard.type('beforeText');
7533+
await insertTable(page, 1, 1);
7534+
await page.keyboard.press('ArrowDown');
7535+
await page.keyboard.type('afterText');
7536+
7537+
const nestedLastRow = await selectorBoundingBox(
7538+
page,
7539+
'table table > tr:last-of-type > th:first-of-type',
7540+
);
7541+
const nestedAfterText = await selectorBoundingBox(
7542+
page,
7543+
'p:has-text("afterText")',
7544+
);
7545+
7546+
await dragMouse(page, nestedAfterText, nestedLastRow, {
7547+
positionStart: 'start',
7548+
steps: 5,
7549+
});
75467550

7547-
// selection starts in the first nested cell and ends at end of the text
7548-
await assertSelection(page, {
7549-
anchorOffset: 0,
7550-
anchorPath: [1, 0, 1, 1, 1],
7551-
focusOffset: 0,
7552-
focusPath: [1, 0, 1, 1, 1],
7553-
});
7554-
});
7551+
// fixme: This selector is not correct. Will need to investigate once the underlying bug is addressed.
7552+
await assertSelection(page, {
7553+
anchorOffset: 0,
7554+
anchorPath: [0],
7555+
focusOffset: 0,
7556+
focusPath: [0],
7557+
});
7558+
});
7559+
},
7560+
);
75557561
});
75567562

75577563
const TABLE_WITH_MERGED_CELLS = `

0 commit comments

Comments
 (0)