mirror of
https://github.com/baserow/baserow.git
synced 2026-12-04 08:18:42 +00:00
* feat: add collapsible group-by grid view * fix: address copilot feedback, plus some other cleanup/fixes * fix: harden grid e2e navigation * Add e2e tests; improve performance; clean up code * feat: show resolved values for reference fields in group-by headers - Resolve collaborator, link-row and select group values to renderable display objects in the group-by data API, batched once per field per page (O(1) lookups, no per-group queries). - Order many-to-many groups identically to the rows via correlated-subquery ordering, since the relation column is shadowed by the aggregated array annotation in group-by queries. - Render the display values as chips in the group-by banner via dedicated multiple-select / multiple-collaborators components; shrink the collaborator badge, reduce the field-name size and keep the label on one line. * fix: group many-to-many fields by their set of values Grouping a grid by a collaborator, multiple-select or link-row field produced empty groups with orphaned rows and duplicate headers for the same set of values. The group key (an id array) was order-sensitive: the backend's aggregated array order was unstable row-to-row and the cell appends new values, so an optimistically-created group's key diverged from the server's and rows were rejected by rowBelongsToGroupBySection. - pathKey and the group-row Vue keys now sort m2m id arrays numerically, so a group is identified by its set of ids, not their order. - The backend aggregates the group value ordered by related id and sorts the group's unique value, making grouping deterministic and set-based. - Optimistically-emptied groups (row_count 0) are no longer rendered (the node is kept for reconciliation), and the leading group gap is fixed so the first visible group has no spurious gap. - A newly created collaborator group resolves its badge name from the workspace store instead of requiring the name on the value. * fix: keep cell multi-select when dragging in a group-by view A multi-select drag ends with a click whose target is the rows container (the common ancestor of the dragged cells). cancelMultiSelect- IfActive cancels the selection unless that container is recognised as part of the rows area, but its whitelist only knew the flat-grid classes (grid-view__rows / grid-view__row). The collapsible group-by feature renders rows in grid-view__group-by-rows containers, so the post-drag click was treated as "outside the rows" and the selection was cleared on mouseup. Add the group-by row containers to the whitelist. * test: expect emptied group-by banners to disappear The optimistic empty-group hiding (a group disappears once its last row moves out) made the e2e contract that kept the emptied source group visible at row_count 0 obsolete. Update the 2.2.7/2.4.4 assertions to expect the emptied group's banner to be gone (new expectNoGroupByBanner helper), and correct the tree-maintenance comments: the node is still kept for reconciliation, but the layout no longer renders its banner. * perf: load the collapsible group-by grid in one bounded request Grouping a wide table by many fields took several seconds and a request waterfall to render the first screen. The group tree was fetched one HTTP request per depth, a budget that ran out before reaching any leaf forced a per-parent fallback, and the rows endpoint resolved group-by metadata unconditionally. Backend - Walk the descendant tree with one batched windowed query per group-by level (get_group_by_data_for_parents) instead of one query per parent, so a single include_descendants request returns the whole visible subtree in O(depth) queries. - Scale the descent window to the viewport: row_budget = ceil(limit / depth). A deep group-by stacks each leaf row under its ancestor banners, so far fewer leaf rows fill the first screen; the window now returns a viewport-sized slice (~264 -> ~68 groups on a 12-level grid) and the rest lazy-loads on scroll. - Gate the rows endpoint's group-by metadata behind include=group_by_metadata so it is not computed when unused. - Resolve reference/link-row display values in one id__in query per field across all pages instead of once per page. Frontend - Initial load issues one group-by-data prefetch and one viewport rows request; expand mode no longer takes the per-depth path. - Cap the banner indent (<=50px) and shrink the per-level arrow spacing as the group-by count grows, keeping the count aligned and the field name ellipsised; render multi-level loading skeletons for the not-yet-loaded levels. - Guard walkPage against a cyclic page-resolution stack overflow and keep activeGroupBys filtered to fields that still exist. Plus e2e env isolation (configurable ports, cookie prefix) and docs. * fix: address review feedback Addresses the review comments on the collapsible group-by grid PR. - Gate the group-by add-row "+" on the same condition as the flat grid (not read-only, not a one-way data sync, has create-row permission), so it no longer renders buttons that error on click for data-sync tables. - Show the "(Empty)" label for empty array-valued groups (multiple select, link row, collaborators), matching the text-field behaviour. - Stop the flat-grid row placeholder from rendering in group-by mode (v-else-if instead of v-else). - Render formula group-by headers via the result field type's group-by component instead of RowCardFieldFormula, removing the dev-only "Missing required prop: row" Vue warning. - Keep the cell selected at the first/last field for both Tab and arrow keys (restore the pre-refactor behaviour); navigating past the edge no longer drops the selection in either flat or group-by mode. - Re-enable and de-flake the "sorted add outside buffer" e2e test: assert on the re-resolved last row instead of a snapshotted renderedRowCount() index, which raced with the create-confirmation re-render in CI. * fix: keep rows inserted below in a grouped grid view in their group Insert-below and add-row in a grouped view now derive the new row's group path from the neighbouring row, so it inherits all writable group-by values and lands in the same group; `before` is set only when the next row shares that group. * feat: soft-cap adding group-bys at 5 in the view UI Once a view reaches 5 group-bys the add button is disabled with a tooltip; views that already have more keep working and only offer to remove them. * limit group-bys; fix css * refactor: polish code and comments * fix: address Bram's feedback * feat: add vertical gap between sibling sub-groups and indent banner labels with their chevron * fix: address remaining feedback * fix: row-coloring and fixed-height for add-row * fix: address Bram's feedback v2 * fix regression in last commit * fix: address grid group review comments
1011 lines
32 KiB
TypeScript
1011 lines
32 KiB
TypeScript
/**
|
|
* Grid view - multi-cell selection, keyboard navigation, copy/paste, row hover.
|
|
*
|
|
* Catalogue sections covered:
|
|
* section 4 Clipboard operations
|
|
* section 10 Multi-cell selection
|
|
* section 11 Keyboard navigation
|
|
* section 12 Row hover/context actions
|
|
* section 13 Checkbox row selection
|
|
* section 14 Row expand modal smoke coverage
|
|
*
|
|
*/
|
|
|
|
import type { Page } from "@playwright/test";
|
|
import { test, expect } from "../../baserowTest";
|
|
import { GridPage } from "../../../pages/database/gridPage";
|
|
import {
|
|
GridSetupResult,
|
|
resetRows,
|
|
setupGrid,
|
|
} from "../../../fixtures/database/gridSetup";
|
|
import { createGridView, View } from "../../../fixtures/database/view";
|
|
import { pauseRows } from "../../../fixtures/network";
|
|
import { baserowConfig } from "../../../playwright.config";
|
|
|
|
type Setup = GridSetupResult;
|
|
|
|
// Keep docs/testing/grid-view-test-plan.md in sync with these cases.
|
|
//
|
|
// Serial mode is scoped per-describe (below), not file-wide, so a failure in one
|
|
// section doesn't skip the unrelated sections after it (and retries only rerun
|
|
// the affected describe).
|
|
|
|
async function pasteText(page: Page, text: string) {
|
|
await page.evaluate((clipboardText) => {
|
|
const data = new DataTransfer();
|
|
data.setData("text/plain", clipboardText);
|
|
const event = new ClipboardEvent("paste", {
|
|
bubbles: true,
|
|
cancelable: true,
|
|
clipboardData: data,
|
|
});
|
|
document.dispatchEvent(event);
|
|
}, text);
|
|
}
|
|
|
|
/**
|
|
* Playwright can only grant and deliver clipboard data in Chromium, so the
|
|
* clipboard cases run there only.
|
|
*/
|
|
function skipIfNoClipboard(browserName: string) {
|
|
test.skip(
|
|
browserName !== "chromium",
|
|
"Playwright cannot deliver clipboard data to Firefox.",
|
|
);
|
|
}
|
|
|
|
async function grantClipboard(page: Page, browserName: string) {
|
|
if (browserName !== "chromium") {
|
|
return;
|
|
}
|
|
await page.context().grantPermissions(["clipboard-read", "clipboard-write"], {
|
|
origin: baserowConfig.PUBLIC_WEB_FRONTEND_URL,
|
|
});
|
|
}
|
|
|
|
function multiSelectedFieldCells(page: Page) {
|
|
return page.locator(".grid-view__right .grid-view__column--multi-select");
|
|
}
|
|
|
|
// -----------------------------------------------------------------------------
|
|
// section 10.1 Selection mechanics
|
|
// -----------------------------------------------------------------------------
|
|
|
|
test.describe("10.1 Selection mechanics", () => {
|
|
test.describe.configure({ mode: "serial" });
|
|
|
|
let g: Setup;
|
|
let groupBy: Setup;
|
|
|
|
test.beforeAll(async () => {
|
|
g = await setupGrid({
|
|
dbName: "SelectionDb",
|
|
fields: [
|
|
{ name: "Score", type: "number" },
|
|
{ name: "Notes", type: "text" },
|
|
],
|
|
rows: [
|
|
{ Name: "Alice", Score: 10, Notes: "note A" },
|
|
{ Name: "Bob", Score: 20, Notes: "note B" },
|
|
{ Name: "Carol", Score: 30, Notes: "note C" },
|
|
],
|
|
});
|
|
groupBy = await setupGrid({
|
|
dbName: "SelectionGroupByDb",
|
|
fields: [
|
|
{ name: "Score", type: "number" },
|
|
{ name: "Notes", type: "text" },
|
|
],
|
|
rows: [
|
|
{ Name: "Alice", Score: 10, Notes: "note A" },
|
|
{ Name: "Bob", Score: 20, Notes: "note B" },
|
|
{ Name: "Carol", Score: 30, Notes: "note C" },
|
|
],
|
|
groupBys: [{ fieldName: "Name", order: "ASC" }],
|
|
});
|
|
});
|
|
|
|
test.beforeEach(async ({ page }) => {
|
|
const grid = new GridPage(page, g.user);
|
|
await grid.goTo(g.database, g.table);
|
|
});
|
|
|
|
test("10.1.1 clicking one field cell selects it and leaves no multi-select range visible", async ({
|
|
page,
|
|
}) => {
|
|
const grid = new GridPage(page, g.user);
|
|
await grid.selectFieldCell(0, 0);
|
|
|
|
await grid.expectFieldSelected(0, 0);
|
|
await expect(page.locator(".grid-view__column--multi-select")).toHaveCount(
|
|
0,
|
|
);
|
|
});
|
|
|
|
test("10.1.2 shift-clicking another cell keeps the anchor selected and shows the rectangular range", async ({
|
|
page,
|
|
}) => {
|
|
const grid = new GridPage(page, g.user);
|
|
|
|
await grid.selectFieldCell(0, 0); // head (Alice, Score)
|
|
await grid.expectFieldSelected(0, 0);
|
|
await grid.fieldCellAt(1, 1).click({ modifiers: ["Shift"] }); // tail (Bob, Notes)
|
|
|
|
// Both cells should be in the multi-select range
|
|
await expect(multiSelectedFieldCells(page)).toHaveCount(4, {
|
|
timeout: 5_000,
|
|
}); // 2 rows x 2 cols
|
|
});
|
|
|
|
test("10.1.3 dragging across cells shows a rectangular range that remains visible after mouseup", async ({
|
|
page,
|
|
}) => {
|
|
const grid = new GridPage(page, g.user);
|
|
|
|
const fromCell = grid.fieldCellAt(0, 0); // Alice / Score
|
|
const toCell = grid.fieldCellAt(1, 1); // Bob / Notes
|
|
|
|
const fromBox = await fromCell.boundingBox();
|
|
const toBox = await toCell.boundingBox();
|
|
|
|
if (!fromBox || !toBox)
|
|
throw new Error("Could not measure cell bounding boxes");
|
|
|
|
const cx = (box: { x: number; width: number }) => box.x + box.width / 2;
|
|
const cy = (box: { y: number; height: number }) => box.y + box.height / 2;
|
|
|
|
// Simulate a real drag: mousedown on the first cell, move to the last,
|
|
// then release. The { steps } option fires intermediate mousemove events
|
|
// so the grid's mouseover handler extends the selection incrementally.
|
|
await page.mouse.move(cx(fromBox), cy(fromBox));
|
|
await page.mouse.down();
|
|
await page.mouse.move(cx(toBox), cy(toBox), { steps: 5 });
|
|
await page.mouse.up();
|
|
|
|
// The selection must still be present after mouseup.
|
|
// This specifically tests the regression where mouseup clears
|
|
// the selection instead of just releasing the hold.
|
|
await expect(multiSelectedFieldCells(page)).toHaveCount(4, {
|
|
timeout: 5_000,
|
|
}); // 2 rows x 2 cols
|
|
});
|
|
|
|
test("10.1.4 Escape removes the visible multi-select range", async ({
|
|
page,
|
|
}) => {
|
|
const grid = new GridPage(page, g.user);
|
|
|
|
await grid.selectFieldCell(0, 0);
|
|
await grid.expectFieldSelected(0, 0);
|
|
await grid.fieldCellAt(1, 1).click({ modifiers: ["Shift"] });
|
|
await expect(
|
|
page.locator(".grid-view__column--multi-select").first(),
|
|
).toBeVisible();
|
|
|
|
await page.keyboard.press("Escape");
|
|
|
|
await expect(page.locator(".grid-view__column--multi-select")).toHaveCount(
|
|
0,
|
|
{ timeout: 5_000 },
|
|
);
|
|
});
|
|
|
|
test("10.1.5 clicking outside the grid removes the visible multi-select range", async ({
|
|
page,
|
|
}) => {
|
|
const grid = new GridPage(page, g.user);
|
|
|
|
await grid.selectFieldCell(0, 0);
|
|
await grid.expectFieldSelected(0, 0);
|
|
await grid.fieldCellAt(1, 0).click({ modifiers: ["Shift"] });
|
|
|
|
await grid.clickAway();
|
|
|
|
await expect(page.locator(".grid-view__column--multi-select")).toHaveCount(
|
|
0,
|
|
{ timeout: 5_000 },
|
|
);
|
|
});
|
|
|
|
test("10.1.6 group-by cell selection and shift range use visible row indexes", async ({
|
|
page,
|
|
}) => {
|
|
const grid = new GridPage(page, groupBy.user);
|
|
await grid.goTo(groupBy.database, groupBy.table);
|
|
await grid.expectGroupByBanner("Alice", 1);
|
|
await grid.expectGroupByBanner("Bob", 1);
|
|
|
|
await grid.selectFieldCell(0, 0);
|
|
await grid.expectFieldSelected(0, 0);
|
|
await grid.fieldCellAt(1, 1).click({ modifiers: ["Shift"] });
|
|
|
|
await expect(multiSelectedFieldCells(page)).toHaveCount(4, {
|
|
timeout: 5_000,
|
|
});
|
|
});
|
|
});
|
|
|
|
// -----------------------------------------------------------------------------
|
|
// section 10.2 Keyboard multi-cell selection
|
|
// -----------------------------------------------------------------------------
|
|
|
|
test.describe("10.2 Keyboard multi-cell selection", () => {
|
|
test.describe.configure({ mode: "serial" });
|
|
|
|
let g: Setup;
|
|
|
|
test.beforeAll(async () => {
|
|
g = await setupGrid({
|
|
dbName: "KeyboardSelectionDb",
|
|
fields: [
|
|
{ name: "Score", type: "number" },
|
|
{ name: "Notes", type: "text" },
|
|
],
|
|
rows: [
|
|
{ Name: "Alice", Score: 10, Notes: "note A" },
|
|
{ Name: "Bob", Score: 20, Notes: "note B" },
|
|
],
|
|
});
|
|
});
|
|
|
|
test.beforeEach(async ({ page }) => {
|
|
const grid = new GridPage(page, g.user);
|
|
await grid.goTo(g.database, g.table);
|
|
});
|
|
|
|
test("10.2.1 Shift+Arrow expands the selected range from one cell to a 2x2 area", async ({
|
|
page,
|
|
}) => {
|
|
const grid = new GridPage(page, g.user);
|
|
|
|
await grid.selectFieldCell(0, 0);
|
|
await page.keyboard.press("Shift+ArrowRight");
|
|
await grid.expectMultiSelectedCellCount(2);
|
|
await page.keyboard.press("Shift+ArrowDown");
|
|
await grid.expectMultiSelectedCellCount(4);
|
|
});
|
|
});
|
|
|
|
// -----------------------------------------------------------------------------
|
|
// section 4 Clipboard operations
|
|
// -----------------------------------------------------------------------------
|
|
|
|
test.describe("4 Clipboard operations", () => {
|
|
test.describe.configure({ mode: "serial" });
|
|
|
|
let g: Setup;
|
|
let pasteFilter: Setup;
|
|
let pasteSort: Setup;
|
|
let pasteGroupBy: Setup;
|
|
|
|
test.beforeAll(async () => {
|
|
g = await setupGrid({
|
|
dbName: "PasteDb",
|
|
fields: [
|
|
{ name: "Score", type: "number" },
|
|
{ name: "Notes", type: "text" },
|
|
],
|
|
rows: [
|
|
{ Name: "Row1", Score: 10, Notes: "note1" },
|
|
{ Name: "Row2", Score: 20, Notes: "note2" },
|
|
{ Name: "Row3", Score: 30, Notes: "note3" },
|
|
],
|
|
});
|
|
pasteFilter = await setupGrid({
|
|
dbName: "PasteFilterDb",
|
|
fields: [{ name: "Score", type: "number" }],
|
|
rows: [
|
|
{ Name: "Keep", Score: 10 },
|
|
{ Name: "Keep", Score: 20 },
|
|
],
|
|
filters: [{ fieldName: "Name", type: "equal", value: "Keep" }],
|
|
});
|
|
pasteSort = await setupGrid({
|
|
dbName: "PasteSortDb",
|
|
fields: [{ name: "Score", type: "number" }],
|
|
sorts: [{ fieldName: "Name", order: "ASC" }],
|
|
});
|
|
pasteGroupBy = await setupGrid({
|
|
dbName: "PasteGroupByDb",
|
|
fields: [{ name: "Team", type: "text" }],
|
|
groupBys: [{ fieldName: "Team", order: "ASC" }],
|
|
});
|
|
});
|
|
|
|
test.beforeEach(async ({ page, browserName }) => {
|
|
await resetRows(g, [
|
|
{ Name: "Row1", Score: 10, Notes: "note1" },
|
|
{ Name: "Row2", Score: 20, Notes: "note2" },
|
|
{ Name: "Row3", Score: 30, Notes: "note3" },
|
|
]);
|
|
const grid = new GridPage(page, g.user);
|
|
await grid.goTo(g.database, g.table);
|
|
await grantClipboard(page, browserName);
|
|
});
|
|
|
|
test("4.1.1 copy stores selected value in clipboard and paste immediately shows it in target cell", async ({
|
|
browserName,
|
|
page,
|
|
}) => {
|
|
skipIfNoClipboard(browserName);
|
|
|
|
const grid = new GridPage(page, g.user);
|
|
|
|
// Select Score cell of Row1 and copy
|
|
await grid.selectFieldCell(0, 0); // Row1 / Score
|
|
await grid.expectFieldSelected(0, 0);
|
|
await grid.copyShortcut();
|
|
await expect
|
|
.poll(async () =>
|
|
(await page.evaluate(() => navigator.clipboard.readText())).trim(),
|
|
)
|
|
.toBe("10");
|
|
const copiedText = await page.evaluate(() =>
|
|
navigator.clipboard.readText(),
|
|
);
|
|
|
|
// Select Score cell of Row3 and paste
|
|
await grid.selectFieldCell(2, 0); // Row3 / Score
|
|
await pasteText(page, copiedText);
|
|
|
|
// Row3's Score should now be 10 (same as Row1); no loading spinner since
|
|
// the cell update is optimistic.
|
|
await grid.expectFieldText(2, 0, "10");
|
|
await grid.expectNoRowsLoading();
|
|
});
|
|
|
|
test("4.1.2 pasting two lines on last row updates last row and immediately creates visible overflow row", async ({
|
|
browserName,
|
|
page,
|
|
}) => {
|
|
// Multi-line paste relies on the synthetic ClipboardEvent carrying its
|
|
// `clipboardData`. Firefox ignores `clipboardData` set via the constructor
|
|
// (getData returns ""), so the paste delivers nothing there — the same
|
|
// Playwright/Firefox clipboard limitation that skips 4.1.1. The behavior is
|
|
// covered in Chromium.
|
|
skipIfNoClipboard(browserName);
|
|
|
|
const grid = new GridPage(page, g.user);
|
|
|
|
// Select the last row's primary field (Row3 / Name) and paste two rows
|
|
// across Name and Score.
|
|
await grid.selectPrimaryCell(2);
|
|
await pasteText(page, "OverflowA\t99\nOverflowB\t88");
|
|
|
|
// New rows should have been created for the overflow lines
|
|
await grid.expectRowCount(4); // 3 original + 1 new (Row3 updated + 1 new)
|
|
await grid.expectPrimaryText(2, "OverflowA");
|
|
await grid.expectFieldText(2, 0, "99");
|
|
await grid.expectPrimaryText(3, "OverflowB");
|
|
await grid.expectFieldText(3, 0, "88");
|
|
});
|
|
|
|
test("4.2.1a filter-breaking paste shows warning, keeps selection, then removes row on deselect", async ({
|
|
browserName,
|
|
page,
|
|
}) => {
|
|
skipIfNoClipboard(browserName);
|
|
await resetRows(pasteFilter, [{ Name: "Keep", Score: 10 }]);
|
|
const grid = new GridPage(page, pasteFilter.user);
|
|
await grid.goTo(pasteFilter.database, pasteFilter.table);
|
|
await grid.expectRowCount(1);
|
|
|
|
// Paste a value that breaks the filter - "Keep" -> "Gone"
|
|
await grid.selectPrimaryCell(0); // first Keep row / Name
|
|
await pasteText(page, "Gone");
|
|
|
|
// The pasted row should show a filter-mismatch warning while still selected
|
|
await grid.expectPrimaryText(0, "Gone");
|
|
await grid.expectPrimarySelected(0);
|
|
await grid.expectRowHasWarning(0);
|
|
await grid.expectRowWarningText(0, "Row does not match filters");
|
|
|
|
await grid.clickAway();
|
|
|
|
await grid.expectPrimaryNotVisible("Gone");
|
|
await grid.expectRowCount(0);
|
|
});
|
|
|
|
test("4.2.1b filter-breaking paste deselected before backend confirmation removes the row immediately", async ({
|
|
browserName,
|
|
page,
|
|
}) => {
|
|
skipIfNoClipboard(browserName);
|
|
await resetRows(pasteFilter, [{ Name: "Keep", Score: 10 }]);
|
|
const grid = new GridPage(page, pasteFilter.user);
|
|
await grid.goTo(pasteFilter.database, pasteFilter.table);
|
|
await grid.expectRowCount(1);
|
|
|
|
const pausedUpdate = await pauseRows(page, pasteFilter.table.id, "PATCH");
|
|
|
|
await grid.selectPrimaryCell(0);
|
|
await pasteText(page, "Gone");
|
|
await pausedUpdate.intercepted;
|
|
await grid.expectPrimaryText(0, "Gone");
|
|
await grid.expectRowHasWarning(0);
|
|
await grid.expectRowWarningText(0, "Row does not match filters");
|
|
|
|
await grid.clickAway();
|
|
await grid.expectRowCount(0);
|
|
|
|
pausedUpdate.release();
|
|
await grid.expectNoRowsLoading();
|
|
await grid.expectRowCount(0);
|
|
});
|
|
|
|
test("4.3.1a sort-affecting paste shows Row has moved warning while selected then moves row on deselect", async ({
|
|
browserName,
|
|
page,
|
|
}) => {
|
|
skipIfNoClipboard(browserName);
|
|
await resetRows(pasteSort, [
|
|
{ Name: "Alice", Score: 10 },
|
|
{ Name: "Bob", Score: 20 },
|
|
]);
|
|
const grid = new GridPage(page, pasteSort.user);
|
|
await grid.goTo(pasteSort.database, pasteSort.table);
|
|
await grid.expectRowCount(2);
|
|
|
|
await grid.selectPrimaryCell(0); // Alice, sorts to position 1 after "Zara" replaces it
|
|
await pasteText(page, "Zara"); // Zara > Bob alphabetically
|
|
|
|
await grid.expectPrimaryText(0, "Zara");
|
|
await grid.expectRowHasWarning(0);
|
|
await grid.expectRowWarningText(0, "Row has moved");
|
|
await grid.expectPrimaryText(1, "Bob");
|
|
|
|
await grid.clickAway();
|
|
await grid.expectPrimaryText(0, "Bob");
|
|
await grid.expectPrimaryText(1, "Zara");
|
|
await grid.expectRowNoWarning(0);
|
|
await grid.expectRowNoWarning(1);
|
|
});
|
|
|
|
test("4.3.1b sort-affecting paste deselected before backend confirmation moves row immediately on deselect", async ({
|
|
browserName,
|
|
page,
|
|
}) => {
|
|
skipIfNoClipboard(browserName);
|
|
await resetRows(pasteSort, [
|
|
{ Name: "Alice", Score: 10 },
|
|
{ Name: "Bob", Score: 20 },
|
|
]);
|
|
const grid = new GridPage(page, pasteSort.user);
|
|
await grid.goTo(pasteSort.database, pasteSort.table);
|
|
await grid.expectRowCount(2);
|
|
|
|
const pausedUpdate = await pauseRows(page, pasteSort.table.id, "PATCH");
|
|
|
|
await grid.selectPrimaryCell(0); // Alice
|
|
await pasteText(page, "Zara");
|
|
await pausedUpdate.intercepted;
|
|
await grid.expectPrimaryText(0, "Zara");
|
|
await grid.expectRowHasWarning(0);
|
|
await grid.expectRowWarningText(0, "Row has moved");
|
|
|
|
await grid.clickAway();
|
|
// Warning was visible so row moves to sorted position immediately
|
|
await grid.expectPrimaryText(0, "Bob");
|
|
await grid.expectPrimaryText(1, "Zara");
|
|
await grid.expectRowNoWarning(0);
|
|
|
|
pausedUpdate.release();
|
|
await grid.expectNoRowsLoading();
|
|
await grid.expectPrimaryText(0, "Bob");
|
|
await grid.expectPrimaryText(1, "Zara");
|
|
await grid.expectRowNoWarning(0);
|
|
await grid.expectRowNoWarning(1);
|
|
});
|
|
|
|
test("4.7.1a group-by-affecting paste shows Row has moved warning while selected then moves row on deselect", async ({
|
|
browserName,
|
|
page,
|
|
}) => {
|
|
skipIfNoClipboard(browserName);
|
|
await resetRows(pasteGroupBy, [
|
|
{ Name: "Alice", Team: "A" },
|
|
{ Name: "Bob", Team: "A" },
|
|
{ Name: "Carol", Team: "B" },
|
|
]);
|
|
const grid = new GridPage(page, pasteGroupBy.user);
|
|
await grid.goTo(pasteGroupBy.database, pasteGroupBy.table);
|
|
await grid.expectRowCount(3);
|
|
await grid.expectGroupByBanner("A", 2);
|
|
await grid.expectGroupByBanner("B", 1);
|
|
|
|
await grid.selectFieldCell(0, 0); // Alice's Team
|
|
await pasteText(page, "B"); // moves Alice from group A to group B
|
|
|
|
await grid.expectFieldText(0, 0, "B");
|
|
await grid.expectRowHasWarning(0);
|
|
await grid.expectRowWarningText(0, "Row has moved");
|
|
await grid.expectGroupByBanner("A", 2);
|
|
await grid.expectGroupByBanner("B", 1);
|
|
|
|
await grid.clickAway();
|
|
await grid.expectGroupByBanner("A", 1);
|
|
await grid.expectGroupByBanner("B", 2);
|
|
await grid.expectRowCount(3);
|
|
await grid.expectRowNoWarning(0);
|
|
});
|
|
|
|
test("4.7.1b group-by-affecting paste deselected before backend confirmation moves the row immediately", async ({
|
|
browserName,
|
|
page,
|
|
}) => {
|
|
skipIfNoClipboard(browserName);
|
|
await resetRows(pasteGroupBy, [
|
|
{ Name: "Alice", Team: "A" },
|
|
{ Name: "Bob", Team: "A" },
|
|
{ Name: "Carol", Team: "B" },
|
|
]);
|
|
const grid = new GridPage(page, pasteGroupBy.user);
|
|
await grid.goTo(pasteGroupBy.database, pasteGroupBy.table);
|
|
await grid.expectRowCount(3);
|
|
await grid.expectGroupByBanner("A", 2);
|
|
await grid.expectGroupByBanner("B", 1);
|
|
|
|
const pausedUpdate = await pauseRows(page, pasteGroupBy.table.id, "PATCH");
|
|
|
|
await grid.selectFieldCell(0, 0);
|
|
await pasteText(page, "B");
|
|
await pausedUpdate.intercepted;
|
|
await grid.expectFieldText(0, 0, "B");
|
|
await grid.expectRowHasWarning(0);
|
|
await grid.expectRowWarningText(0, "Row has moved");
|
|
|
|
await grid.clickAway();
|
|
// Warning was visible so the row moves to its new group immediately.
|
|
await grid.expectGroupByBanner("A", 1);
|
|
await grid.expectGroupByBanner("B", 2);
|
|
await grid.expectRowNoWarning(0);
|
|
|
|
pausedUpdate.release();
|
|
await grid.expectNoRowsLoading();
|
|
await grid.expectGroupByBanner("A", 1);
|
|
await grid.expectGroupByBanner("B", 2);
|
|
});
|
|
|
|
test("4.4.1 Delete clears every value in the selected cell range", async ({
|
|
page,
|
|
}) => {
|
|
const grid = new GridPage(page, g.user);
|
|
|
|
await grid.selectFieldCell(0, 0);
|
|
await grid.fieldCellAt(1, 1).click({ modifiers: ["Shift"] });
|
|
await grid.expectMultiSelectedCellCount(4);
|
|
|
|
await page.keyboard.press("Delete");
|
|
|
|
await grid.expectFieldEmpty(0, 0);
|
|
await grid.expectFieldEmpty(0, 1);
|
|
await grid.expectFieldEmpty(1, 0);
|
|
await grid.expectFieldEmpty(1, 1);
|
|
await grid.expectPrimaryText(0, "Row1");
|
|
await grid.expectFieldText(2, 0, "30");
|
|
});
|
|
});
|
|
|
|
// -----------------------------------------------------------------------------
|
|
// section 11.1 Keyboard navigation
|
|
// -----------------------------------------------------------------------------
|
|
|
|
test.describe("11.1 Keyboard navigation", () => {
|
|
test.describe.configure({ mode: "serial" });
|
|
|
|
let g: Setup;
|
|
|
|
test.beforeAll(async () => {
|
|
g = await setupGrid({
|
|
dbName: "KeyboardDb",
|
|
fields: [
|
|
{ name: "Score", type: "number" },
|
|
{ name: "Notes", type: "text" },
|
|
],
|
|
rows: [
|
|
{ Name: "Row1", Score: 10, Notes: "n1" },
|
|
{ Name: "Row2", Score: 20, Notes: "n2" },
|
|
],
|
|
});
|
|
});
|
|
|
|
test.beforeEach(async ({ page }) => {
|
|
await resetRows(g, [
|
|
{ Name: "Row1", Score: 10, Notes: "n1" },
|
|
{ Name: "Row2", Score: 20, Notes: "n2" },
|
|
]);
|
|
const grid = new GridPage(page, g.user);
|
|
await grid.goTo(g.database, g.table);
|
|
});
|
|
|
|
test("11.1.1 Tab moves selection to next cell, typing opens editor there, and Enter saves visible value", async ({
|
|
page,
|
|
}) => {
|
|
const grid = new GridPage(page, g.user);
|
|
|
|
await grid.selectFieldCell(0, 0); // Row1 / Score cell
|
|
await grid.expectFieldSelected(0, 0);
|
|
await page.keyboard.press("Tab");
|
|
|
|
await grid.expectFieldSelected(0, 1);
|
|
await page.keyboard.type("tabbed");
|
|
await expect(grid.activeEditor()).toHaveValue("tabbed", { timeout: 5_000 });
|
|
await grid.confirmWithEnter();
|
|
await grid.expectFieldText(0, 1, "tabbed");
|
|
});
|
|
|
|
test("11.1.2 pressing Enter on a selected cell shows the editor in that cell", async ({
|
|
page,
|
|
}) => {
|
|
const grid = new GridPage(page, g.user);
|
|
|
|
await grid.startEditingField(0, 0); // Row1 / Score
|
|
});
|
|
|
|
test("11.1.3 Enter while editing saves visible value, moves focus down, and allows editing next row", async ({
|
|
page,
|
|
}) => {
|
|
const grid = new GridPage(page, g.user);
|
|
|
|
await grid.startEditingField(0, 1); // Row1 / Notes
|
|
await grid.type("Row1Updated");
|
|
await grid.confirmWithEnter();
|
|
|
|
await grid.expectFieldText(0, 1, "Row1Updated");
|
|
|
|
await page.keyboard.type("Row2Updated");
|
|
await expect(grid.activeEditor()).toHaveValue("Row2Updated", {
|
|
timeout: 5_000,
|
|
});
|
|
await grid.confirmWithEnter();
|
|
await grid.expectFieldText(1, 1, "Row2Updated");
|
|
});
|
|
|
|
test("11.1.4 Escape while editing discards typed draft and keeps original row visible", async ({
|
|
page,
|
|
}) => {
|
|
const grid = new GridPage(page, g.user);
|
|
|
|
await grid.startEditingField(0, 1); // Row1 / Notes
|
|
await grid.type("ShouldNotSave");
|
|
await grid.cancelEdit();
|
|
|
|
await expect(grid.activeEditor()).toHaveCount(0);
|
|
await grid.expectFieldText(0, 1, "n1");
|
|
});
|
|
|
|
test("11.1.5 arrow key moves selection to adjacent row without showing an editor", async ({
|
|
page,
|
|
}) => {
|
|
const grid = new GridPage(page, g.user);
|
|
|
|
await grid.selectFieldCell(0, 0); // Row1 / Score
|
|
await grid.expectFieldSelected(0, 0);
|
|
await page.keyboard.press("ArrowDown");
|
|
|
|
// Row2's first cell should now be active and ready to edit - no editor opened
|
|
// until the user starts typing.
|
|
await expect(grid.activeEditor()).toHaveCount(0);
|
|
await grid.expectFieldSelected(1, 0);
|
|
});
|
|
|
|
test("11.1.6 typing while a cell is selected shows editor containing the typed characters", async ({
|
|
page,
|
|
}) => {
|
|
const grid = new GridPage(page, g.user);
|
|
|
|
await grid.selectFieldCell(0, 1); // Row1 / Notes cell (fieldIndex 1)
|
|
await grid.expectFieldSelected(0, 1);
|
|
await page.keyboard.type("42");
|
|
|
|
const editor = grid.activeEditor();
|
|
await expect(editor).toBeVisible({ timeout: 5_000 });
|
|
await expect(editor).toHaveValue("42");
|
|
});
|
|
});
|
|
|
|
// -----------------------------------------------------------------------------
|
|
// section 12.1 Row hover actions
|
|
// -----------------------------------------------------------------------------
|
|
|
|
test.describe("12.1 Row hover actions", () => {
|
|
test.describe.configure({ mode: "serial" });
|
|
|
|
let gUnsorted: Setup;
|
|
let gSorted: Setup;
|
|
|
|
test.beforeAll(async () => {
|
|
[gUnsorted, gSorted] = await Promise.all([
|
|
setupGrid({
|
|
dbName: "HoverDb",
|
|
fields: [{ name: "Score", type: "number" }],
|
|
rows: [
|
|
{ Name: "Alice", Score: 10 },
|
|
{ Name: "Bob", Score: 20 },
|
|
],
|
|
}),
|
|
setupGrid({
|
|
dbName: "HoverSortedDb",
|
|
fields: [{ name: "Score", type: "number" }],
|
|
rows: [{ Name: "Alice", Score: 10 }],
|
|
sorts: [{ fieldName: "Name", order: "ASC" }],
|
|
}),
|
|
]);
|
|
});
|
|
|
|
test("12.1.1 hovering and unhovering a row toggles the checkbox and row count", async ({
|
|
page,
|
|
}) => {
|
|
const grid = new GridPage(page, gUnsorted.user);
|
|
await grid.goTo(gUnsorted.database, gUnsorted.table);
|
|
|
|
await grid.expectRowCountVisible(0);
|
|
await grid.expectRowCheckboxHidden(0);
|
|
|
|
await grid.hoverRow(0);
|
|
|
|
await grid.expectRowCheckboxVisible(0);
|
|
await grid.expectRowCountHidden(0);
|
|
|
|
await grid.unhoverRow();
|
|
|
|
await grid.expectRowCountVisible(0);
|
|
await grid.expectRowCheckboxHidden(0);
|
|
});
|
|
|
|
test("12.1.2 drag handle is present in an unsorted view and absent when a sort is active", async ({
|
|
page,
|
|
}) => {
|
|
const grid = new GridPage(page, gUnsorted.user);
|
|
await grid.goTo(gUnsorted.database, gUnsorted.table);
|
|
await grid.expectRowDragHandlePresent(0);
|
|
|
|
const sortedGrid = new GridPage(page, gSorted.user);
|
|
await sortedGrid.goTo(gSorted.database, gSorted.table);
|
|
await sortedGrid.expectRowDragHandleAbsent(0);
|
|
});
|
|
});
|
|
|
|
// -----------------------------------------------------------------------------
|
|
// section 12.2 / 14.1 Row context menu and row modal
|
|
// -----------------------------------------------------------------------------
|
|
|
|
test.describe("12.2 Row context menu actions", () => {
|
|
test.describe.configure({ mode: "serial" });
|
|
let g: Setup;
|
|
|
|
test.beforeAll(async () => {
|
|
g = await setupGrid({
|
|
dbName: "ContextMenuDb",
|
|
fields: [{ name: "Score", type: "number" }],
|
|
rows: [
|
|
{ Name: "Alice", Score: 10 },
|
|
{ Name: "Bob", Score: 20 },
|
|
],
|
|
});
|
|
});
|
|
|
|
test.beforeEach(async ({ page }) => {
|
|
await resetRows(g, [
|
|
{ Name: "Alice", Score: 10 },
|
|
{ Name: "Bob", Score: 20 },
|
|
]);
|
|
const grid = new GridPage(page, g.user);
|
|
await grid.goTo(g.database, g.table);
|
|
});
|
|
|
|
test("12.2.1 context-menu insert below creates an empty row below the selected row", async ({
|
|
page,
|
|
}) => {
|
|
const grid = new GridPage(page, g.user);
|
|
|
|
await grid.rightClickRow(0);
|
|
await grid.clickContextItem("Insert row below");
|
|
|
|
await grid.expectRowCount(3);
|
|
await grid.expectPrimaryText(0, "Alice");
|
|
await grid.expectPrimaryEmpty(1);
|
|
await grid.expectPrimaryText(2, "Bob");
|
|
});
|
|
|
|
test("12.2.2 context-menu duplicate creates a copied row directly below the selected row", async ({
|
|
page,
|
|
}) => {
|
|
const grid = new GridPage(page, g.user);
|
|
|
|
await grid.rightClickRow(0);
|
|
await grid.clickContextItem("Duplicate row");
|
|
|
|
await grid.expectRowCount(3);
|
|
await grid.expectPrimaryText(0, "Alice");
|
|
await grid.expectPrimaryText(1, "Alice");
|
|
await grid.expectFieldText(1, 0, "10");
|
|
await grid.expectPrimaryText(2, "Bob");
|
|
});
|
|
|
|
test("14.1.1 context-menu enlarge opens and closes the row edit modal", async ({
|
|
page,
|
|
}) => {
|
|
const grid = new GridPage(page, g.user);
|
|
|
|
await grid.openRowModalFromContext(0);
|
|
await grid.expectRowModalVisibleFor("Alice");
|
|
await grid.closeRowModal();
|
|
});
|
|
});
|
|
|
|
// -----------------------------------------------------------------------------
|
|
// section 14.2 Row edit modal with filters
|
|
// -----------------------------------------------------------------------------
|
|
|
|
test.describe("14.2 Row edit modal with filters", () => {
|
|
test.describe.configure({ mode: "serial" });
|
|
let g: Setup;
|
|
let unfilteredView: View;
|
|
|
|
test.beforeAll(async () => {
|
|
g = await setupGrid({
|
|
dbName: "ModalFilterDb",
|
|
fields: [{ name: "Status", type: "text" }],
|
|
rows: [
|
|
{ Name: "Alice", Status: "keep" },
|
|
{ Name: "Bob", Status: "keep" },
|
|
],
|
|
filters: [{ fieldName: "Status", type: "equal", value: "keep" }],
|
|
});
|
|
unfilteredView = await createGridView(g.user, g.table, {
|
|
name: "All rows",
|
|
});
|
|
});
|
|
|
|
test.beforeEach(async ({ page }) => {
|
|
await resetRows(g, [
|
|
{ Name: "Alice", Status: "keep" },
|
|
{ Name: "Bob", Status: "keep" },
|
|
]);
|
|
const grid = new GridPage(page, g.user);
|
|
await grid.goTo(g.database, g.table, g.view);
|
|
});
|
|
|
|
test("14.2.1 modal edit that stops matching the filter keeps the row visible with a warning until modal close", async ({
|
|
page,
|
|
}) => {
|
|
const grid = new GridPage(page, g.user);
|
|
await grid.expectRowCount(2);
|
|
|
|
await grid.openRowModalFromContext(0);
|
|
await grid.expectRowModalVisibleFor("Alice");
|
|
await grid.fillRowModalTextField("Status", "gone");
|
|
|
|
// The edited row keeps its place with a filter warning instead of being
|
|
// hidden while the modal stays open.
|
|
await grid.expectRowWarningVisible(0);
|
|
await grid.expectRowWarningText(0, "Row does not match filters");
|
|
await grid.expectRowCount(2);
|
|
await grid.expectPrimaryText(0, "Alice");
|
|
await grid.expectPrimaryText(1, "Bob");
|
|
|
|
// A follow-up edit must not hide any other row.
|
|
await grid.fillRowModalTextField("Status", "still gone");
|
|
await grid.expectRowCount(2);
|
|
await grid.expectPrimaryText(1, "Bob");
|
|
|
|
// Closing the modal hides the row that no longer matches.
|
|
await grid.closeRowModal();
|
|
await grid.expectRowCount(1);
|
|
await grid.expectPrimaryText(0, "Bob");
|
|
});
|
|
|
|
test("14.2.2 a row edit modal continues receiving realtime updates after its row stops matching filters", async ({
|
|
page,
|
|
}) => {
|
|
const grid = new GridPage(page, g.user);
|
|
await grid.expectRowCount(2);
|
|
|
|
await grid.openRowModalFromContext(0);
|
|
await grid.expectRowModalVisibleFor("Alice");
|
|
|
|
const otherPage = await page.context().newPage();
|
|
try {
|
|
const otherGrid = new GridPage(otherPage, g.user);
|
|
await otherGrid.goTo(g.database, g.table, unfilteredView);
|
|
await otherGrid.startEditingField(0, 0);
|
|
await otherGrid.type("gone");
|
|
await otherGrid.confirmWithEnter();
|
|
await otherGrid.expectRowCount(2);
|
|
|
|
// The first remote update is the one that removes the row from the filtered
|
|
// grid buffer. The open modal must still receive that exact realtime event.
|
|
await grid.expectRowCount(1);
|
|
await grid.expectRowModalTextFieldValue("Status", "gone");
|
|
|
|
await otherGrid.startEditingField(0, 0);
|
|
await otherGrid.type("still gone");
|
|
await otherGrid.confirmWithEnter();
|
|
|
|
// This follow-up update happens after the row no longer matches the first
|
|
// page's filters, which is the disconnected-modal regression from the review.
|
|
await grid.expectRowModalTextFieldValue("Status", "still gone");
|
|
} finally {
|
|
await otherPage.close();
|
|
}
|
|
});
|
|
});
|
|
|
|
// -----------------------------------------------------------------------------
|
|
// section 13.1 Checkbox row selection
|
|
// -----------------------------------------------------------------------------
|
|
|
|
test.describe("13.1 Checkbox row selection", () => {
|
|
test.describe.configure({ mode: "serial" });
|
|
|
|
let g: Setup;
|
|
let groupBy: Setup;
|
|
|
|
test.beforeAll(async () => {
|
|
g = await setupGrid({
|
|
dbName: "CheckboxSelectionDb",
|
|
fields: [
|
|
{ name: "Score", type: "number" },
|
|
{ name: "Notes", type: "text" },
|
|
],
|
|
rows: [
|
|
{ Name: "Alice", Score: 10, Notes: "note A" },
|
|
{ Name: "Bob", Score: 20, Notes: "note B" },
|
|
],
|
|
});
|
|
groupBy = await setupGrid({
|
|
dbName: "CheckboxSelectionGroupByDb",
|
|
fields: [
|
|
{ name: "Score", type: "number" },
|
|
{ name: "Notes", type: "text" },
|
|
],
|
|
rows: [
|
|
{ Name: "Alice", Score: 10, Notes: "note A" },
|
|
{ Name: "Bob", Score: 20, Notes: "note B" },
|
|
],
|
|
groupBys: [{ fieldName: "Name", order: "ASC" }],
|
|
});
|
|
});
|
|
|
|
test.beforeEach(async ({ page }) => {
|
|
const grid = new GridPage(page, g.user);
|
|
await grid.goTo(g.database, g.table);
|
|
});
|
|
|
|
test("13.1.1 selecting a row checkbox clears an active multi-cell selection", async ({
|
|
page,
|
|
}) => {
|
|
const grid = new GridPage(page, g.user);
|
|
|
|
await grid.selectFieldCell(0, 0);
|
|
await grid.fieldCellAt(1, 1).click({ modifiers: ["Shift"] });
|
|
await grid.expectMultiSelectedCellCount(4);
|
|
|
|
await grid.hoverRow(0);
|
|
await grid.checkboxAt(0).click();
|
|
|
|
await grid.expectRowCheckboxChecked(0);
|
|
await grid.expectMultiSelectedCellCount(0);
|
|
});
|
|
|
|
test("13.1.2 grouped row checkbox selection clears an active multi-cell selection", async ({
|
|
page,
|
|
}) => {
|
|
const grid = new GridPage(page, groupBy.user);
|
|
await grid.goTo(groupBy.database, groupBy.table);
|
|
await grid.expectGroupByBanner("Alice", 1);
|
|
|
|
await grid.selectFieldCell(0, 0);
|
|
await grid.fieldCellAt(1, 1).click({ modifiers: ["Shift"] });
|
|
await grid.expectMultiSelectedCellCount(4);
|
|
|
|
await grid.hoverRow(0);
|
|
await grid.checkboxAt(0).click();
|
|
|
|
await grid.expectRowCheckboxChecked(0);
|
|
await grid.expectMultiSelectedCellCount(0);
|
|
});
|
|
});
|