pr-test
Manual E2E Test
Test a PR/branch end-to-end by building the full platform, interacting via browser and API, capturing screenshots, and reporting results.
Changelog 2.2.0 — auth flow updated for Better Auth (Supabase signup is
gone), env-setup gaps closed, a proven Playwright fallback for agent-browser,
a billing-test trap that produces false passes, safer process cleanup, and a
mock-provider pattern for deterministic $0 testing. Learned on
#14206 — see the
2.2.1 — corrects two claims from 2.2.0 that didn't survive live-stack
verification (JWKS does not rotate on a frontend restart; the local
Postgres port is 5432, not 54322) and hardens the auth setup (explicit
password-length/allowlist/rate-limit failure modes, fail-fast on an empty
token, password kept out of process args).
2.3.0 — screenshots are posted as GitHub comment attachments
(gh pr comment --attach, needs gh >= 2.99.0) instead of being pushed to a
test-screenshots/* branch, which accumulated one branch per tested PR and
made every old report's images depend on that branch surviving.
Critical Requirements
These are NON-NEGOTIABLE. Every test run MUST satisfy ALL the following:
1. Screenshots at Every Step
- Take a screenshot at EVERY significant test step — not just at the end
- Every test scenario MUST have at least one BEFORE and one AFTER screenshot
- Name screenshots sequentially:
{NN}-{action}-{state}.png(e.g.,01-credits-before.png,02-credits-after.png) - If a screenshot is missing for a scenario, the test is INCOMPLETE — go back and take it
2. Screenshots MUST Be Posted to PR
- Attach ALL screenshots to the PR comment with
gh pr comment --attach(see Step 7). Never push image files to a repo branch — attachments live in GitHub's own asset store and leave nothing behind in the repo - Post a PR comment with ALL screenshots embedded inline, each with its explanation
- This is NOT optional — every test run MUST end with a PR comment containing screenshots
- If the upload fails, retry. If it still fails, list failed files and require manual drag-and-drop/paste attachment in the PR comment, and mark the run INCOMPLETE
3. State Verification with Before/After Evidence
- For EVERY state-changing operation (API call, user action), capture the state BEFORE and AFTER
- Log the actual API response values (e.g.,
credits_before=100, credits_after=95) - Screenshot MUST show the relevant UI state change
- Compare expected vs actual values explicitly — do not just eyeball it
4. Negative Test Cases Are Mandatory
- Test at least ONE negative case per feature (e.g., insufficient credits, invalid input, unauthorized access)
- Verify error messages are user-friendly and accurate
- Verify the system state did NOT change after a rejected operation
5. Test Report Must Include Full Evidence
Each test scenario in the report MUST have:
- Steps: What was done (exact commands or UI actions)
- Expected: What should happen
- Actual: What actually happened
- API Evidence: Before/after API response values for state-changing operations
- Screenshot Evidence: Before/after screenshots with explanations
State Manipulation for Realistic Testing
Billing-test trap — this one produces a false pass, not a visible failure.
LLM block cost filters key on the *platform-owned* credential id. A run made
with the test user's own API key bills nothing by design, so a credits
before/after assertion silently passes on zero deltas either way. Any test
that verifies credit reconciliation MUST use the system credential, not a
user-supplied key. Related: Ollama block entries are configured with an
explicit $0 run-based cost (BlockCostType.RUN, cost_amount=0 in
block_cost_config.py), not a token-metered one — so pre/post-flight cost
deltas are always 0 for them regardless of credential. Never use an Ollama
model to test credit reconciliation; pick any hosted model billed through the
system credential instead.
When testing features that depend on specific states (rate limits, credits, quotas):
- Use Redis CLI to set counters directly:
```bash
# Find the Redis container
REDIS_CONTAINER=$(docker ps --format '{{.Names}}' | grep redis | head -1)
# Set a key with expiry
docker exec $REDIS_CONTAINER redis-cli SET key value EX ttl
# Example: Set rate limit counter to near-limit
docker exec $REDIS_CONTAINER redis-cli SET "rate_limit:user:$PR_TEST_USER_EMAIL" 99 EX 3600
# Example: Check current value
docker exec $REDIS_CONTAINER redis-cli GET "rate_limit:user:$PR_TEST_USER_EMAIL"
```
- Use API calls to check before/after state:
```bash
# BEFORE: Record current state
BEFORE=$(curl -s -H "Authorization: Bearer $TOKEN" http://localhost:8006/api/credits | jq '.credits')
echo "Credits BEFORE: $BEFORE"
# Perform the action...
# AFTER: Record new state and compare
AFTER=$(curl -s -H "Authorization: Bearer $TOKEN" http://localhost:8006/api/credits | jq '.credits')
echo "Credits AFTER: $AFTER"
echo "Delta: $(( BEFORE - AFTER ))"
```
- Take screenshots BEFORE and AFTER state changes — the UI must reflect the backend state change
- Never rely on mocked/injected browser state — always use real backend state. Do NOT use
agent-browser evalto fake UI state. The backend must be the source of truth.
