Skip to content

Open-source AI teammates in Slack, Teams, Discord, Telegram and Mattermost. Self-host it, with any agent harness and any model.

Add a browser lane: the gateway UI in headless Chromium

Petr Bauch6572b41b5ae4
diff --git a/.github/workflows/e2e-scheduled.yml b/.github/workflows/e2e-scheduled.yml
index 471588ceb..f2c18e345 100644
--- a/.github/workflows/e2e-scheduled.yml
+++ b/.github/workflows/e2e-scheduled.yml
@@ -5,8 +5,9 @@ name: E2E scheduled
#
# after a merge to main the provider lane on a throwaway stack. Real model
# calls, so not on every PR, and never a required check
-# nightly the provider lane again, and the fast lane against
-# dev, then one summary notification for the night
+# nightly the provider lane again, the fast and browser lanes
+# against dev, then one summary notification for the
+# night
#
# A failed run after a merge is reported too, since the lane is not a required
# check and nothing else would surface it before the night; a passing one is
@@ -54,9 +55,18 @@ jobs:
environment: dev
agent_type: claude-code
+ browser-dev:
+ name: Browser lane on dev
+ if: ${{ github.event_name != 'push' }}
+ uses: ./.github/workflows/e2e.yml
+ with:
+ lane: browser
+ environment: dev
+ agent_type: claude-code
+
notify:
name: Report
- needs: [provider, fast-dev]
+ needs: [provider, fast-dev, browser-dev]
if: ${{ always() && github.event_name != 'workflow_dispatch' }}
runs-on: ubuntu-latest
steps:
@@ -68,6 +78,8 @@ jobs:
PROVIDER_SUMMARY: ${{ needs.provider.outputs.summary }}
DEV_RESULT: ${{ needs.fast-dev.result }}
DEV_SUMMARY: ${{ needs.fast-dev.outputs.summary }}
+ BROWSER_RESULT: ${{ needs.browser-dev.result }}
+ BROWSER_SUMMARY: ${{ needs.browser-dev.outputs.summary }}
run: |
if [ "$GITHUB_EVENT_NAME" = push ] && [ "$PROVIDER_RESULT" = success ]; then
echo "The provider lane passed after the merge; nothing to report."
@@ -83,9 +95,10 @@ jobs:
"$(line 'Provider lane (ephemeral)' "$PROVIDER_RESULT" "$PROVIDER_SUMMARY")" \
"$RUN_URL")"
else
- text="$(printf 'Switch E2E nightly\n%s\n%s\n%s' \
+ text="$(printf 'Switch E2E nightly\n%s\n%s\n%s\n%s' \
"$(line 'Provider lane (ephemeral)' "$PROVIDER_RESULT" "$PROVIDER_SUMMARY")" \
"$(line 'Fast lane (dev)' "$DEV_RESULT" "$DEV_SUMMARY")" \
+ "$(line 'Browser lane (dev)' "$BROWSER_RESULT" "$BROWSER_SUMMARY")" \
"$RUN_URL")"
fi
echo "$text"
diff --git a/.github/workflows/e2e.yml b/.github/workflows/e2e.yml
index aaf9e5cc0..b781cf34c 100644
--- a/.github/workflows/e2e.yml
+++ b/.github/workflows/e2e.yml
@@ -7,6 +7,8 @@ name: E2E
#
# lane fast provider-free scenarios over plain HTTP
# provider real agent sessions on a headless agent controller
+# browser the gateway UI in headless Chromium; on ephemeral the
+# UI is built from this checkout
# environment ephemeral a fresh stack on the runner, built from this checkout
# dev, staging an existing deployment, configured by the GitHub
# Environment of that name
@@ -17,7 +19,8 @@ name: E2E
# GitHub Environment, whose protection rules decide which refs may run it:
#
# e2e-provider secret ANTHROPIC_API_KEY, for the controller's Claude Code
-# dev, staging vars SWITCH_API_URL, MATTERMOST_URL, MATTERMOST_TEAM; secrets
+# dev, staging vars SWITCH_API_URL, MATTERMOST_URL, MATTERMOST_TEAM, and
+# SWITCH_GATEWAY_UI_URL for the browser lane; secrets
# SWITCH_GATEWAY_ADMIN_EMAIL, SWITCH_GATEWAY_ADMIN_PASSWORD,
# SWITCH_AGENT_REGISTRATION_TOKEN, MATTERMOST_TOKEN
#
@@ -50,7 +53,7 @@ on:
inputs:
lane:
type: choice
- options: [fast, provider]
+ options: [fast, provider, browser]
default: fast
environment:
type: choice
@@ -96,7 +99,7 @@ jobs:
env:
AGENT_TYPE: ${{ inputs.agent_type }}
run: |
- case "$LANE" in fast|provider) ;; *) echo "::error::Unknown lane '$LANE'."; exit 1 ;; esac
+ case "$LANE" in fast|provider|browser) ;; *) echo "::error::Unknown lane '$LANE'."; exit 1 ;; esac
case "$TARGET" in ephemeral|dev|staging) ;; *) echo "::error::Unknown environment '$TARGET'."; exit 1 ;; esac
if [ "$LANE" = provider ] && [ "$TARGET" != ephemeral ]; then
echo "::error::The provider lane runs on an ephemeral stack only."; exit 1
@@ -128,6 +131,11 @@ jobs:
working-directory: console
run: pnpm install --frozen-lockfile
+ - name: Install Chromium
+ if: ${{ inputs.lane == 'browser' }}
+ working-directory: console/tooling-e2e
+ run: pnpm exec playwright install --with-deps chromium
+
- name: Install Claude Code
if: ${{ inputs.lane == 'provider' }}
run: npm install -g @anthropic-ai/[email protected]
@@ -167,19 +175,23 @@ jobs:
MATTERMOST_URL: ${{ vars.MATTERMOST_URL }}
MATTERMOST_TOKEN: ${{ secrets.MATTERMOST_TOKEN }}
MATTERMOST_TEAM: ${{ vars.MATTERMOST_TEAM }}
+ SWITCH_GATEWAY_UI_URL: ${{ vars.SWITCH_GATEWAY_UI_URL }}
SWITCH_E2E_SECRETS_FILE: ${{ runner.temp }}/issued-secrets
+ SWITCH_E2E_OUTPUT_DIR: ${{ env.OUT }}
run: |
mkdir -p "$OUT"
pnpm exec vitest run --reporter=verbose --reporter=junit --outputFile.junit="$OUT/junit.xml" \
2>&1 | tee "$OUT/vitest.log"
- # What interrupted runs left behind. The floor keeps it off a run still in
- # progress, which is why it can run after every suite.
+ # What interrupted runs left behind, whichever lane made it; cleanup
+ # resolves as the fast lane, which needs nothing a lane adds. The floor
+ # keeps it off a run still in progress, which is why it can run after
+ # every suite.
- name: Remove stale harness artefacts from ${{ inputs.environment }}
if: ${{ always() && inputs.environment != 'ephemeral' }}
working-directory: console/tooling-e2e
env:
- SWITCH_E2E_LANE: ${{ inputs.lane }}
+ SWITCH_E2E_LANE: fast
SWITCH_E2E_ENVIRONMENT: ${{ inputs.environment }}
SWITCH_E2E_STRICT: '1'
SWITCH_API_URL: ${{ vars.SWITCH_API_URL }}
diff --git a/console/pnpm-lock.yaml b/console/pnpm-lock.yaml
index dcef7ff62..b45355452 100644
--- a/console/pnpm-lock.yaml
+++ b/console/pnpm-lock.yaml
@@ -479,6 +479,9 @@ importers:
tooling-e2e:
devDependencies:
+ playwright:
+ specifier: 1.60.0
+ version: 1.60.0
typescript:
specifier: ^5.9.2
version: 5.9.3
diff --git a/console/tooling-e2e/README.md b/console/tooling-e2e/README.md
index ba4b01eb4..f5f6c8151 100644
--- a/console/tooling-e2e/README.md
+++ b/console/tooling-e2e/README.md
@@ -1,8 +1,8 @@
# `@switch-console/tooling-e2e`
End-to-end tests for Switch: **real messages through a real Switch server**, and
-through a real Mattermost bridge where a scenario crosses one. One package, two
-runner modes:
+through a real Mattermost bridge where a scenario crosses one. One package,
+three lanes:
- **The fast lane** needs no provider, no Switch Console and no LLM key. The
harness plays every participant over plain HTTP: it registers throwaway
@@ -12,6 +12,10 @@ runner modes:
- **The provider lane** needs a real agent session (Switch Console or its
sidecar) attending the room, and checks what that session does: answering,
asking a question, asking for approval, being interrupted.
+- **The browser lane** drives the gateway UI in headless Chromium against the
+ same server: signing in, every page in the navigation rail, a room opened
+ from the list, signing out. A page that renders but is broken (an uncaught
+ error, a request the server failed, an error banner) fails it.
Nothing here talks to Switch Console directly. If a scenario passes, an operator
doing the same thing by hand would have seen the same result.
@@ -28,6 +32,11 @@ just e2e-fast --keep # leave the stack running afterwards
just e2e-fast -- -t mattermost # arguments after -- go to vitest
```
+`just e2e-browser` does the same for the browser lane. It also builds the
+gateway UI from `gateway/` and serves it on :4173 with `vite preview`, whose
+proxy sends `/gateway` requests to the server as nginx does in a deployment.
+On first run Playwright installs its Chromium.
+
Its log, JUnit report and the stack's per-run secrets go to `build/e2e/ephemeral/`.
The repository's own `.env` is never read or written.
@@ -37,6 +46,7 @@ from this directory:
```bash
SWITCH_E2E_LANE=fast pnpm test
SWITCH_E2E_LANE=provider pnpm test
+SWITCH_E2E_LANE=browser SWITCH_GATEWAY_UI_URL=http://localhost:5173 pnpm test # just gateway-dev
```
With `SWITCH_E2E_LANE` unset every end-to-end scenario is skipped, which is
@@ -65,7 +75,8 @@ Typecheck: `pnpm typecheck`.
| `src/fixtures/` | Throwaway agents and rooms for a scenario, the bridge-readiness probe, teardown |
| `src/fast/` | Fast-lane scenarios, one file per area, listed in `index.ts` |
| `src/provider/` | The provider lane: Console credential files, the shared agent and channel, the scenarios, `seed.ts` |
-| `scripts/ephemeral-stack.sh` | The throwaway-stack runner behind `just e2e-fast` and `just e2e-provider` |
+| `src/browser/` | The browser lane: the gateway UI driver (`gateway-ui.ts`) and the scenarios, listed in `index.ts` |
+| `scripts/ephemeral-stack.sh` | The throwaway-stack runner behind `just e2e-fast`, `just e2e-provider` and `just e2e-browser` |
| `scripts/scan-artifacts.sh` | Fails if a run's output holds one of the secrets the run used |
| `src/ci-summary.ts` | The CI run summary, read from the JUnit report |
| `src/gate/` | The coverage gate |
@@ -74,13 +85,13 @@ Typecheck: `pnpm typecheck`.
## Scenarios and their headers
-Every scenario, in either lane, carries a header:
+Every scenario, in any lane, carries a header:
```ts
{
- id: 'addressed-delivery', // kebab-case, unique across both lanes
+ id: 'addressed-delivery', // kebab-case, unique across every lane
covers: ['POST /agents/{agent_id}/message', 'list_rooms'],
- needsProvider: false, // true puts it in the provider lane
+ lane: 'fast', // 'fast', 'provider' or 'browser'
environments: ['ephemeral', 'local', 'dev', 'staging'],
owner: 'platform', // a team or role, never a person
requires: ['mattermost'], // what must be configured
@@ -119,6 +130,25 @@ passed or not. A teardown that leaves something behind fails the scenario.
If `mattermost-roundtrip` passes and a provider-lane scenario fails, the fault
is in the agent session, not in Switch, the bridge or the harness.
+### Browser lane
+
+Each scenario gets a fresh browser context, signed out. What it needs in the
+server it creates over HTTP through the same fixtures as the fast lane. Beyond
+its own assertions, a scenario fails on anything that went wrong on its pages:
+an uncaught page error, a console error, a `/gateway` request the server
+answered with a 5xx (or any 4xx once signed in), or an error banner. A failed
+scenario's last page is saved under `screenshots/` in the output directory.
+
+| Scenario | What it drives |
+| --- | --- |
+| `gateway-sign-in` | The login form signs the admin in, and the app opens on the rooms list. |
+| `gateway-every-page` | Every link in the navigation rail opens its page without an error. It follows the rail, so a page added there is visited without this changing. |
+| `gateway-room-from-list` | A room made over the API is listed, and its page opens from the list. |
+| `gateway-sign-out` | Signing out returns to the login form, and the app stays there. |
+
+None runs against `prod`: a page may write on load, and the browser goes
+around the clients' read-only guard.
+
## Naming, isolation and the read-only guard
Everything the harness creates is named `e2e-<runId><scope>-<role>`: the run,
@@ -143,7 +173,7 @@ beside this file. Never commit one. `just e2e-fast` sets all of them itself.
| Variable | Required | Meaning |
| --- | --- | --- |
-| `SWITCH_E2E_LANE` | to run anything | `fast` or `provider`. Unset, every end-to-end scenario skips. |
+| `SWITCH_E2E_LANE` | to run anything | `fast`, `provider` or `browser`. Unset, every end-to-end scenario skips. |
| `SWITCH_E2E_ENVIRONMENT` | yes | `ephemeral`, `local`, `dev`, `staging` or `prod`. Decides which scenarios run, and makes `prod` read-only. |
| `SWITCH_API_URL` | yes | Switch origin — serves both `/agents/…` and `/gateway/…`. |
| `SWITCH_GATEWAY_ADMIN_EMAIL` | yes | Gateway admin account. |
@@ -156,6 +186,8 @@ beside this file. Never commit one. `just e2e-fast` sets all of them itself.
| `SWITCH_E2E_KEEP` | no | `1` leaves agents, rooms and channels behind for inspection. |
| `SWITCH_E2E_SERVER_LOG` | no | The server's log, written with `LOG_FORMAT=json`. When set, a scenario fails if the server logged an error while it ran. The stack script sets it. |
| `SWITCH_E2E_SECRETS_FILE` | no | File to append each credential the server issues during the run to (agent keys, gateway sessions), for CI's scan of the output. The stack script and `e2e.yml` set it. |
+| `SWITCH_GATEWAY_UI_URL` | browser lane | Where the gateway UI is served. Its `/gateway` requests must reach `SWITCH_API_URL`. `just e2e-browser` sets it. |
+| `SWITCH_E2E_OUTPUT_DIR` | no | Where the browser lane saves screenshots of failed pages. The stack script and `e2e.yml` set it. |
| `SWITCH_E2E_AGENT_DIR` | provider lane | Working directory of the session under test. When set, the agent's credentials are written into it (see below) and it is sent to Switch as the agent's `repo_dir`. |
| `SWITCH_E2E_MANIFEST` | provider lane | File the setup records its agent and room in, so a second process can reuse them. See "Seeding first". |
| `SWITCH_E2E_REPLY_TIMEOUT_MS` | provider lane | How long a scenario waits for the agent (default 5 min). |
@@ -305,14 +337,14 @@ dispatched by hand.
| --- | --- | --- | --- |
| Every PR, and every push to main (`pr-ci.yml`) | fast | ephemeral | yes |
| After a merge to main (`e2e-scheduled.yml`) | provider | ephemeral | no |
-| Nightly (`e2e-scheduled.yml`) | provider; fast | ephemeral; dev | no |
+| Nightly (`e2e-scheduled.yml`) | provider; fast; browser | ephemeral; dev; dev | no |
- **Secrets.** An ephemeral fast run generates every secret it uses on the
runner, so it works the same on a fork PR. Every other run reads its secrets
from a GitHub Environment:
- `e2e-provider` holds `ANTHROPIC_API_KEY`;
- - `dev` and `staging` hold the deployment's URLs as variables and its
- credentials as secrets.
+ - `dev` and `staging` hold the deployment's URLs as variables (the browser
+ lane also needs `SWITCH_GATEWAY_UI_URL`) and its credentials as secrets.
The header of `e2e.yml` lists every name. Each environment's protection rules
decide which branches may use it.
diff --git a/console/tooling-e2e/package.json b/console/tooling-e2e/package.json
index c327f7f8b..3443bdcf3 100644
--- a/console/tooling-e2e/package.json
+++ b/console/tooling-e2e/package.json
@@ -11,6 +11,7 @@
"typecheck": "tsc --noEmit"
},
"devDependencies": {
+ "playwright": "1.60.0",
"typescript": "^5.9.2",
"vitest": "^5.0.1"
}
diff --git a/console/tooling-e2e/scripts/ephemeral-stack.sh b/console/tooling-e2e/scripts/ephemeral-stack.sh
index fb51d331a..169f436d2 100755
--- a/console/tooling-e2e/scripts/ephemeral-stack.sh
+++ b/console/tooling-e2e/scripts/ephemeral-stack.sh
@@ -5,6 +5,7 @@
#
# just e2e-fast the fast lane (no provider, no Console)
# just e2e-provider the provider lane, on a headless agent controller
+# just e2e-browser the browser lane: the gateway UI in headless Chromium
# just e2e-fast --keep leave the stack running afterwards
# just e2e-fast -- <vitest args> pass arguments through to vitest
#
@@ -18,7 +19,11 @@
# own .env is never read or written, so this cannot rotate a developer's live
# secrets or pick up a stale value from them.
#
-# Ports 5432, 8000, 8065 and 8081 must be free: stop a local stack first.
+# The browser lane also builds the gateway UI from gateway/ and serves it with
+# `vite preview` on :4173, whose proxy sends its /gateway requests to :8000 as
+# nginx does in a deployment, and installs Playwright's Chromium.
+#
+# Ports 4173, 5432, 8000, 8065 and 8081 must be free: stop a local stack first.
# Logs and the JUnit report go to build/e2e/ephemeral/ (or $E2E_OUT); the env
# file, the controller's state and the agent's working directory go to a
# temporary directory, so the output holds nothing secret by construction.
@@ -45,7 +50,7 @@ done
for tool in docker uv openssl curl jq lsof; do
command -v "$tool" >/dev/null || { echo "$tool is required but not on PATH." >&2; exit 1; }
done
-for port in 5432 8000 8065 8081; do
+for port in 4173 5432 8000 8065 8081; do
if lsof -nP -iTCP:"$port" -sTCP:LISTEN >/dev/null 2>&1; then
echo "Port $port is in use. Stop your local stack first ('just down', and any 'just run')." >&2
exit 1
@@ -65,6 +70,7 @@ COMPOSE=(docker compose -p switch-e2e-ephemeral -f deploy/local/docker-compose.y
--env-file "$ENV_FILE" --project-directory .)
SERVER_PID=""
CONTROLLER_PID=""
+UI_PID=""
cleanup() {
local status=$?
# Every step runs whatever the one before it did: a process that exits
@@ -72,13 +78,14 @@ cleanup() {
# of $WORK.
set +e
if [ "$KEEP" = 0 ]; then
+ [ -n "$UI_PID" ] && kill "$UI_PID" 2>/dev/null && wait "$UI_PID" 2>/dev/null
[ -n "$CONTROLLER_PID" ] && kill "$CONTROLLER_PID" 2>/dev/null && wait "$CONTROLLER_PID" 2>/dev/null
[ -n "$SERVER_PID" ] && kill "$SERVER_PID" 2>/dev/null && wait "$SERVER_PID" 2>/dev/null
"${COMPOSE[@]}" down -v >/dev/null 2>&1 || true
else
- echo "Left running: switch-core :8000 (pid $SERVER_PID), Mattermost :8065${CONTROLLER_PID:+, agent controller (pid $CONTROLLER_PID)}."
+ echo "Left running: switch-core :8000 (pid $SERVER_PID), Mattermost :8065${CONTROLLER_PID:+, agent controller (pid $CONTROLLER_PID)}${UI_PID:+, gateway UI :4173 (pid $UI_PID)}."
echo "Secrets and state for this stack: $WORK. Tear down with:"
- echo " kill $SERVER_PID $CONTROLLER_PID; ${COMPOSE[*]} down -v; rm -rf $WORK"
+ echo " kill $SERVER_PID $CONTROLLER_PID $UI_PID; ${COMPOSE[*]} down -v; rm -rf $WORK"
fi
if "$HARNESS/scripts/scan-artifacts.sh" "$OUT" <"$SECRETS"; then
: >"$OUT/.secret-scan-passed"
@@ -215,11 +222,28 @@ if [ "$LANE" = provider ]; then
PROVIDER_ENV=(SWITCH_E2E_CONTROLLER_ID="$CONTROLLER_ID" SWITCH_E2E_AGENT_DIR="$WORK/agent-dir")
fi
+BROWSER_ENV=()
+if [ "$LANE" = browser ]; then
+ echo "Building the gateway UI…"
+ (cd "$REPO/gateway" && npm ci --no-audit --no-fund && npm run build) >"$OUT/gateway-build.log" 2>&1 \
+ || { echo "gateway UI build failed; see $OUT/gateway-build.log" >&2; exit 1; }
+ (cd "$HARNESS" && pnpm exec playwright install chromium) >"$OUT/playwright-install.log" 2>&1 \
+ || { echo "installing Playwright's Chromium failed; see $OUT/playwright-install.log" >&2; exit 1; }
+ (cd "$REPO/gateway" && exec node_modules/.bin/vite preview --host 127.0.0.1 --port 4173 --strictPort) \
+ >"$OUT/gateway-ui.log" 2>&1 &
+ UI_PID=$!
+ for _ in $(seq 30); do curl -sf localhost:4173/ >/dev/null && break; sleep 1; done
+ curl -sf localhost:4173/ >/dev/null \
+ || { echo "the gateway UI did not come up; see $OUT/gateway-ui.log" >&2; exit 1; }
+ BROWSER_ENV=(SWITCH_GATEWAY_UI_URL=http://127.0.0.1:4173 SWITCH_E2E_OUTPUT_DIR="$OUT")
+fi
+
echo "Running the $LANE lane…"
status=0
(
cd "$HARNESS"
if [ ${#PROVIDER_ENV[@]} -gt 0 ]; then export "${PROVIDER_ENV[@]}"; fi
+ if [ ${#BROWSER_ENV[@]} -gt 0 ]; then export "${BROWSER_ENV[@]}"; fi
# The credentials the harness is issued, for the scan on exit.
export SWITCH_E2E_SECRETS_FILE="$SECRETS"
# What the server logs, so a scenario during which it logs an error fails.
@@ -241,5 +265,6 @@ status=0
if [ "$status" != 0 ]; then
echo "The $LANE lane failed. switch-core log: $OUT/switch-core.log" >&2
[ "$LANE" = provider ] && echo "Agent controller log: $OUT/controller.log" >&2
+ [ "$LANE" = browser ] && echo "Screenshots of failed pages: $OUT/screenshots" >&2
fi
exit "$status"
diff --git a/console/tooling-e2e/src/browser/browser.e2e.test.ts b/console/tooling-e2e/src/browser/browser.e2e.test.ts
new file mode 100644
index 000000000..08dd29422
--- /dev/null
+++ b/console/tooling-e2e/src/browser/browser.e2e.test.ts
@@ -0,0 +1,117 @@
+import { mkdirSync } from 'node:fs';
+import path from 'node:path';
+import { chromium, type Browser } from 'playwright';
+import { afterAll, beforeAll, describe, expect, it } from 'vitest';
+import { describeEnv } from '../core/env.ts';
+import { RunContext } from '../core/run.ts';
+import { admit, assertValidHeaders } from '../core/scenario.ts';
+import { IssuedSecrets } from '../core/secrets.ts';
+import {
+ describeErrors,
+ describeServerLogCheck,
+ ScenarioObserver,
+ type ServerLogError,
+} from '../core/server-log.ts';
+import { resolveLane, type LaneResolution } from '../core/suite.ts';
+import { Fixtures } from '../fixtures/fixtures.ts';
+import { GatewayUi } from './gateway-ui.ts';
+import { BROWSER_SCENARIOS } from './index.ts';
+
+/**
+ * The browser lane: the gateway UI in headless Chromium, against the server
+ * its `/gateway` requests reach. Runs when `SWITCH_E2E_LANE=browser`, with
+ * `SWITCH_GATEWAY_UI_URL` naming where the UI is served.
+ *
+ * Each scenario gets a fresh browser context, so no session carries over. A
+ * scenario fails on its own assertions, on what went wrong on its pages
+ * (`GatewayUi`), on what it left behind, and on errors the server logged while
+ * it ran, in that order. A failed scenario's last page is saved as a
+ * screenshot under `SWITCH_E2E_OUTPUT_DIR`, when that is set.
+ */
+
+assertValidHeaders(BROWSER_SCENARIOS.map((scenario) => scenario.header));
+
+const run = new RunContext();
+let lane: LaneResolution;
+let browser: Browser | null = null;
+
+beforeAll(async () => {
+ lane = await resolveLane('browser');
+ if (!lane.target) return;
+ console.log(`browser lane run ${run.runId}: ${describeEnv(lane.target.env)}`);
+ console.log(` ${describeServerLogCheck(lane.target.env.serverLog)}`);
+ if (lane.target.env.gatewayUiUrl !== null) browser = await chromium.launch();
+}, 120_000);
+
+afterAll(async () => {
+ await browser?.close();
+});
+
+describe('browser lane', () => {
+ for (const scenario of BROWSER_SCENARIOS) {
+ it(scenario.header.id, async (context) => {
+ if (!lane.target) return context.skip(lane.skip);
+ const { env, switchClient, mattermost } = lane.target;
+
+ const admission = admit(scenario.header, env);
+ if (!admission.run) {
+ if (admission.failure) {
+ throw new Error(
+ `${scenario.header.id} cannot run (SWITCH_E2E_STRICT=1): ${admission.reason}`
+ );
+ }
+ return context.skip(admission.reason);
+ }
+ if (browser === null || env.gatewayUiUrl === null) {
+ throw new Error('The browser was not launched although the scenario was admitted.');
+ }
+
+ const names = run.scope();
+ const fixtures = new Fixtures(env, names, switchClient, mattermost);
+ const log = (message: string): void => console.log(`[${scenario.header.id}] ${message}`);
+ const browserContext = await browser.newContext();
+ const page = await browserContext.newPage();
+ const ui = new GatewayUi(
+ browserContext,
+ page,
+ env.gatewayUiUrl,
+ env.switch,
+ new IssuedSecrets(env.secretsFile)
+ );
+ const observer = new ScenarioObserver(env.serverLog, switchClient, names.tag);
+ let failure: unknown = null;
+ try {
+ await scenario.run({ env, names, switchClient, fixtures, ui, log });
+ } catch (error) {
+ failure = error;
+ }
+ const problems = [...ui.recorded()];
+ if ((failure !== null || problems.length > 0) && env.outputDir !== null) {
+ const dir = path.join(env.outputDir, 'screenshots');
+ mkdirSync(dir, { recursive: true });
+ const file = path.join(dir, `${scenario.header.id}.png`);
+ await ui.screenshot(file);
+ log(`screenshot of the last page: ${file}`);
+ }
+ await browserContext.close();
+ const leftovers = await fixtures.teardown();
+ for (const line of leftovers) log(`teardown: ${line}`);
+ const serverErrors = await observer.finish();
+ if (serverErrors !== null && serverErrors.length > 0) {
+ log(`the server logged errors:\n ${describeErrors(serverErrors, observer.tag)}`);
+ }
+ if (failure !== null) throw failure;
+ expect(problems, `the pages went wrong:\n ${problems.join('\n ')}\n`).toEqual([]);
+ if (!env.keepArtifacts) expect(leftovers, 'teardown left artefacts behind').toEqual([]);
+ expectNoServerErrors(serverErrors, observer.tag);
+ });
+ }
+});
+
+function expectNoServerErrors(errors: ServerLogError[] | null, tag: string): void {
+ if (errors === null) return;
+ expect(
+ errors,
+ `the server logged errors while this ran:\n ${describeErrors(errors, tag)}\n`
+ ).toEqual([]);
+}
diff --git a/console/tooling-e2e/src/browser/gateway-ui.ts b/console/tooling-e2e/src/browser/gateway-ui.ts
new file mode 100644
index 000000000..2c464f8b4
--- /dev/null
+++ b/console/tooling-e2e/src/browser/gateway-ui.ts
@@ -0,0 +1,165 @@
+import type { BrowserContext, ConsoleMessage, Locator, Page, Response } from 'playwright';
+import { expect } from 'vitest';
+import type { SwitchEnv } from '../core/env.ts';
+import type { IssuedSecrets } from '../core/secrets.ts';
+
+/** The session cookie the gateway sets on sign-in. */
+const SESSION_COOKIE = 'switch_auth';
+
+/**
+ * The gateway UI in one browser context, and everything that went wrong on its
+ * pages while a scenario drove it.
+ *
+ * A page can render and still be broken: a React error caught by nothing, a
+ * request the server answered with a 500 that the page shows as an empty
+ * table. So every page error, every console error, and every `/gateway`
+ * response the server failed is recorded, and the suite fails a scenario that
+ * left any, whether or not its own assertions passed.
+ *
+ * A 4xx is the page's business (a 401 is how the login page learns there is no
+ * session) and is recorded only when the scenario says it was signed in, where
+ * none is expected.
+ */
+export class GatewayUi {
+ readonly page: Page;
+ private readonly context: BrowserContext;
+ private readonly baseUrl: string;
+ private readonly credentials: SwitchEnv;
+ private readonly secrets: IssuedSecrets;
+ private readonly problems: string[] = [];
+ private signedIn = false;
+
+ constructor(
+ context: BrowserContext,
+ page: Page,
+ baseUrl: string,
+ credentials: SwitchEnv,
+ secrets: IssuedSecrets
+ ) {
+ this.context = context;
+ this.page = page;
+ this.baseUrl = baseUrl;
+ this.credentials = credentials;
+ this.secrets = secrets;
+ page.on('pageerror', (error) => this.problems.push(`page error: ${error.message}`));
+ page.on('console', (entry) => this.onConsole(entry));
+ page.on('response', (response) => this.onResponse(response));
+ page.on('requestfailed', (request) => {
+ if (!this.isGatewayApi(request.url())) return;
+ this.problems.push(
+ `${request.method()} ${this.pathOf(request.url())} failed: ${request.failure()?.errorText ?? 'unknown'}`
+ );
+ });
+ }
+
+ /** Every problem recorded on the pages so far. */
+ recorded(): readonly string[] {
+ return this.problems;
+ }
+
+ async goto(path: string): Promise<void> {
+ await this.page.goto(`${this.baseUrl}${path}`);
+ }
+
+ /** Sign in through the login form as the gateway admin, and land on the rooms page. */
+ async signIn(): Promise<void> {
+ await this.goto('/');
+ await expect.poll(() => this.path(), { timeout: 15_000 }).toBe('/login');
+ await this.page.getByLabel('Email').fill(this.credentials.gatewayAdminEmail);
+ await this.page.getByLabel('Password').fill(this.credentials.gatewayAdminPassword);
+ await this.page.getByRole('button', { name: 'Sign in' }).click();
+ await expect.poll(() => this.path(), { timeout: 15_000 }).toBe('/rooms');
+ await this.recordSessionCookie();
+ this.signedIn = true;
+ }
+
+ async signOut(): Promise<void> {
+ await this.page.getByRole('button', { name: 'Account menu' }).click();
+ await this.page.getByRole('menuitem', { name: 'Sign out' }).click();
+ this.signedIn = false;
+ await expect.poll(() => this.path(), { timeout: 15_000 }).toBe('/login');
+ }
+
+ /** The path the app is showing. */
+ path(): string {
+ return new URL(this.page.url()).pathname;
+ }
+
+ /** The navigation rail. */
+ nav(): Locator {
+ return this.page.getByRole('navigation', { name: 'Main' });
+ }
+
+ /** The navigation rail's links, by label, as the signed-in user sees them. */
+ async navLinks(): Promise<{ label: string; path: string }[]> {
+ const nav = this.nav();
+ await expect.poll(() => nav.getByRole('link').count(), { timeout: 15_000 }).toBeGreaterThan(0);
+ const links: { label: string; path: string }[] = [];
+ for (const link of await nav.getByRole('link').all()) {
+ const href = await link.getAttribute('href');
+ const label = (await link.innerText()).trim();
+ if (href !== null && href.startsWith('/')) links.push({ label, path: href });
+ }
+ return links;
+ }
+
+ /**
+ * Wait until the page has stopped fetching, then fail on an error it shows.
+ * MUI renders every error banner as an `alert`; a page with nothing wrong
+ * shows none with error severity.
+ */
+ async settled(): Promise<void> {
+ await this.page.waitForLoadState('networkidle');
+ const alerts = this.page.locator('[role="alert"].MuiAlert-colorError');
+ const shown = await alerts.allInnerTexts();
+ for (const text of shown) this.problems.push(`${this.path()} shows an error: ${text.trim()}`);
+ }
+
+ async screenshot(file: string): Promise<void> {
+ await this.page.screenshot({ path: file, fullPage: true });
+ }
+
+ /**
+ * The session cookie is a credential the server issued the harness, valid
+ * until it expires on a shared deployment, so it goes to the run's issued
+ * secrets for the artefact scan.
+ */
+ private async recordSessionCookie(): Promise<void> {
+ const cookies = await this.context.cookies();
+ const session = cookies.find((cookie) => cookie.name === SESSION_COOKIE);
+ if (session === undefined) {
+ throw new Error(
+ `Signed in, but the gateway set no ${SESSION_COOKIE} cookie (cookies: ${cookies.map((c) => c.name).join(', ') || 'none'}).`
+ );
+ }
+ this.secrets.record(session.value);
+ }
+
+ private onConsole(entry: ConsoleMessage): void {
+ if (entry.type() !== 'error') return;
+ // The browser's own line for a failed response; `onResponse` judges those.
+ if (entry.text().startsWith('Failed to load resource')) return;
+ this.problems.push(`console error on ${this.path()}: ${entry.text().slice(0, 300)}`);
+ }
+
+ private onResponse(response: Response): void {
+ if (!this.isGatewayApi(response.url())) return;
+ const status = response.status();
+ const failed = status >= 500 || (this.signedIn && status >= 400);
+ if (!failed) return;
+ this.problems.push(
+ `${response.request().method()} ${this.pathOf(response.url())} answered ${status} on ${this.path()}`
+ );
+ }
+
+ private isGatewayApi(url: string): boolean {
+ const parsed = new URL(url);
+ return (
+ parsed.origin === new URL(this.baseUrl).origin && parsed.pathname.startsWith('/gateway/')
+ );
+ }
+
+ private pathOf(url: string): string {
+ return new URL(url).pathname;
+ }
+}
diff --git a/console/tooling-e2e/src/browser/index.ts b/console/tooling-e2e/src/browser/index.ts
new file mode 100644
index 000000000..d4109c130
--- /dev/null
+++ b/console/tooling-e2e/src/browser/index.ts
@@ -0,0 +1,75 @@
+import { expect } from 'vitest';
+import { browserHeader, type BrowserScenario } from './scenario.ts';
+
+/** The login form signs the admin in, and the app opens on the rooms list. */
+const signIn: BrowserScenario = {
+ header: browserHeader('gateway-sign-in', [
+ 'GET /gateway/auth/config',
+ 'POST /gateway/auth/login',
+ 'GET /gateway/auth/session',
+ ]),
+ async run({ ui }) {
+ await ui.signIn();
+ await expect
+ .poll(() => ui.page.getByRole('heading', { name: 'Rooms', level: 5 }).isVisible())
+ .toBe(true);
+ await ui.settled();
+ },
+};
+
+/**
+ * Every page in the navigation rail opens without an error: each link the
+ * signed-in admin is shown, so a page added to the rail is visited without
+ * this list changing.
+ */
+const everyPage: BrowserScenario = {
+ header: browserHeader('gateway-every-page', ['GET /gateway/rooms', 'GET /gateway/agents']),
+ async run({ ui, log }) {
+ await ui.signIn();
+ const links = await ui.navLinks();
+ expect(links.map((link) => link.path)).toEqual(expect.arrayContaining(['/rooms', '/agents']));
+ for (const link of links) {
+ await ui.nav().getByRole('link', { name: link.label }).click();
+ await expect.poll(() => ui.path()).toBe(link.path);
+ await ui.settled();
+ log(`${link.label} (${link.path}) opened`);
+ }
+ },
+};
+
+/** A room made over the API is listed, and its page opens from the list. */
+const roomFromList: BrowserScenario = {
+ header: browserHeader('gateway-room-from-list', ['GET /gateway/rooms/{room_id}']),
+ async run({ ui, fixtures }) {
+ const agent = await fixtures.agent('member');
+ const room = await fixtures.internalRoom('room', [agent]);
+ await ui.signIn();
+ const row = ui.page.getByRole('row').filter({ hasText: room.name });
+ await expect.poll(() => row.count(), { timeout: 15_000 }).toBe(1);
+ await row.click();
+ await expect.poll(() => ui.path()).toBe(`/rooms/${room.id}`);
+ await expect
+ .poll(() => ui.page.getByRole('heading', { name: room.name }).isVisible())
+ .toBe(true);
+ await ui.settled();
+ },
+};
+
+/** Signing out ends the session: the app returns to the login form and stays there. */
+const signOut: BrowserScenario = {
+ header: browserHeader('gateway-sign-out', ['POST /gateway/auth/logout']),
+ async run({ ui }) {
+ await ui.signIn();
+ await ui.signOut();
+ await ui.goto('/rooms');
+ await expect.poll(() => ui.path(), { timeout: 15_000 }).toBe('/login');
+ },
+};
+
+/** Every browser-lane scenario. A scenario not listed here does not run. */
+export const BROWSER_SCENARIOS: readonly BrowserScenario[] = [
+ signIn,
+ everyPage,
+ roomFromList,
+ signOut,
+];
diff --git a/console/tooling-e2e/src/browser/scenario.ts b/console/tooling-e2e/src/browser/scenario.ts
new file mode 100644
index 000000000..f65dc6907
--- /dev/null
+++ b/console/tooling-e2e/src/browser/scenario.ts
@@ -0,0 +1,48 @@
+import type { SwitchClient } from '../clients/switch-client.ts';
+import type { HarnessEnv } from '../core/env.ts';
+import type { NameScope } from '../core/run.ts';
+import type { ScenarioHeader } from '../core/scenario.ts';
+import type { Fixtures } from '../fixtures/fixtures.ts';
+import type { GatewayUi } from './gateway-ui.ts';
+
+/**
+ * A browser-lane scenario: the gateway UI driven in a fresh headless browser
+ * context, signed out at the start. What it needs in the server it creates
+ * over HTTP through `fixtures`, which tears it down afterwards.
+ */
+export interface BrowserScenario {
+ header: ScenarioHeader;
+ run(context: BrowserScenarioContext): Promise<void>;
+}
+
+export interface BrowserScenarioContext {
+ env: HarnessEnv;
+ names: NameScope;
+ switchClient: SwitchClient;
+ fixtures: Fixtures;
+ ui: GatewayUi;
+ log: (message: string) => void;
+}
+
+/**
+ * Where a browser scenario runs: anywhere but prod. Signing in and loading
+ * pages writes nothing a scenario asks for, but a page is free to write on
+ * load, and the browser goes around the clients' read-only guard.
+ */
+export const BROWSER_ENVIRONMENTS: ScenarioHeader['environments'] = [
+ 'ephemeral',
+ 'local',
+ 'dev',
+ 'staging',
+];
+
+export function browserHeader(id: string, covers: string[]): ScenarioHeader {
+ return {
+ id,
+ covers,
+ lane: 'browser',
+ environments: BROWSER_ENVIRONMENTS,
+ owner: 'platform',
+ requires: ['gateway-ui'],
+ };
+}
diff --git a/console/tooling-e2e/src/core/core.test.ts b/console/tooling-e2e/src/core/core.test.ts
index 0912da1e2..d75afe182 100644
--- a/console/tooling-e2e/src/core/core.test.ts
+++ b/console/tooling-e2e/src/core/core.test.ts
@@ -2,19 +2,14 @@ import { mkdtempSync, readFileSync, rmSync } from 'node:fs';
import { tmpdir } from 'node:os';
import path from 'node:path';
import { describe, expect, it } from 'vitest';
+import { BROWSER_SCENARIOS } from '../browser/index.ts';
import { olderThanFrom, timestampMs } from '../cleanup.ts';
import { FAST_SCENARIOS } from '../fast/index.ts';
import { SCENARIOS as PROVIDER_SCENARIOS } from '../provider/scenarios.ts';
import { laneFrom, loadEnv, MissingConfigError, strictFrom, type HarnessEnv } from './env.ts';
import { assertAllowed, ReadOnlyEnvironmentError } from './guard.ts';
import { isValidMattermostUsername, RunContext } from './run.ts';
-import {
- admit,
- assertValidHeaders,
- headerProblems,
- laneOf,
- type ScenarioHeader,
-} from './scenario.ts';
+import { admit, assertValidHeaders, headerProblems, type ScenarioHeader } from './scenario.ts';
import { IssuedSecrets } from './secrets.ts';
const BASE = {
@@ -106,7 +101,7 @@ describe('run naming', () => {
const header = (overrides: Partial<ScenarioHeader> = {}): ScenarioHeader => ({
id: 'some-scenario',
covers: ['list_rooms', 'POST /agents/{agent_id}/message'],
- needsProvider: false,
+ lane: 'fast',
environments: ['ephemeral', 'dev'],
owner: 'platform',
requires: [],
@@ -129,7 +124,7 @@ describe('scenario headers', () => {
});
it('keeps provider scenarios off prod', () => {
- expect(headerProblems(header({ needsProvider: true, environments: ['prod'] }))).toHaveLength(1);
+ expect(headerProblems(header({ lane: 'provider', environments: ['prod'] }))).toHaveLength(1);
});
it('refuses a duplicated id', () => {
@@ -139,9 +134,11 @@ describe('scenario headers', () => {
it('holds for every scenario in the suite, with ids unique across lanes', () => {
const fast = FAST_SCENARIOS.map((scenario) => scenario.header);
const provider = PROVIDER_SCENARIOS.map((scenario) => scenario.header);
- expect(() => assertValidHeaders([...fast, ...provider])).not.toThrow();
- expect(fast.every((h) => laneOf(h) === 'fast')).toBe(true);
- expect(provider.every((h) => laneOf(h) === 'provider')).toBe(true);
+ const browser = BROWSER_SCENARIOS.map((scenario) => scenario.header);
+ expect(() => assertValidHeaders([...fast, ...provider, ...browser])).not.toThrow();
+ expect(fast.every((h) => h.lane === 'fast')).toBe(true);
+ expect(provider.every((h) => h.lane === 'provider')).toBe(true);
+ expect(browser.every((h) => h.lane === 'browser')).toBe(true);
});
});
@@ -151,7 +148,7 @@ describe('admission', () => {
});
it('passes over the other lane and unlisted environments without failing', () => {
- expect(admit(header({ needsProvider: true }), env())).toMatchObject({
+ expect(admit(header({ lane: 'provider' }), env())).toMatchObject({
run: false,
failure: false,
});
diff --git a/console/tooling-e2e/src/core/env.ts b/console/tooling-e2e/src/core/env.ts
index 4c25a0d9a..59d5e0f09 100644
--- a/console/tooling-e2e/src/core/env.ts
+++ b/console/tooling-e2e/src/core/env.ts
@@ -16,9 +16,11 @@ import { fileURLToPath } from 'node:url';
* that cross the bridge): no provider, no Console, no LLM key. It is the lane
* that can gate pull requests, because it carries no secrets a fork lacks.
* `provider` needs a real agent session attending the room, driven by Switch
- * Console or its sidecar.
+ * Console or its sidecar. `browser` drives the gateway UI in a headless
+ * Chromium against the same server: a smoke test of what an operator sees,
+ * which no HTTP-level scenario can see break.
*/
-export type Lane = 'fast' | 'provider';
+export type Lane = 'fast' | 'provider' | 'browser';
/**
* What the target is. Scenarios declare which they may run against.
@@ -99,6 +101,13 @@ export interface HarnessEnv {
secretsFile: string | null;
/** The server's JSON log, when the harness can read it; see `ServerLog`. */
serverLog: string | null;
+ /**
+ * The gateway UI, served against `switch.apiUrl` (its `/gateway` requests
+ * reach that server). Only the browser lane reads it.
+ */
+ gatewayUiUrl: string | null;
+ /** Where the browser lane saves a screenshot of a page that failed, if anywhere. */
+ outputDir: string | null;
switch: SwitchEnv;
/** `null` when no Mattermost is configured; scenarios that need one then skip or fail. */
mattermost: MattermostEnv | null;
@@ -176,8 +185,8 @@ export function laneFrom(
): Lane | null {
const raw = reader(source, file)('SWITCH_E2E_LANE');
if (raw === undefined) return null;
- if (raw === 'fast' || raw === 'provider') return raw;
- throw new Error(`SWITCH_E2E_LANE must be 'fast' or 'provider' — got '${raw}'.`);
+ if (raw === 'fast' || raw === 'provider' || raw === 'browser') return raw;
+ throw new Error(`SWITCH_E2E_LANE must be 'fast', 'provider' or 'browser' — got '${raw}'.`);
}
/**
@@ -236,6 +245,8 @@ export function loadEnv(
keepArtifacts: get('SWITCH_E2E_KEEP') === '1',
secretsFile: get('SWITCH_E2E_SECRETS_FILE') ?? null,
serverLog: get('SWITCH_E2E_SERVER_LOG') ?? null,
+ gatewayUiUrl: optionalUrl(get('SWITCH_GATEWAY_UI_URL')),
+ outputDir: get('SWITCH_E2E_OUTPUT_DIR') ?? null,
switch: {
apiUrl: stripTrailingSlash(required.SWITCH_API_URL as string),
gatewayAdminEmail: required.SWITCH_GATEWAY_ADMIN_EMAIL as string,
@@ -296,6 +307,10 @@ function questionModeFrom(raw: string | undefined): QuestionMode {
throw new Error(`SWITCH_E2E_QUESTION_MODE must be 'numbered' or 'prose' — got '${raw}'.`);
}
+function optionalUrl(raw: string | undefined): string | null {
+ return raw === undefined ? null : stripTrailingSlash(raw);
+}
+
export function stripTrailingSlash(url: string): string {
return url.endsWith('/') ? url.slice(0, -1) : url;
}
@@ -309,5 +324,6 @@ export function describeEnv(env: HarnessEnv): string {
const mattermost = env.mattermost
? `mattermost=${env.mattermost.url} team=${env.mattermost.team}`
: 'mattermost=none';
- return `lane=${env.lane} environment=${env.environment} switch=${env.switch.apiUrl} ${mattermost}`;
+ const ui = env.lane === 'browser' ? ` gateway-ui=${env.gatewayUiUrl ?? 'none'}` : '';
+ return `lane=${env.lane} environment=${env.environment} switch=${env.switch.apiUrl} ${mattermost}${ui}`;
}
diff --git a/console/tooling-e2e/src/core/scenario.ts b/console/tooling-e2e/src/core/scenario.ts
index b7f5d1944..6fe07c63f 100644
--- a/console/tooling-e2e/src/core/scenario.ts
+++ b/console/tooling-e2e/src/core/scenario.ts
@@ -4,7 +4,7 @@ import type { Environment, HarnessEnv, Lane } from './env.ts';
* The machine-readable header every scenario carries, in either lane.
*
* It is what lets tooling answer questions about the suite without running it:
- * which lane a scenario belongs to (`needsProvider`), where it may run
+ * which lane a scenario belongs to (`lane`), where it may run
* (`environments`), who to ask when it breaks (`owner`), and what it exercises
* (`covers`), which is what the coverage gate reads.
*/
@@ -18,8 +18,11 @@ export interface ScenarioHeader {
* own parameter names (e.g. `POST /agents/{agent_id}/message`).
*/
covers: readonly string[];
- /** `true` puts the scenario in the provider lane: it needs a real agent session. */
- needsProvider: boolean;
+ /**
+ * The lane it runs in: `fast` (plain HTTP), `provider` (a real agent
+ * session) or `browser` (the gateway UI in a headless browser).
+ */
+ lane: Lane;
/**
* Where it may run. A scenario that changes server-global state (a feature
* flag) lists only `ephemeral`. One that writes anything never lists `prod`.
@@ -34,8 +37,9 @@ export interface ScenarioHeader {
/**
* `mattermost`: a Mattermost and a human token on it are configured.
* `agent-dir`: the provider session's working directory is on this machine.
+ * `gateway-ui`: the address of a gateway UI served against this Switch server.
*/
-export type Prerequisite = 'mattermost' | 'agent-dir';
+export type Prerequisite = 'mattermost' | 'agent-dir' | 'gateway-ui';
const OPERATION = /^[a-z][a-z0-9_]*$/;
const ROUTE = /^(GET|POST|PUT|PATCH|DELETE) \/\S*$/;
@@ -53,7 +57,7 @@ export function headerProblems(header: ScenarioHeader): string[] {
}
if (header.environments.length === 0) problems.push('environments is empty');
if (header.owner.trim() === '') problems.push('owner is empty');
- if (header.needsProvider && header.environments.includes('prod')) {
+ if (header.lane === 'provider' && header.environments.includes('prod')) {
problems.push('a provider scenario writes to the room, so it cannot list prod');
}
return problems;
@@ -73,10 +77,6 @@ export function assertValidHeaders(headers: readonly ScenarioHeader[]): void {
}
}
-export function laneOf(header: ScenarioHeader): Lane {
- return header.needsProvider ? 'provider' : 'fast';
-}
-
/**
* Whether a scenario runs here, and if not, whether that is a failure.
*
@@ -88,8 +88,8 @@ export function laneOf(header: ScenarioHeader): Lane {
export type Admission = { run: true } | { run: false; reason: string; failure: boolean };
export function admit(header: ScenarioHeader, env: HarnessEnv): Admission {
- if (laneOf(header) !== env.lane) {
- return { run: false, reason: `belongs to the ${laneOf(header)} lane`, failure: false };
+ if (header.lane !== env.lane) {
+ return { run: false, reason: `belongs to the ${header.lane} lane`, failure: false };
}
if (!header.environments.includes(env.environment)) {
return {
@@ -115,6 +115,8 @@ function satisfied(prerequisite: Prerequisite, env: HarnessEnv): boolean {
return env.mattermost !== null;
case 'agent-dir':
return env.provider.agentRepoDir !== null;
+ case 'gateway-ui':
+ return env.gatewayUiUrl !== null;
}
}
@@ -124,5 +126,7 @@ function describePrerequisite(prerequisite: Prerequisite): string {
return 'Mattermost (MATTERMOST_URL, MATTERMOST_TOKEN, MATTERMOST_TEAM)';
case 'agent-dir':
return 'the session working directory (SWITCH_E2E_AGENT_DIR)';
+ case 'gateway-ui':
+ return 'a gateway UI (SWITCH_GATEWAY_UI_URL)';
}
}
diff --git a/console/tooling-e2e/src/fast/agent-messaging.ts b/console/tooling-e2e/src/fast/agent-messaging.ts
index ccd2203b2..802fececf 100644
--- a/console/tooling-e2e/src/fast/agent-messaging.ts
+++ b/console/tooling-e2e/src/fast/agent-messaging.ts
@@ -23,7 +23,7 @@ export const addressedDelivery: FastScenario = {
'POST /agents/{agent_id}/message',
'GET /agents/{agent_id}/notifications',
],
- needsProvider: false,
+ lane: 'fast',
environments: WRITABLE,
owner: 'platform',
requires: [],
@@ -71,7 +71,7 @@ export const unaddressedHistory: FastScenario = {
'GET /agents/{agent_id}/rooms/{room_id}/history',
'GET /agents/{agent_id}/notifications',
],
- needsProvider: false,
+ lane: 'fast',
environments: WRITABLE,
owner: 'platform',
requires: [],
diff --git a/console/tooling-e2e/src/fast/mattermost-roundtrip.ts b/console/tooling-e2e/src/fast/mattermost-roundtrip.ts
index 4c09d31b3..6d1c36f92 100644
--- a/console/tooling-e2e/src/fast/mattermost-roundtrip.ts
+++ b/console/tooling-e2e/src/fast/mattermost-roundtrip.ts
@@ -24,7 +24,7 @@ export const mattermostRoundtrip: FastScenario = {
'GET /agents/{agent_id}/notifications',
'POST /agents/{agent_id}/message',
],
- needsProvider: false,
+ lane: 'fast',
environments: WRITABLE,
owner: 'platform',
requires: ['mattermost'],
diff --git a/console/tooling-e2e/src/fast/operations.ts b/console/tooling-e2e/src/fast/operations.ts
index 5a63dc18f..40756e14b 100644
--- a/console/tooling-e2e/src/fast/operations.ts
+++ b/console/tooling-e2e/src/fast/operations.ts
@@ -14,7 +14,7 @@ export const operationsFrontDoor: FastScenario = {
'list_rooms',
'read_context',
],
- needsProvider: false,
+ lane: 'fast',
environments: WRITABLE,
owner: 'platform',
requires: [],
diff --git a/console/tooling-e2e/src/gate/coverage.test.ts b/console/tooling-e2e/src/gate/coverage.test.ts
index e7fafc399..2c0a468e0 100644
--- a/console/tooling-e2e/src/gate/coverage.test.ts
+++ b/console/tooling-e2e/src/gate/coverage.test.ts
@@ -1,4 +1,5 @@
import { describe, expect, it } from 'vitest';
+import { BROWSER_SCENARIOS } from '../browser/index.ts';
import type { ScenarioHeader } from '../core/scenario.ts';
import { FAST_SCENARIOS } from '../fast/index.ts';
import { SCENARIOS as PROVIDER_SCENARIOS } from '../provider/scenarios.ts';
@@ -10,7 +11,9 @@ import {
type ServerSurface,
} from './gate.ts';
-const HEADERS = [...FAST_SCENARIOS, ...PROVIDER_SCENARIOS].map((scenario) => scenario.header);
+const HEADERS = [...FAST_SCENARIOS, ...PROVIDER_SCENARIOS, ...BROWSER_SCENARIOS].map(
+ (scenario) => scenario.header
+);
describe('coverage gate', () => {
it('accounts for every operation and gateway route the server has', () => {
@@ -31,7 +34,7 @@ function header(id: string, covers: string[]): ScenarioHeader {
return {
id,
covers,
- needsProvider: false,
+ lane: 'fast',
environments: ['ephemeral'],
owner: 'platform',
requires: [],
diff --git a/console/tooling-e2e/src/provider/scenarios.ts b/console/tooling-e2e/src/provider/scenarios.ts
index 86088ec89..f59d1924e 100644
--- a/console/tooling-e2e/src/provider/scenarios.ts
+++ b/console/tooling-e2e/src/provider/scenarios.ts
@@ -433,7 +433,7 @@ function providerHeader(
return {
id,
covers,
- needsProvider: true,
+ lane: 'provider',
environments: PROVIDER_ENVIRONMENTS,
owner: 'console',
requires: ['mattermost', ...requires],
diff --git a/console/tooling-e2e/surface/exemptions.json b/console/tooling-e2e/surface/exemptions.json
index 423bd87ed..1bf07c860 100644
--- a/console/tooling-e2e/surface/exemptions.json
+++ b/console/tooling-e2e/surface/exemptions.json
@@ -133,7 +133,6 @@
"DELETE /gateway/tenants/{tenant_id}/members/{user_id}",
"DELETE /gateway/trust-settings",
"GET /gateway/agent-sessions/approvals",
- "GET /gateway/agents",
"GET /gateway/agents/avatar-settings",
"GET /gateway/agents/icon-choices",
"GET /gateway/agents/known-types",
@@ -141,10 +140,8 @@
"GET /gateway/agents/{agent_id}/service-grants",
"GET /gateway/api-keys",
"GET /gateway/api-keys/{key_id}/reveal",
- "GET /gateway/auth/config",
"GET /gateway/auth/me",
"GET /gateway/auth/me/identities",
- "GET /gateway/auth/session",
"GET /gateway/chats",
"GET /gateway/chats/activity/events",
"GET /gateway/chats/events",
@@ -197,9 +194,7 @@
"GET /gateway/references/{reference_id}",
"GET /gateway/references/{reference_id}/rooms",
"GET /gateway/room-groups",
- "GET /gateway/rooms",
"GET /gateway/rooms/template-schema",
- "GET /gateway/rooms/{room_id}",
"GET /gateway/rooms/{room_id}/documents",
"GET /gateway/rooms/{room_id}/documents/{document_id}",
"GET /gateway/rooms/{room_id}/linked-rooms",
@@ -246,8 +241,6 @@
"POST /gateway/agents/register-known-bulk",
"POST /gateway/agents/register-other",
"POST /gateway/api-keys",
- "POST /gateway/auth/login",
- "POST /gateway/auth/logout",
"POST /gateway/auth/refresh",
"POST /gateway/auth/signup",
"POST /gateway/chats",
diff --git a/gateway/src/layout/NavRail.tsx b/gateway/src/layout/NavRail.tsx
index 1a603187e..e4077a5e4 100644
--- a/gateway/src/layout/NavRail.tsx
+++ b/gateway/src/layout/NavRail.tsx
@@ -223,6 +223,8 @@ export default memo(function NavRail() {
<Divider sx={{ my: 1.5, width: 29 }} />
<Stack
+ component="nav"
+ aria-label="Main"
sx={{
width: "100%",
alignItems: "center",
diff --git a/justfile b/justfile
index 2cb1eb8ec..78dfe49bb 100644
--- a/justfile
+++ b/justfile
@@ -176,6 +176,13 @@ e2e-fast *args:
e2e-provider *args:
SWITCH_E2E_LANE=provider console/tooling-e2e/scripts/ephemeral-stack.sh {{ args }}
+# ── End-to-end harness, browser lane, on a throwaway stack ─────────────────────
+# As e2e-fast, plus the gateway UI built from gateway/ and served on :4173, then
+# the browser scenarios in headless Chromium (installed by Playwright on first
+# run). Screenshots of failed pages: build/e2e/ephemeral/screenshots.
+e2e-browser *args:
+ SWITCH_E2E_LANE=browser console/tooling-e2e/scripts/ephemeral-stack.sh {{ args }}
+
# ── Regenerate the server surface the E2E coverage gate reads ─────────────────
# Every agent operation and gateway route, written to
# console/tooling-e2e/surface/server-surface.json. CI fails when it is stale;