Skip to content

feat(ui-test): Playwright ui tests helpers + per-test scenarios stage 1#2196

Draft
cjlg-soloio wants to merge 9 commits into
kagent-dev:mainfrom
cjlg-soloio:feat(ui)--Playwright-tests-foundation-stage-2
Draft

feat(ui-test): Playwright ui tests helpers + per-test scenarios stage 1#2196
cjlg-soloio wants to merge 9 commits into
kagent-dev:mainfrom
cjlg-soloio:feat(ui)--Playwright-tests-foundation-stage-2

Conversation

@cjlg-soloio

@cjlg-soloio cjlg-soloio commented Jul 9, 2026

Copy link
Copy Markdown

Description

Stage 1 of the Playwright UI E2E suite — builds on the Stage 0 foundation to unlock non-happy-path testing and add a small, proven driver surface.

Depends on #2180 (Stage 0).

Stage 0 could only serve a fixed happy path, so specs couldn't cover empty/error states and there were no reusable driver helpers. This stage adds:

  • Scenario-override engine in the stub backend — POST /__mock/scenario sets a per-endpoint { status, body } override; POST /__mock/reset clears them. Default stays the happy path.
  • Typed control seam (mocks/control.ts) surfaced as a mock fixture: mock.noAgents(), mock.agentsError(), etc. The fixture resets the stub before every test, so scenarios never leak between tests.
  • Driver helperspage.ts (loadPage, expectNoErrors, expectToast) and nav.ts (dropdown-aware gotoView / gotoCreate).
  • Specs exercising the new machinery: a home spec (happy / empty / error) and a nav spec (dropdown routing across sections).

Form/select/dialog helpers are intentionally deferred to Stage 2, built demand-driven against the real create-agent flow. See ui/playwright/README.md.

Files

New

File Purpose
ui/playwright/mocks/control.ts Semantic mock seam over /__mock/* (makeMock): noAgents, agentsError, noModelConfigs, noToolServers, setScenario, reset
ui/playwright/helpers/page.ts loadPage, expectNoErrors, expectToast (sonner)
ui/playwright/helpers/nav.ts Dropdown-aware gotoView / gotoCreate / gotoHome
ui/playwright/tests/home.spec.ts Agents list: happy / empty / error states
ui/playwright/tests/nav.spec.ts Header dropdown navigation across sections

Modified

  • ui/playwright/mocks/server.mjs — scenario-override engine (/__mock/scenario, /__mock/reset) layered over the happy-path defaults
  • ui/playwright/mocks/data.tsok() success-envelope helper for scenario payloads
  • ui/playwright/fixtures/test.ts — exposes the mock fixture; page depends on it so the stub resets before every test
  • ui/playwright/README.md — layout + roadmap updated for Stage 1

Testing

cd ui
npm run test:pw

Playwright boots the stub backend and dev server automatically. The home spec drives the mock through three states — the seeded agent (happy path), mock.noAgents() (empty state), and mock.agentsError() (error state) — and the nav spec walks the header dropdown from Agents → Models → MCP. Runs serially (workers: 1) against the shared stub; CI runs the same on any ui/** change.

Change type

test — extends the Playwright test infrastructure. No product or runtime code changed.

Changelog

Stage 2 of 3 playwright tests for ui

cjlg-soloio and others added 9 commits July 8, 2026 15:50
Signed-off-by: Carlos Logroño Guerrero <carlos.logrono@solo.io>
Co-authored-by: Copilot Autofix powered by AI <175728472+Copilot@users.noreply.github.com>
Signed-off-by: cjlg-soloio <carlos.logrono@solo.io>
Signed-off-by: Carlos Logroño Guerrero <carlos.logrono@solo.io>
- Force single Playwright worker unconditionally (shared stub + Next server)
- Default req.method/req.url before parsing in the stub server
- Fail fast on stub reset failure in CI; stay non-fatal locally
- Drop unused pull-requests:write permission from the workflow

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
Signed-off-by: Carlos Logroño Guerrero <carlos.logrono@solo.io>
Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
Signed-off-by: Carlos Logroño Guerrero <carlos.logrono@solo.io>
Pairs fullyParallel with workers: 1 so both stay off until per-test data
isolation lands, preventing tests from silently racing against the shared
stub backend if the worker count is raised.

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
Signed-off-by: Carlos Logroño Guerrero <carlos.logrono@solo.io>
- Pin STUB_PORT on the stub webServer so a shell-set STUB_PORT can't misbind it
- Stop reusing the dev server so BACKEND_INTERNAL_URL always applies (no silent stub bypass)
- Type ToolServerListEntry as the real RemoteMCPServerResponse for compile-time drift detection
- Drop no-op **/*.mjs from the playwright tsconfig include

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
Signed-off-by: Carlos Logroño Guerrero <carlos.logrono@solo.io>
Builds on the Stage 0 foundation to unlock non-happy-path testing and give
specs a small, proven driver surface:

- Scenario-override engine in the stub backend: POST /__mock/scenario sets a
  per-endpoint { status, body } override; /__mock/reset clears them. Default
  stays the happy path.
- Typed control seam (mocks/control.ts) surfaced as a `mock` fixture
  (mock.noAgents(), mock.agentsError(), ...); the fixture resets the stub
  before every test so scenarios never leak between tests.
- page.ts (loadPage, expectNoErrors, expectToast) and nav.ts (dropdown-aware
  gotoView/gotoCreate) driver helpers.
- home spec (happy / empty / error) proving the engine, and a nav spec proving
  dropdown routing.

Form/select/dialog helpers are deferred to Stage 2 (built demand-driven with the
create-agent flow).

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
Signed-off-by: Carlos Logroño Guerrero <carlos.logrono@solo.io>
@github-actions github-actions Bot added enhancement New feature or request and removed enhancement New feature or request labels Jul 9, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

enhancement New feature or request

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant