Skip to content

Fixes #37219: Vitest browser-mode UI integration tests (Pagination migration, marked) + CI - #35623

Merged
chirag-madlani merged 24 commits into
mainfrom
poc/ui-integration-tests
Nov 23, 2026
Merged

chirag-madlani merged 24 commits into
mainfrom
poc/ui-integration-tests

Conversation

@chirag-madlani

@chirag-madlani chirag-madlani commented Oct 16, 2026 •

Copy link
Copy Markdown
Collaborator

Describe your changes:

Base of #36198. This adds UI integration tests in Vitest Browser Mode, with MSW mocking every /api call, to take over page-behaviour checks from heavy Playwright E2E specs. The layering rule is proposed in ADR:2026-10-28-page-behaviour-is-tested-in-vitest-browser-mode-and-e2e-tests-leave-by-marking (status Proposed until the team signs off).

What's here:

  • Harness: Vitest Browser Mode + MSW under src/test/browser/ (renderWithApp / renderApp, typed fixtures, paginationContract.ts). Any unmocked /api/* call fails the test, so no test can pass against a request that failed silently.
  • Migration: of the 39 tests in playwright/e2e/Features/Pagination.spec.ts, 31 are covered by 22 *.browser.test.tsx files (70 tests plus 4 test.fails that pin real bugs). The Playwright tests are not deleted: each covered one is tagged @migrated-browser with its replacement (playwright/constant/migration.ts) and keeps running until the browser tests are validated and PaginationIT covers every list endpoint. The 8 untagged ones: 2 real-server smoke tests, 2 Topic schema fields tests added after this migration, and 4 Data Models / Stored Procedures tests whose browser tests are pinned failing by Data Models and Stored Procedures tabs reset to page 1 after Next #38295. The mapping is in src/test/browser/PAGINATION_MIGRATION.md.
  • Test isolation: setup.ts unmounts before resetting MSW handlers (vitest-browser-react only unmounts in the next test's beforeEach, so a still-mounted page refetched against reset handlers), then resets the URL, localStorage and the app-wide zustand stores. Waits use conditions (network.ts's networkIdle), never fixed sleeps.
  • Coverage: istanbul, written even when a test fails, and shown in the CI job summary. Sonar does not read it yet; that is a follow-up.
  • Agent and contributor instructions:
    • .claude/rules/frontend-browser-tests.md auto-loads on browser tests and Playwright specs. It says which layer a check belongs in (Jest, browser test, Java IT or Playwright journey), how to write a browser test with the shared fixtures, and how to tag a moved Playwright test instead of deleting it.
    • It is indexed in AGENTS.md.
    • frontend-playwright.md and the test-enforcement skill point to it.
  • CI, .github/workflows/ui-browser-tests.yml (new file; no existing workflow is changed):

Type of change:

  • Improvement

High-level design:

  • Layering: pure logic stays in Jest. Page and feature behaviour runs in real Chromium with the real components, router, react-query, i18n and styles; only the network is faked (MSW). API contracts belong in Java ITs. Playwright keeps cross-feature journeys against a real server. See src/test/browser/README.md.
  • Speed so far: from main nightly timing artifacts, Pagination.spec.ts costs 274–495 s of CI worker time, plus the shared stack, build and fixture pipeline. Locally, on a heavily loaded M1 Pro (load 35–60 on 8 cores), the browser suite runs in ~2m14s without coverage, with no backend at all. This PR measures it on a CI runner.
  • Known gap before deleting the marked E2E tests: the cursor walk in PaginationIT is called only for tables. It should cover every list endpoint, so the server side of what moved here stays tested against a real DB.

Tests:

Use cases covered

Pagination across 22 list pages: Next/Previous with cursors and URL sync, deep links, reload, page-size change, search resetting to page 1, empty states, the deleted toggle, the Files ↔ Spreadsheets tab reset, client-side paging, and a visual snapshot of the schema table.

Unit tests

N/A: the change is test infrastructure. Jest is unaffected (*.browser.test.tsx is excluded from Jest).

Backend integration tests

  • Not applicable (no backend API changes).

Ingestion integration tests

  • Not applicable (no ingestion changes).

Playwright (UI) tests

  • Pagination.spec.ts: 35 tests are tagged @migrated-browser, and the 2 real-server smoke tests are untagged.

Manual testing performed

On macOS (M1 Pro):

  1. yarn test:ui:run --maxWorkers=3: 70 passed + 4 expected fail.
  2. yarn test:ui:coverage: the coverage report is written even when a test fails.
  3. Under heavy CPU load the only failures were 15 s testTimeouts, a different test each run.
  4. Jest still skips the browser files.

UI screen recording:

Not applicable: test and CI infrastructure only, no product UI change. (The ObservabilityAlertsTable row-header fix the migration found landed separately on main.)

Checklist:

  • I have read the CONTRIBUTING document.
  • My PR title is Fixes <issue-number>: <short explanation>.
  • My PR is linked to a GitHub issue via Fixes #<issue-number>: Fixes Vitest browser-mode + MSW setup for UI integration tests, with CI #37219.
  • I have commented on my code, particularly in hard-to-understand areas.
  • I have added tests (unit / integration / Playwright as applicable) and listed them above.
  • Decision check: the layering rule is in a decision record, marked Proposed pending team sign-off.

🤖 Generated with Claude Code

RetriggerView in GreptileConfidence Score: 5/5

The PR appears safe to merge, with a non-blocking concern about ANTLR download reliability.

Findings

  1. P2 ANTLR downloads lose their fallback ▶

Summary

Adds Vitest browser tests with MSW, shared pagination checks, migration markers, and a separate CI workflow.

  • UI developers can check real pages in Chromium with mocked API responses.
  • Browser tests check pagination across many UI pages.
  • Playwright pagination tests show their browser-test replacements.
  • UI changes can trigger browser tests and a coverage report in CI.

Reviews (7) · Last reviewed commit: "test(ui): address review on the browser-..." · Reviewed by Greptile

…lure

vitest-browser-react unmounts in the next test's beforeEach, so the global
afterEach reset handlers and the URL under a still-mounted page, which then
refetched and got wrong-shaped responses (unhandled paging/permission errors).
Also write lcov when a test fails so one flake can't drop Sonar coverage.
…nd stability runs

Runs the browser suite with istanbul coverage and posts a Jest-style coverage
and JUnit comment, plus five shuffled no-retry runs whose failures are
summarized in a second comment. Drops the duplicate patch file.
@github-actions github-actions Bot added safe to test Add this label to run secure Github workflows on PRs UI UI specific issues labels Oct 16, 2026
Comment thread .github/workflows/ui-browser-tests.yml Resolved
Comment thread .github/workflows/ui-browser-tests.yml Resolved
@github-actions

github-actions Bot commented Oct 16, 2026 •

Copy link
Copy Markdown
Contributor

UI browser test coverage

…s on failure

main now calls /metadata/types/workflows/approvalEnforcedEntityTypes and
/changeRequests from entity pages, which the strict unmocked-API check caught.
The workflow now records wall time and uploads screenshots even when tests fail.
chirag-madlani and others added 6 commits October 26, 2026 14:57
# Conflicts:
#	openmetadata-ui/src/main/resources/ui/playwright/e2e/Features/Pagination.spec.ts
#	openmetadata-ui/src/main/resources/ui/yarn.lock
main removed it with the antd Form/Select/Input migration (#35509); the app
no longer mounts it.
# Conflicts:
#	openmetadata-ui/src/main/resources/ui/yarn.lock
The shuffled no-retry runs showed the suite stable; the workflow now runs
the browser tests once, with coverage, on UI and core-component changes.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
…owser

The 35 Pagination E2E tests covered by browser tests keep running, tagged
with their replacement, until the browser tests are validated and
PaginationIT walks cursors for every listed entity type. Records the
layering rule as a decision.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
Skips the coverage comment on fork PRs and lets it fail without failing
the job; formats three browser-test files.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
@chirag-madlani chirag-madlani changed the title POC: Vitest browser-mode UI integration tests (migrate Pagination.spec.ts) + CI Vitest browser-mode UI integration tests (Pagination migration, marked) + CI Oct 28, 2026
@pmbrull
pmbrull requested a review from reethika-pd November 3, 2026 16:33
@chirag-madlani chirag-madlani changed the title Vitest browser-mode UI integration tests (Pagination migration, marked) + CI Fixes #37219: Vitest browser-mode UI integration tests (Pagination migration, marked) + CI Nov 6, 2026
chirag-madlani and others added 2 commits November 6, 2026 18:09
# Conflicts:
#	openmetadata-ui/src/main/resources/ui/package.json
#	openmetadata-ui/src/main/resources/ui/yarn.lock
A path-scoped rule for browser tests and Playwright specs: pick the layer
(Jest, browser test, Java IT, Playwright journey), write a browser test
with the shared fixtures, and tag a moved Playwright test instead of
deleting it. The Playwright rule and test-enforcement skill point to it.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
Comment thread .claude/rules/frontend-browser-tests.md Resolved
@open-metadata open-metadata deleted a comment from github-actions Bot Nov 6, 2026
chirag-madlani and others added 2 commits November 6, 2026 18:25
…izes

Main added GET /domains/styles and /ontologyConcepts/boundTo calls to
every entity page, and moved list pages to 15/25/50 (#35288); the
browser tests now answer both calls and read PAGE_SIZE_BASE.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
Copilot AI balanced review requested due to automatic review settings November 18, 2026 11:36

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Copilot was unable to review this pull request because the user who requested the review has insufficient remaining quota. Try requesting a review at a lower effort level.

# Conflicts:
#	openmetadata-ui/src/main/resources/ui/package.json
#	openmetadata-ui/src/main/resources/ui/yarn.lock
Copilot AI balanced review requested due to automatic review settings November 20, 2026 09:19

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Copilot was unable to review this pull request because the user who requested the review has insufficient remaining quota. Try requesting a review at a lower effort level.

…ar path

Search hits now come back in a different order from the list, and the
contract asserts the visible rows after search, Next and reload, so a page
that sends the right request but keeps showing old rows fails. Sonar never
receives browser coverage yet, so its lcov path is dropped. The agent rule
names only helpers that exist on this branch.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
Copilot AI balanced review requested due to automatic review settings November 20, 2026 09:22

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Copilot was unable to review this pull request because the user who requested the review has insufficient remaining quota. Try requesting a review at a lower effort level.

…contract

settle() slept 300 ms. The contract now waits until MSW has nothing in
flight and no new request for a short quiet window, which is what a
request count needs to be final; render waits poll for the row.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
Copilot AI balanced review requested due to automatic review settings November 20, 2026 10:11

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Copilot was unable to review this pull request because the user who requested the review has insufficient remaining quota. Try requesting a review at a lower effort level.

Copilot AI balanced review requested due to automatic review settings November 20, 2026 10:14

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Copilot was unable to review this pull request because the user who requested the review has insufficient remaining quota. Try requesting a review at a lower effort level.

@harsh-vador harsh-vador left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for putting this together. Strict unmocked-API failures and unmounting before handlers reset are both good calls, and the spec diff is only tags plus reflow, which I checked with whitespace ignored.

Main things before this goes in:

  • Some of the description and docs don't match the diff: the Sonar lcov, the coverage comment, the workflow trigger, the test counts, and the a11y fix.
  • The test.fails pins on Data Models and Stored Procedures, combined with the @migrated-browser tags, would leave those flows without coverage once the E2E tests are deleted.
  • The ADR is marked Accepted ahead of team sign-off.

The rest are smaller suggestions inline.

Comment thread .github/workflows/ui-browser-tests.yml Resolved
Comment thread .github/workflows/ui-browser-tests.yml Resolved
- Data Models and Stored Procedures: their browser tests are pinned failing
  by a product bug (#38295), so their Playwright tests stay untagged;
  double fetch filed as #38296. Migration doc counts and rows updated.
- Decision record is Proposed until the team signs off.
- No Sonar claims (it does not read browser coverage yet); no unused JUnit.
- The workflow also runs on setup-action changes; the setup action caches
  Chromium and the ANTLR CLI.
- setup.ts resets the app-wide zustand stores between tests.
- networkIdle counts /api requests only and notes its quiet-window limit.
- Screenshot comparison runs on Linux only (its baseline's platform).
- Contract: two-page assumption checked, empty-record guard, isListPage
  shared, search mock scope documented; msw resolutions dropped.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
Copilot AI balanced review requested due to automatic review settings November 20, 2026 11:19

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Copilot was unable to review this pull request because the user who requested the review has insufficient remaining quota. Try requesting a review at a lower effort level.

@gitar-bot

gitar-bot Bot commented Nov 20, 2026

Copy link
Copy Markdown
Code Review ✅ Approved 🟡 Medium risk 5 closed / 5 findings

The new Chromium browser-test workflow adds a separate UI CI job and coverage reporting, which could disrupt PR feedback if setup or reporting fails.

Adds Vitest Browser Mode and MSW UI integration tests for pagination, a layering decision record, and a separate browser-test CI workflow. Resolved this session: the stability run wall-time and count issue, the missing real-server cursor paging coverage, the missing decision record in docs/decisions/, and the failure-screenshot upload skipped when the comment step fails. No open findings remain.

✅ 5 closed
✅ Bug: Stability run loses wall time and counts whenever a test fails

📄 .github/workflows/ui-browser-tests.yml:42-45 📄 .github/workflows/ui-browser-tests.yml:88-92 📄 .github/workflows/ui-browser-tests.yml:121-126
GitHub runs run: scripts with bash -e. When yarn test:ui:run exits non-zero, the script stops before the line that writes timing.json. The report's jq -rs ... results.json timing.json then fails, and the row prints n/a | no results instead of the run's pass/fail counts and wall time. So any run with a failing test, which is exactly the run you want to inspect, shows no numbers. The same thing happens in browser-tests: the seconds output is never written on failure. Capture the exit status, write the timing file, then exit with that status.

✅ Quality: E2E pagination deleted while real-server cursor paging stays untested

📄 openmetadata-ui/src/main/resources/ui/playwright/e2e/Features/Pagination.spec.ts:28-38 📄 openmetadata-ui/src/main/resources/ui/src/test/browser/PAGINATION_MIGRATION.md:37-42
This PR cuts 35 Playwright tests that paged through ~18 list endpoints (roles, policies, bots, alerts, data models, stored procedures, drive files, etc.) against a real backend. Their replacements are MSW tests, and those can only check that the UI agrees with fixtures/paging.ts#cursorPage, which the test author wrote. They cannot check what the server actually returns. The PR's own PAGINATION_MIGRATION.md (the * gap note) says the server-side replacement isn't there yet, and the repo confirms it: testPaginationForEntityType is only called for "table" (PaginationIT.java:83-85), and BaseEntityIT only checks that a list is non-empty. So once this merges, a cursor regression on any of those endpoints, such as a wrong before cursor or a duplicated last row, would pass every suite. The description puts this under "Known gap before deleting more E2E", but this PR already does the deleting. Either keep the Playwright cases until the IT cursor walk covers each listed entity type, or add that @ParameterizedTest in this PR.

✅ Quality: Test-layering decision is not in docs/decisions/

📄 openmetadata-ui/src/main/resources/ui/src/test/browser/README.md:13-20 📄 openmetadata-ui/src/main/resources/ui/sonar-project.properties:12 📄 openmetadata-ui/src/main/resources/ui/playwright/e2e/Features/Pagination.spec.ts:28-37
This PR makes a lasting rule and records it only in the PR body and in src/test/browser/README.md. No record in docs/decisions/ states it. A record would say something like: "Per-page list UI behaviour (cursor/URL sync, reload, page size, search reset, deleted toggle) is tested in Vitest browser mode with MSW (*.browser.test.tsx). Playwright keeps only real-server smoke tests for it, and every unmocked /api/* call fails a browser test." That rule comes from the description's "Layering: pure logic stays in Jest. Page and feature behaviour runs in real Chromium … Playwright keeps cross-feature journeys against a real server." Separately, merging the browser lcov into the Sonar gate (sonar.typescript.lcov.reportPaths) changes how the coverage gate is computed, which is a second decision. The description says an ADR will follow if the approach is adopted. It needs to land in this PR, because this PR already deletes the E2E tests and changes the Sonar inputs.

✅ Bug: Comment step failure skips failure-screenshot upload; forks fail

📄 .github/workflows/ui-browser-tests.yml:46-60 📄 .github/workflows/ui-browser-tests.yml:140-141
The steps Upload failure screenshots and Fail if tests failed use if: steps.tests.outcome == 'failure' with no status function, so GitHub treats them as success() && .... If Coverage comment fails, both steps are skipped. That happens when coverage-summary.json is missing because vitest crashed, or on a fork PR, where GITHUB_TOKEN is read-only and pull-requests: write is not granted. Failure screenshots are then never uploaded. On fork PRs the job and the stability report comment step also go red even when every test passes. Fix: add always() to the failure-handling steps, and skip comment posting for fork PRs.

Closed: Quality: Browser-test rule tells agents to use helpers that don't exist in tree

📄 .claude/rules/frontend-browser-tests.md:33-41
The new rule tells agents to reuse serveEntity, servePersona, server.patches, scaled(ms) / suiteTimeout(ms) from src/test/browser/timeouts.ts, and openPicker / setSelected. None of these exist on this branch. src/test/browser/ holds only msw.ts, setup.ts, renderWithApp.tsx, paginationContract.ts, and fixtures/{entities,hierarchy,paging,table,user}.ts. Of the helpers the rule names, only serveSearch, renderApp and renderWithApp are defined, and the stacked PR #36198 doesn't add the missing ones under src/test/browser either. Any agent this rule loads for (every playwright/e2e/** and browser-test file) will import a module that doesn't exist, such as timeouts.ts, or search for helpers that aren't there. Because the rule also says "rather than writing new handlers" and "Do not add sleeps or retries", it steers the agent away from the workarounds it would otherwise use. Fix: either drop these bullets until the helpers land, or limit them to what exists today (renderApp, renderWithApp, serveSearch, the factories in fixtures/).

Verification

Rules No rules evaluated

Functional validation Not enabled

Set up

Auto-approval Not enabled

Set up

For more verification details, comment gitar display:verbose.

Options

Display: compact → Showing compact verification results.

Comment with these commands to change the behavior for this request:

Compact
gitar display:verbose         

Was this helpful? React with 👍 / 👎 | Powered by Gitar — free for open source

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

safe to test Add this label to run secure Github workflows on PRs UI UI specific issues

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Vitest browser-mode + MSW setup for UI integration tests, with CI

3 participants