Skip to content

feat(ui-test): Playwright ui tests foundation stage 0#2262

Open
cjlg-soloio wants to merge 19 commits into
kagent-dev:mainfrom
cjlg-soloio:cjlg-soloio/playwrightTestsStage1
Open

feat(ui-test): Playwright ui tests foundation stage 0#2262
cjlg-soloio wants to merge 19 commits into
kagent-dev:mainfrom
cjlg-soloio:cjlg-soloio/playwrightTestsStage1

Conversation

@cjlg-soloio

Copy link
Copy Markdown
Contributor

Description

Adds the Stage 0 foundation for Playwright page-level E2E testing of the kagent UI, running against a mocked backend with no cluster required.

The suite targets the one gap nothing else covers — multi-step user flows across components:

Tool Covers
Storybook / Chromatic Component render states
Jest Logic
Cypress Page-load smoke
Playwright (this PR) Cross-component user flows

The core design challenge: the UI fetches data server-side via Next.js server actions, so browser-level page.route("**/api/**") intercepts nothing. Instead, this PR boots a dependency-free stub backend and redirects Next's server-side fetch to it via BACKEND_INTERNAL_URL — which getBackendUrl() in ui/src/lib/utils.ts already honors. Playwright's webServer block starts both the stub (:8899) and next dev (:8001) automatically.

This is foundation-only: config, stub backend, shared fixture, CI workflow, and a single smoke test. The helper/driver library and per-test scenarios land in Stage 1; feature flows in Stage 3 (see ui/playwright/README.md).

Files

New

File Purpose
ui/playwright.config.ts Boots stub + dev server; chromium project; CI-aware retries/workers; trace & screenshot on failure
ui/playwright/mocks/server.mjs Dependency-free stub backend (Node http only); serves happy-path payloads mirroring src/types/index.ts; exposes /__mock/health & /__mock/reset
ui/playwright/mocks/data.ts Typed spec-side data builders mirroring the stub's shapes
ui/playwright/fixtures/test.ts Shared test/expect fixture; resets stub per test and bypasses first-run onboarding
ui/playwright/tests/smoke.spec.ts Stage 0 smoke test — asserts the Agents list renders against the mock
ui/playwright/tsconfig.json Extends UI tsconfig with node + Playwright types
ui/playwright/README.md Test strategy, mocking rationale, conventions, roadmap
.github/workflows/ui-playwright.yaml Standalone CI workflow (paths-filtered to ui/**); installs chromium, runs test:pw, uploads report

Modified

  • ui/package.json@playwright/test dev dep + test:pw / test:pw:ui / test:pw:debug scripts
  • ui/package-lock.json — lockfile updates
  • ui/.gitignore — ignores playwright-report, playwright/test-results, playwright/.cache

Testing

cd ui
npm install
npx playwright install chromium   # first time only
npm run test:pw

Playwright starts the stub backend and dev server automatically. The smoke test passes when the home page renders the Agents, no "Error Encountered" state appears, and no uncaught page errors occur. CI runs the same on any ui/** change.

Change type

test / ci — new test infrastructure and CI workflow. No product or runtime code changed.

Changelog

Stage 1 of 3 playwright tests for ui

cjlg-soloio and others added 13 commits July 13, 2026 15:12
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>
…ght video

Resolve Charlesthebird's review on PR kagent-dev#2180:
- Playwright workflow now reads node-version-file: ui/.nvmrc instead of a
  hardcoded major version.
- Remove Cypress entirely: delete cypress.config.ts and cypress/e2e/smoke.cy.ts,
  drop the cypress and now-unused start-server-and-test devDeps plus the
  test:e2e/test:e2e:cypress scripts, and remove the dead CYPRESS_INSTALL_BINARY
  env from the ui-playwright, ci, and ui-chromatic workflows and the Dockerfile.
- Enable Playwright video recording (video: "on"); artifacts already upload via
  the existing test-results step.
- De-Cypress the Playwright README (Jest, Vitest, Storybook untouched).

data.ts is intentionally kept — it is consumed by the stacked stage-2 PR.

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
Signed-off-by: Carlos Logroño Guerrero <carlos.logrono@solo.io>
Restore a conventional test:e2e entrypoint pointing at the Playwright
suite, per review feedback on kagent-dev#2180.

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>
@github-actions github-actions Bot added the enhancement New feature or request label Jul 15, 2026
@cjlg-soloio
cjlg-soloio marked this pull request as ready for review July 15, 2026 14:33
@cjlg-soloio
cjlg-soloio requested a review from peterj as a code owner July 15, 2026 14:33
Copilot AI review requested due to automatic review settings July 15, 2026 14:33

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.

Pull request overview

Introduces a Stage 0 Playwright E2E testing foundation for the ui/ Next.js app, running against a local stub backend to enable cross-component flow testing without requiring a Kubernetes cluster.

Changes:

  • Adds Playwright configuration, fixtures, a stub backend, and an initial smoke test for the Agents page.
  • Adds a dedicated GitHub Actions workflow to run Playwright on ui/** changes and upload reports/artifacts.
  • Removes Cypress E2E scaffolding and related CI/Dockerfile knobs in favor of Playwright.

Reviewed changes

Copilot reviewed 15 out of 16 changed files in this pull request and generated 3 comments.

Show a summary per file
File Description
ui/playwright.config.ts Playwright runner config that boots the stub backend + next dev via webServer.
ui/playwright/fixtures/test.ts Shared fixture that resets the stub and bypasses onboarding for deterministic tests.
ui/playwright/tests/smoke.spec.ts Stage 0 smoke test asserting the Agents page renders and no fatal page errors occur.
ui/playwright/mocks/server.mjs Dependency-free Node http stub backend serving /api/* happy-path responses plus control/health endpoints.
ui/playwright/mocks/data.ts Typed mock builders for spec-side assertions / future scenario injection.
ui/playwright/tsconfig.json TS config for Playwright tests/types, extending the UI’s TS config.
ui/playwright/README.md Documentation for scope, mocking approach (server-side fetch redirection), conventions, and roadmap.
.github/workflows/ui-playwright.yaml New CI workflow to run Playwright against the stubbed backend and upload reports.
ui/package.json Adds @playwright/test and Playwright scripts; maps test:e2e to Playwright.
ui/package-lock.json Lockfile updates for Playwright/Cypress dependency changes.
ui/.gitignore Ignores Playwright report and test-results outputs.
ui/Dockerfile Removes CYPRESS_INSTALL_BINARY since Cypress is no longer used.
.github/workflows/ui-chromatic.yaml Removes Cypress-related env var from UI dependency install step.
.github/workflows/ci.yaml Removes Cypress-related env var from UI dependency install step.
ui/cypress/e2e/smoke.cy.ts Removes Cypress smoke/regression E2E spec.
ui/cypress.config.ts Removes Cypress configuration.
Files not reviewed (1)
  • ui/package-lock.json: Generated file

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment thread ui/playwright/fixtures/test.ts Outdated
Comment thread ui/playwright.config.ts
Comment thread ui/package.json
- rename fixture callback param to `provide` (drops the rules-of-hooks eslint-disable)
- record video only on failure to match screenshot/trace
- pin @playwright/test and playwright to aligned 1.61.1

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
Signed-off-by: Carlos Logroño Guerrero <carlos.logrono@solo.io>
peterj and others added 2 commits July 15, 2026 18:42
Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
Signed-off-by: Carlos Logroño Guerrero <carlos.logrono@solo.io>
Signed-off-by: Carlos Logroño Guerrero <carlos.logrono@solo.io>
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.

5 participants