Repository navigation
test: add isolated browser verification loop #21
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
Merged
Changes from all commits
Commits
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,19 @@ | ||
| ts phase decision why evidence result | ||
| 2026-08-31T15:27:00Z isolation created t3code/agent-verification-loop in its own T3 worktree kept the dirty main checkout and other worktrees untouched git worktree list clean isolated branch | ||
| 2026-08-31T15:35:00Z browser made port 18080 loopback-only and disabled server reuse prevented another checkout on port 8080 from producing false browser results playwright.config.ts isolated server configured | ||
| 2026-08-31T15:35:30Z staging kept real auth tokens out of traces and uploaded artifacts Playwright traces and storage state can contain bearer and refresh tokens playwright.config.ts, .github/workflows/deploy.yml secret-bearing artifacts excluded | ||
| 2026-08-31T15:36:00Z staging used a unique user-owned source and exact UI deletion proved persistence while limiting cleanup to the row created by the test e2e/staging/authed-flows.spec.ts bounded cleanup implemented | ||
| 2026-08-31T15:38:00Z local gates ran lint, typecheck, focused sparring tests, and Playwright discovery caught compile and selector problems before the full browser matrix local command output 14 focused tests and 168 browser cases listed | ||
| 2026-08-31T15:39:00Z staging proved partial and missing staging configuration fails closed never substitute production or a skipped fake session for missing protected values playwright.config.ts both negative preflights exited 1 | ||
| 2026-08-31T15:44:00Z browser made the score mock briefly asynchronous after two flaky results the zero-latency mock removed the loading state before its existing assertion could observe it e2e/sparring.spec.ts preserved the loading assertion for deterministic rerun | ||
| 2026-08-31T16:05:00Z webkit loaded Jam recorder scripts only when MediaRecorder exists WebKit reproduced three Jam page errors on the smallest authenticated route src/jam-loader.ts, src/test/jam-loader.test.ts minimal repro passed and 56 WebKit cases passed | ||
| 2026-08-31T16:15:00Z local gates ran the full Node 22 verification command on the Jam-fixed tree needed fresh proof for the final source state npm run verify 85 files, 874 tests, coverage, build, and 112 Chromium cases passed | ||
| 2026-08-31T16:22:00Z staging audited staging before any remote mutation confirmed target and identified exact synchronization and credential blockers Supabase function, secret-name, migration, and CORS reads 2 migrations and 3 function deploys stale; protected test inputs absent | ||
| 2026-08-31T16:30:00Z review fixed all four Luna xhigh pre-commit findings kept auth traces out of artifacts, isolated staging concurrency, tightened AI proof, and guaranteed cleanup after insert playwright.config.ts, .github/workflows/staging-e2e.yml, e2e/staging/authed-flows.spec.ts focused lint, typecheck, tests, YAML parse, and staging discovery passed | ||
| 2026-08-31T16:31:00Z ci recorded exhausted GitHub Actions minutes as an external exception Adam confirmed hosted CI cannot run and required local CI-equivalent proof user instruction local gates remain authoritative; GitHub runs must not be called green | ||
| 2026-08-31T16:35:00Z integration rebased onto analytics and telemetry main changes kept the PR current before push and invalidated older verification origin/main 7bca126 clean rebase; full gates rerun | ||
| 2026-08-31T16:40:00Z local gates ran fresh CI-equivalent checks after rebase proved the exact integrated source before PR creation npm ci, npm run verify 89 files, 930 tests, coverage, build, and 112 Chromium cases passed | ||
| 2026-08-31T16:42:00Z webkit reran the full Safari-engine matrix after rebase main changed routing and AI code since the first WebKit proof Playwright 1.60 Noble container with Node 22 56 WebKit cases passed | ||
| 2026-08-31T16:56:00Z CodeRabbit fixed all four current-head review comments restricted trusted staging triggers and loopback auth, updated plan state, and sequenced Jam before app startup PR 21 review on 5f0f67a all findings implemented or bounded with deterministic proof | ||
| 2026-08-31T16:59:00Z local gates reran CI-equivalent checks after CodeRabbit fixes review changes affected workflow security and application bootstrap npm run verify, Playwright 1.60 Noble container 89 files, 930 tests, coverage, build, 112 Chromium and 56 WebKit cases passed | ||
| 2026-08-31T17:06:00Z CodeRabbit added a bounded Jam CDN timeout prevented a stalled recorder request from blocking application startup src/jam-loader.ts, src/test/jam-loader.test.ts 20 focused tests, lint, typecheck, build, Chromium and WebKit startup passed |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,83 @@ | ||
| name: Protected staging E2E | ||
|
|
||
| on: | ||
| workflow_run: | ||
| workflows: ["Build and Push Docker Image"] | ||
| types: [completed] | ||
| workflow_dispatch: | ||
|
|
||
| permissions: | ||
| contents: read | ||
|
|
||
| concurrency: | ||
| group: protected-staging-e2e-main | ||
| cancel-in-progress: false | ||
|
|
||
| jobs: | ||
| staging-e2e: | ||
| if: >- | ||
| ( | ||
| (github.event_name == 'workflow_run' && | ||
| github.event.workflow_run.conclusion == 'success' && | ||
| github.event.workflow_run.event == 'push' && | ||
| github.event.workflow_run.head_branch == 'main') || | ||
| (github.event_name == 'workflow_dispatch' && github.ref == 'refs/heads/main') | ||
| ) && vars.STAGING_E2E_ENABLED == 'true' | ||
| runs-on: ubuntu-latest | ||
| environment: staging | ||
| steps: | ||
| - name: Checkout code | ||
| uses: actions/checkout@11d5960a326750d5838078e36cf38b85af677262 # v4 | ||
| with: | ||
| persist-credentials: false | ||
| ref: ${{ github.event_name == 'workflow_run' && github.event.workflow_run.head_sha || github.sha }} | ||
|
|
||
| - name: Set up Node | ||
| uses: actions/setup-node@49933ea5288caeca8642d1e84afbd3f7d6820020 # v4 | ||
| with: | ||
| node-version: 22 | ||
|
|
||
| - name: Install dependencies | ||
| run: npm ci | ||
|
|
||
| - name: Install Chromium | ||
| run: npx playwright install --with-deps chromium | ||
|
|
||
| - name: Verify protected variables are present | ||
| shell: bash | ||
| env: | ||
| STAGING_SUPABASE_URL: ${{ secrets.STAGING_SUPABASE_URL }} | ||
| STAGING_SUPABASE_ANON_KEY: ${{ secrets.STAGING_SUPABASE_ANON_KEY }} | ||
| STAGING_DEMO_CODE: ${{ secrets.STAGING_DEMO_CODE }} | ||
| run: | | ||
| missing=0 | ||
| for name in STAGING_SUPABASE_URL STAGING_SUPABASE_ANON_KEY STAGING_DEMO_CODE; do | ||
| if [ -z "${!name}" ]; then | ||
| echo "::error::$name is not configured in the staging environment" | ||
| missing=1 | ||
| fi | ||
| done | ||
| exit "$missing" | ||
|
|
||
| - name: Protected staging browser tests | ||
| env: | ||
| CI: 1 | ||
| PORT: 18080 | ||
| PLAYWRIGHT_BASE_URL: http://127.0.0.1:18080 | ||
| STAGING_SUPABASE_URL: ${{ secrets.STAGING_SUPABASE_URL }} | ||
| STAGING_SUPABASE_ANON_KEY: ${{ secrets.STAGING_SUPABASE_ANON_KEY }} | ||
| STAGING_DEMO_CODE: ${{ secrets.STAGING_DEMO_CODE }} | ||
| run: npm run test:e2e:staging | ||
|
|
||
| - name: Upload staging failure artifacts | ||
| if: failure() | ||
| uses: actions/upload-artifact@ea165f8d65b6e75b540449e92b4886f43607fa02 # v4 | ||
| with: | ||
| name: staging-browser-failure-${{ github.run_id }} | ||
| path: | | ||
| test-results/**/*.png | ||
| test-results/**/*.webm | ||
| !test-results/.auth/ | ||
| !test-results/**/*.zip | ||
| if-no-files-found: ignore | ||
| retention-days: 7 | ||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,61 @@ | ||
| # DebateLab agent guide | ||
|
|
||
| ## Runtime and install | ||
|
|
||
| - Use Node 22 and npm. The lockfile is `package-lock.json`. | ||
| - Start a clean checkout with `npm ci`. | ||
| - The development server normally uses port 8080. Automated browser verification owns `127.0.0.1:18080` and never reuses an existing server. | ||
| - Local Supabase development uses port 54321. Do not point staging checks at the production project. | ||
|
|
||
| ## Verification ladder | ||
|
|
||
| Run the smallest relevant reproduction first, then the complete gate before a PR: | ||
|
|
||
| ```bash | ||
| npm run lint | ||
| npm run typecheck | ||
| npm test -- --coverage | ||
| npm run build | ||
| CI=1 PORT=18080 PLAYWRIGHT_BASE_URL=http://127.0.0.1:18080 npm run test:e2e | ||
| ``` | ||
|
|
||
| `npm run verify` runs that full credential-free ladder. It starts an isolated Vite server and executes the desktop and mobile Chromium projects. Browser failures stay in ignored `test-results/` and `playwright-report/` directories. CI uploads those directories for seven days when the browser step fails. | ||
|
|
||
| WebKit is an additional release smoke gate: | ||
|
|
||
| ```bash | ||
| npx playwright install --with-deps webkit | ||
| CI=1 PORT=18080 PLAYWRIGHT_BASE_URL=http://127.0.0.1:18080 npm run test:e2e:webkit | ||
| ``` | ||
|
|
||
| ## Protected staging verification | ||
|
|
||
| The staging suite uses a real staging user and backend. It never uses a service-role key. Supply all three protected values together: | ||
|
|
||
| - `STAGING_SUPABASE_URL` | ||
| - `STAGING_SUPABASE_ANON_KEY` | ||
| - `STAGING_DEMO_CODE` | ||
|
|
||
| Then run: | ||
|
|
||
| ```bash | ||
| CI=1 PORT=18080 PLAYWRIGHT_BASE_URL=http://127.0.0.1:18080 \ | ||
| STAGING_SUPABASE_URL=<staging-url> \ | ||
| STAGING_SUPABASE_ANON_KEY=<staging-anon-key> \ | ||
| STAGING_DEMO_CODE=<dedicated-test-code> \ | ||
| npm run test:e2e:staging | ||
| ``` | ||
|
|
||
| The suite rejects the production project, checks that the anon key belongs to the supplied staging URL, authenticates through `demo-code-login`, proves session reload, writes and reads back one unique source, makes one bounded AI request, and deletes only that source. It saves temporary auth state under `test-results/.auth/`. Never upload that directory or a staging trace because both can contain session tokens. | ||
|
|
||
| GitHub runs staging only for `main` push or a main-branch manual dispatch, through the protected `staging` environment, after the credential-free build job passes. Set the repository variable `STAGING_E2E_ENABLED=true` only after the protected environment has the three secrets, current staging functions, schema, provider secret, dedicated unlimited-use test code, and a main-only deployment rule. A skipped staging job is not a pass. | ||
|
|
||
| The staging origin `http://127.0.0.1:18080` must be deployed in the CORS allowlists for `demo-code-login`, `ai`, and `ai-stream` before enabling the gate. Do not deploy those functions or apply migrations to an unverified project. | ||
|
|
||
| ## Working rules | ||
|
|
||
| - Start bug fixes with a failing test or a repeatable browser reproduction when the repository has a suitable test layer. | ||
| - Keep stub sessions limited to render checks. Do not describe them as authenticated backend proof. | ||
| - Never put staging or production secrets in PR jobs, logs, traces, screenshots, commits, or comments. | ||
| - A local pass proves only the local commit. Inspect the current-head GitHub run before calling CI green. Account billing or spending-limit failures are external exceptions, not passing checks. | ||
| - State exactly which browser and staging checks ran. If credentials, provider access, or staging synchronization are missing, stop that gate and report it instead of substituting production or mocks. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.