Skip to content

test(playground): smoke-test the playground's own server plugins - #542

Draft
IamGalymzhan wants to merge 4 commits into
feat/testing-kit-harnessfrom
feat/dev-playground-smoke-tests
Draft

test(playground): smoke-test the playground's own server plugins#542
IamGalymzhan wants to merge 4 commits into
feat/testing-kit-harnessfrom
feat/dev-playground-smoke-tests

Conversation

@IamGalymzhan

Copy link
Copy Markdown
Collaborator

Summary

Third in the stack — base is feat/testing-kit-harness (#540), which is itself based on #530. Review those first; GitHub shows only this PR's 2 files here, and retargets automatically as the parents merge.

The playground's server plugins had no tests at all. apps/dev-playground/tests/ holds Playwright specs that intercept /api at the browser boundary (page.route + route.fulfill), so the Express server never runs in them — route handlers, execute() interceptors, and executeStream are entirely unexercised. These five tests cover that side with the harness from #540: real HTTP, faked data plane, no workspace, no credentials, no network.

It also serves as dogfooding that a customer would recognise — the reference app testing its own plugins the way the docs tell them to test theirs.

What's covered

Test Proves
all three boot together the plugin set composes and registers under its manifest names
GET /api/reconnect the plain JSON route answers
reconnect stream opens as text/event-stream and emits its first message
POST /api/telemetry-examples/combined the whole nested-span body runs against the real TelemetryProvider and threads userId through
lakebase-examples unconfigured degrades to no routes without PGHOST/LAKEBASE_ENDPOINT, and the app still boots

Adds a dev-playground vitest project so pnpm test and CI's Unit Tests job pick them up: 4517 → 4522.

Two things writing this turned up

  • telemetry-example-plugin really calls fetch("https://example.com") in its external-api span, so a naive test of it needs the internet. The suite stubs non-loopback fetches and passes loopback through — loopback has to work, since that's how the harness reaches its own server. Verified hermetic by running the suite under a socket guard that throws on any non-loopback connect.
  • expectStream can't assert on a long-lived stream. It buffers a source to completion and throws on timeout rather than returning partial events. The reconnect stream is five messages three seconds apart, so the SSE test reads one payload off res.body and hangs up instead of costing ~12s.

Notes for the reviewer

  • The tests/** exclusion in the new vitest project is load-bearing. Vitest's default **/*.spec.ts glob otherwise collects the Playwright specs, which fail on import with Playwright Test did not expect test.describe() to be called here. Verified by removing it.
  • Deliberately smoke-only. Reconnection replay is the real prize — executeStream's ring buffer and Last-Event-ID handling — and deserves its own tests rather than being smuggled into a smoke suite.
  • No typecheck script for this app, so the new file is transpile-only. Adding one is out of scope: the existing tsconfig reports 2128 errors from the client's unset --jsx, and a server-scoped one still has 13 pre-existing errors CI has never seen, because pnpm -r typecheck skips this workspace. The most interesting of those 13 is a duplicate-identity clash between appkit/dist/shared/src/workspace-client/types and shared/dist/workspace-client/typesshared is bundled inline into appkit, so the two WorkspaceClient types diverge on Config. Worth its own issue.

Verification

4522 tests pass; typecheck, lint, and format clean. The five new tests pass with zero non-loopback connection attempts under a socket guard.

This pull request and its description were written by Isaac.

The playground's server plugins had no tests at all. `tests/` holds Playwright
specs that intercept `/api` at the browser boundary (`page.route` + `fulfill`),
so the Express server never runs in them — route handlers, `execute()`
interceptors, and `executeStream` are all unexercised. These five tests cover
that side using the harness from #540: real HTTP, faked data plane, no
workspace, no credentials, no network.

Adds a `dev-playground` vitest project so `pnpm test` (and CI's Unit Tests job)
picks them up: 4517 -> 4522. The `tests/**` exclusion is load-bearing — without
it vitest's default `**/*.spec.ts` glob collects the Playwright specs and they
fail on import with "Playwright Test did not expect test.describe() to be
called here".

Two things worth knowing, both found by writing this:

- `telemetry-example-plugin` really calls `fetch("https://example.com")` in its
  external-api span, so a naive test needs the internet. The suite stubs
  non-loopback fetches and passes loopback through, since that is how the
  harness reaches its own server. Verified hermetic under a socket guard that
  throws on any non-loopback connect.
- `expectStream` buffers a source to completion and throws on timeout rather
  than returning partial events, so it cannot assert on a long-lived stream.
  The reconnect stream is five messages three seconds apart, so the SSE test
  reads one payload and hangs up instead of costing ~12s.

Scoped to smoke coverage deliberately. Not included: reconnection replay
(`executeStream`'s ring buffer and `Last-Event-ID` handling is the real prize
and deserves its own tests), and a `typecheck` script for the app — the
existing tsconfig reports 2128 errors from the client's unset `--jsx`, and a
server-scoped one still has 13 pre-existing errors that CI has never seen
because `pnpm -r typecheck` skips this workspace.

Signed-off-by: Galymzhan <zhangazy2004@gmail.com>
@IamGalymzhan
IamGalymzhan requested a review from a team as a code owner August 20, 2026 09:51
@IamGalymzhan
IamGalymzhan requested review from pkosiec and removed request for a team August 20, 2026 09:51
@IamGalymzhan
IamGalymzhan marked this pull request as draft August 20, 2026 10:06
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant