monoscope/e2e
Anthony Alaribe f86c324429
Floating AI assistant that acts on, navigates and reloads the UI (#912)
* Floating AI assistant: page-aware sessions that act, navigate and reload the page

Cmd+K or typing a letter opens the palette; Enter asks the assistant, which runs in the
background as a web conversation bound to the page it was asked from. The dock shows
sessions as bubbles, the selected transcript with live steps, and visits pages the agent
opens (open_page) or reloads the current page after a write.

* Dock polish: transcript-style progress, launcher with shortcut, entry motion; snapshot goldens

* Dock: OpenSession record, single-meaning navigate, inline bubble classes

* Dock panel reveals and focuses itself when a session first opens

* e2e: palette leads with Ask AI and hands the request to the dock

* Dock: catalog write policy, indexed session query, concurrent loads, 2s poll

* Dock: keep the changes toggle across sends; follow-up turn binds its page; lint

* hpack: list the page-context migration

* Dock: a log-view answer opens the explorer; prompt says only open_page changes the screen

* e2e: wait for the palette's lazy items before moving the selection

* Dock requests run on the receiving server; the queued job is a deferred fallback

* Browser tools: read_page, click and fill run in the user's tab; the run pauses until it answers

* Charts saved without a height get three rows; dashboard tools describe their body

* Dock reloads the current page by a whole swap; morphing a dashboard onto itself left it empty

* Stats saved without a height get two rows

* Assistant prompt lists a monitor's own page

* Page snapshot skips empty headings

* Assistant prompt: on-page parts of a request use the page tools; no unproven claims

* Document why the page tools carry a read-only policy

* Widget lifecycle spec: sizeless charts are three rows tall

* e2e: retry the palette's ArrowDown across the lazy items landing

* One prompt field for the thread and dock composers; tool names from the catalog

* Stored widgets get distinct ids; same-titled widgets no longer share one identity

* Widgets aggregating duration show time units; one inference for every widget

* A resize never redraws a chart before its data lands; echarts threw on the null source

* Dock: one let for the page change

* Distill: inline single-use tool list, merge height arms, dock spec helpers; hlint
History 2026-11-15 09:10:03 +01:00
..
tests Floating AI assistant that acts on, navigates and reloads the UI (#912) 2026-11-15 09:10:03 +01:00
package-lock.json Stripe and e2e test (#344) 2026-03-23 00:39:11 +01:00
package.json Stripe and e2e test (#344) 2026-03-23 00:39:11 +01:00
playwright.config.ts Add RUM audience breakdowns and reusable segments (#740) 2026-10-26 17:35:20 +01:00
README.md Fix empty team picker 400, KQL pipe suggestions, and make e2e reproducible 2026-08-20 00:35:08 +02:00
tsconfig.json Stripe and e2e test (#344) 2026-03-23 00:39:11 +01:00

End-to-end tests

Playwright specs that drive the real server in a real browser. They exist to catch the class of bug the unit suites structurally cannot see — a component reading a response key the server never sends, a renamed element id, a suggestion path that works in isolation and not through the live editor. Every one of those has actually shipped here.

Do not point these at port 8080

playwright.config.ts defaults to http://localhost:8081, deliberately.

Port 8080 is what make live-reload serves, and the dev server reads .env — whose DATABASE_URL points at monoscope-prod-eu-pg with MIGRATE_AND_INITIALIZE_ON_START=True. These specs create dashboards, drag and resize widgets, and POST to stripe_checkout. Run them against 8080 with the watcher up and that goes into production.

If a bare npx playwright test fails with connection refused, the fix is to start an e2e server (below) — not to point E2E_BASE_URL back at 8080.

Running them

make test-e2e                       # whole suite
scripts/e2e.sh tests/live-tail.spec.ts
scripts/e2e.sh -g "suggests"        # by title
E2E_KEEP=1 scripts/e2e.sh           # leave the server up to poke at

scripts/e2e.sh creates monoscope_e2e if absent, starts the server on 8081 from a temp directory whose .env is built from .env.example (so no real credential is ever copied and the production .env is not on its path), waits for /ping, runs Playwright, and tears everything down. Verified from a dropped database and from a warm one — both green.

Three settings in that generated env are load-bearing, and all three were found the hard way: BASIC_AUTH_ENABLED=False (otherwise every request 401s), ENABLE_FREETIER=True (otherwise the plan picker renders two cards and #freePricing never appears), and Pub/Sub + background jobs off (so a test server cannot join production topics).

No manual seeding is needed. Migration 0001 creates the demo project the specs drive (DEMO_PROJECT = 00000000-0000-0000-0000-000000000000, see tests/helpers.ts), the schema endpoint derives its fields without telemetry, and specs that need richer state build it themselves — dashboard-grid.spec.ts creates its own dashboard from a template rather than opening "whichever dashboard sorted first", which is what previously made it pass only on a database an earlier run had already populated.

Rebuild the frontend before running

BodyWrapper Template-Haskell-splices the Vite manifest's content hash at compile time, so a vite build without rebuilding the server leaves the page requesting the previous bundle. If the browser 404s an asset or runs stale JS, rebuild the server binary too — scripts/e2e.sh runs whatever cabal list-bin monoscope-server points at, so a server-side fix is not under test until that binary is rebuilt.