Skip to content

feat(runner): live shape checks for the two AI endpoints (DEV-2203) - #187

Open
danielzytohoc wants to merge 4 commits into
feat/DEV-2203-share-create-livefrom
feat/DEV-2203-ai-live-spec
Open

feat(runner): live shape checks for the two AI endpoints (DEV-2203)#187
danielzytohoc wants to merge 4 commits into
feat/DEV-2203-share-create-livefrom
feat/DEV-2203-ai-live-spec

Conversation

@danielzytohoc

@danielzytohoc danielzytohoc commented Aug 14, 2026

Copy link
Copy Markdown

Seventh in the DEV-2203 series. Stacked on #186.

What

e2e/ai-live.spec.ts — two API-level tests, double-gated (E2E_BASE_URL + E2E_AI=1), that prove the deployed gateway chain returns something usable (never an opinion on content quality):

  • POST /api/chat → 200 with the documented shape: non-empty message, edits/references/pages arrays.
  • POST /api/theme ("corporate green") → 200 with a whitelist-clean suggestion — every token key must be in the product's own generated TOKEN_KEYS, palette keys must match the ramp grammar — and the suggestion must move at least one thing (an empty 200 is the DEV-2497 class of quiet failure).

429 → test.skip: both endpoints share the 8/min-per-IP bucket with real users.

Verification

Both passed against production (7.6 s / 7.9 s, ~2 LLM calls). Skip behavior verified without the gates. First live run caught a subtlety now documented in the spec: the chat validator silently drops non-relative file paths and then refuses the all-dropped map as "files are required".


Note

Low Risk
Test-only addition with env gates; no production code paths changed, though runs consume live API quota when enabled.

Overview
Adds e2e/ai-live.spec.ts, a Playwright suite that hits the deployed POST /api/chat and POST /api/theme endpoints (not the UI drawers) to verify the worker → LiteLLM → model chain returns usable responses.

Tests run only when E2E_BASE_URL and E2E_AI=1 are set (real LLM spend, shared 8/min IP rate limit). 429 and budget_* refusals skip instead of failing; other errors (e.g. missing gateway key) still fail.

Chat: expects 200 with non-empty message and array edits, references, pages; uses relative-only file paths so the validator does not drop the whole map.

Theme: expects 200, token keys in generated TOKEN_KEYS, palette keys matching the ramp grammar, and at least one change across tokens/palette/config (non-empty “corporate green” suggestion).

Reviewed by Cursor Bugbot for commit c9f0ea5. Bugbot is set up for automated code reviews on this repo. Configure here.

panels.spec.ts and style-apply's recorded payloads prove the drawers;
nothing proved the deployed chain — worker → LiteLLM → model →
whitelist — returns something usable at all. Two API-level calls, one
file, double-gated (E2E_BASE_URL + E2E_AI=1): /api/chat answers with
the documented shape, /api/theme answers with a whitelist-clean,
non-empty suggestion (an empty 200 is the DEV-2497 class of quiet
failure). The theme whitelist assertion imports the product's own
generated TOKEN_KEYS, so a sanitiser regression fails here too.

A 429 skips rather than fails: both endpoints share the 8/min-per-IP
bucket with real users, and traffic is not a product failure.

The chat body uses relative file paths on purpose — the validator
silently drops unsafe paths and an all-dropped map fails as 'files are
required' (this spec's first live run found that the hard way).

@cursor cursor Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Cursor Bugbot has reviewed your changes using default effort and found 1 potential issue.

Fix All in Cursor

❌ Bugbot Autofix is OFF. To automatically fix reported issues with cloud agents, enable autofix in the Cursor dashboard.

Reviewed by Cursor Bugbot for commit 90e69fd. Configure here.

Comment thread runner/e2e/ai-live.spec.ts Outdated
Dan Zyto added 3 commits August 17, 2026 08:35
…gbot #187)

Both endpoints sit behind the budget gate as well as the per-IP bucket:
an anonymous caller gets 401 budget_login_required at anon_blocked and
503 budget_exhausted at new_blocked/closed. Those are spend policy, not
the AI chain — the same class as a 429 — so they skip. A 503
chat_unavailable stays a failure: a missing gateway key IS the product
being broken.
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