Files
baserow/docs/development/e2e-testing.md
T
Davide Silvestri 0aa7147db3 Collapsible group-by grid view (#5470)
* 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
2026-07-03 09:09:52 +02:00

7.3 KiB

End-to-End Testing

Baserow includes an end-to-end test suite in the e2e-tests folder using Playwright to run UI tests against a running Baserow instance.

Prerequisites

  • Docker - For running the E2E environment
  • Node.js - For running Playwright tests
  • Yarn - Package manager
  • just - Command runner

See supported.md for minimum version requirements.

# Verify installation
docker --version
node -v
yarn -v
just --version

Quick Start

# Full E2E cycle: build images, start environment, run tests, stop
just e2e run

# Or step by step:
just e2e build    # Build CI images
just e2e up       # Start E2E environment
just e2e test     # Run tests
just e2e down     # Stop and cleanup

Access during testing:

The e2e stack intentionally uses 3070/8070 by default so it does not collide with the default dev stack (3000/8000) or the documented alternate dev stacks (3010/8010 and 3020/8020), and leaves 3030-3060/ 8030-8060 free for additional dev instances.

Commands Reference

Command Description
just e2e build Build backend and frontend CI images
just e2e up Start E2E environment (db, redis, backend, frontend)
just e2e down Stop and remove all E2E containers
just e2e test Run all E2E tests
just e2e test <args> Run tests with Playwright arguments
just e2e run Full cycle: build, up, test, down
just e2e logs View all container logs
just e2e logs <service> View logs for specific service
just e2e db-dump Generate fresh database dump
just e2e db-restore <container> Restore dump to a container

Examples

Running Specific Tests

# Run a specific test file
just e2e test tests/auth/login.spec.ts
just e2e test tests/database/search.spec.ts

# Run all tests in a directory
just e2e test tests/database/
just e2e test tests/builder/

# Run tests matching a pattern
just e2e test --grep "login"

# Run in headed mode (see the browser)
just e2e test --headed

# Run in UI mode (interactive debugging)
just e2e test --ui

# Run only in Chrome
just e2e test --project=chromium

Viewing Logs

# All logs
just e2e logs

# Specific service
just e2e logs backend
just e2e logs frontend
just e2e logs db
just e2e logs celery

Debugging Failed Tests

# Start environment without running tests
just e2e up

# Run tests in UI mode for debugging
just e2e test --ui

# Or run specific failing test with trace
just e2e test tests/mytest.spec.ts --trace on

# Keep environment running for manual inspection
# Access http://localhost:3070 in your browser

Regenerating Database Dump

When migrations change, regenerate the E2E database dump:

# Generate new dump with latest migrations
just e2e db-dump

# Commit the updated dump
git add e2e-tests/fixtures/e2e-db.dump
git commit -m "Update E2E database dump"

How It Works

The E2E environment uses:

  1. Pre-built CI images - Backend and frontend built with test dependencies
  2. Database dump - Pre-migrated database restored on startup (fast)
  3. tmpfs storage - PostgreSQL and Redis run in-memory for speed
  4. Isolated network - All containers on baserow-e2e network

Container Architecture

┌─────────────────────────────────────────────────────────┐
│                    baserow-e2e network                  │
│                                                         │
│  ┌──────────┐  ┌──────────┐  ┌──────────┐  ┌─────────┐ │
│  │  e2e-db  │  │e2e-redis │  │e2e-backend│  │e2e-celery│ │
│  │ (tmpfs)  │  │ (tmpfs)  │  │  :8000   │  │         │ │
│  └──────────┘  └──────────┘  └──────────┘  └─────────┘ │
│                                     │                   │
│                              ┌──────────────┐           │
│                              │ e2e-frontend │           │
│                              │    :3000     │           │
│                              └──────────────┘           │
└─────────────────────────────────────────────────────────┘
                                    │
                              Playwright tests

When to Write E2E Tests

Consider adding E2E tests for:

  1. Multi-service UX flows - Like duplicating a database
  2. Complex frontend interactions - Hard to test with unit tests
  3. API serialization boundaries - Frontend-backend integration
  4. Critical features - Features that often break across browsers
  5. Cross-browser issues - Browser-specific bugs

Configuration

Environment Variables

Variable Description Default
E2E_FRONTEND_PORT Host port published by just e2e up for the frontend 3070
E2E_BACKEND_PORT Host port published by just e2e up for the backend API 8070
E2E_FRONTEND_COOKIE_PREFIX Cookie prefix used by the e2e frontend to avoid same-host auth cookie collisions baserow_e2e_
PUBLIC_WEB_FRONTEND_URL Frontend URL for tests http://localhost:3070
PUBLIC_BACKEND_URL Backend API URL for tests http://localhost:8070
BASEROW_FRONTEND_COOKIE_PREFIX Cookie prefix expected by Playwright helpers when tests write frontend cookies directly baserow_e2e_

You can set these in e2e-tests/.env (see .env-example).

When running the deprecated run-e2e-tests-locally.sh script against a normal local dev environment, it keeps using 3000/8000 and an empty cookie prefix unless you override the variables above.

Playwright Configuration

See e2e-tests/playwright.config.ts for:

  • Browser configuration
  • Test timeouts
  • Retry settings
  • Reporter configuration

Writing Tests

Test Generation

Playwright can help generate test skeletons:

cd e2e-tests
yarn codegen

This opens a browser where your actions are recorded as test code. Use it as a starting point, but clean up the generated code.

Best Practices

  1. Use page object patterns for reusable components
  2. Wait for elements explicitly rather than using timeouts
  3. Use data-testid attributes for reliable selectors
  4. Clean up test data after tests when possible

Deprecated: Old Workflow

Note: The commands below are deprecated. Use just e2e commands instead.

Old Installation

# Using dev.sh (deprecated)
./dev.sh
cd e2e-tests
./run-e2e-tests-locally.sh

# Manual yarn commands still work if environment is running:
yarn test          # headless
yarn test-headed   # see browser
yarn test-ui       # interactive debugging
yarn codegen       # generate test code

These still work but require manually managing the dev environment. The new just e2e commands handle everything automatically.