Table unmerge (#4877)

This commit is contained in:
Peter Cook Bulukin
2023-08-17 16:54:05 +02:00
committed by GitHub
parent 7f62decae6
commit ede18e69a0
3 changed files with 63 additions and 1 deletions

View File

@ -0,0 +1,54 @@
/**
* Copyright (c) Meta Platforms, Inc. and affiliates.
*
* This source code is licensed under the MIT license found in the
* LICENSE file in the root directory of this source tree.
*
*/
import {
click,
expect,
focusEditor,
initialize,
insertTable,
locate,
mergeTableCells,
selectCellsFromTableCords,
test,
unmergeTableCell,
} from '../utils/index.mjs';
test.describe('Regression test #4876', () => {
test.beforeEach(({isCollab, page}) => initialize({isCollab, page}));
test('unmerging cells should add cells to correct rows', async ({
page,
isPlainText,
isCollab,
}) => {
test.skip(isPlainText);
await focusEditor(page);
await insertTable(page, 4, 4);
await click(page, '.PlaygroundEditorTheme__tableCell');
await selectCellsFromTableCords(
page,
{x: 0, y: 1},
{x: 1, y: 3},
true,
false,
);
await mergeTableCells(page);
await unmergeTableCell(page);
const tableRow = await locate(page, 'tr');
expect(await tableRow.count()).toBe(4);
for (let i = 0; i < 4; i++) {
const tableCells = tableRow.nth(i).locator('th, td');
expect(await tableCells.count()).toBe(4);
}
});
});

View File

@ -519,6 +519,14 @@ export async function waitForSelector(page, selector, options) {
}
}
export async function locate(page, selector) {
let leftFrame = page;
if (IS_COLLAB) {
leftFrame = await page.frame('left');
}
return await leftFrame.locator(selector);
}
export async function selectorBoundingBox(page, selector) {
let leftFrame = page;
if (IS_COLLAB) {

View File

@ -621,7 +621,7 @@ export function $unmergeCell(): void {
for (let i = 1; i < rowSpan; i++) {
const currentRow = startRow + i;
const currentRowMap = map[currentRow];
currentRowNode = row.getNextSibling();
currentRowNode = (currentRowNode || row).getNextSibling();
invariant(
DEPRECATED_$isGridRowNode(currentRowNode),
'Expected row next sibling to be a row',