Skip to content

test: cut tests that can't catch a regression, fix the misbuilt ones - #107

Merged
Programcode merged 9 commits into
mainfrom
chore/test-diet
Oct 3, 2026
Merged

Programcode merged 9 commits into
mainfrom
chore/test-diet

Conversation

@Programcode

@Programcode Programcode commented Oct 3, 2026 •

Copy link
Copy Markdown
Owner

This PR deletes 74 tests that couldn't catch a real regression and fixes 9 that should have caught one but didn't. I audited every layer: Vitest, Deno, the collaboration service, Playwright and pgTAP. Only test files change: 29 files, +82 / −847 lines. The rules are the ones in #93.

It sits on top of #95, which merged during this work and cut the unit suite from 112 files to 24. Edits to files that #95 deleted were dropped in the rebase. #95's new CORS allowlist tests are kept. Three test files are left alone because open PRs change them: e2e/workspace-collaboration.spec.ts (#63), and e2e/model-matrix/generate.spec.ts and e2e/production/canary.spec.ts (#94). The verify-debatelab recipes are untouched.

Before and after

Measured against main at 5ef8b24. Counts are executed tests. Playwright counts are --list totals across its three projects, and pgTAP counts are the sum of plan().

Layer Tests before Tests after Test lines before Test lines after
Vitest (src/) 274 265 5222 5089
Deno (supabase/functions/) 344 318 8644 8255
Collaboration service 30 30 1393 1402
Playwright (e2e/) 387 363 5184 4996
pgTAP (supabase/tests) 451 419 4397 4333

Wall times were measured on a shared VPS, where load from other worktrees varies:

Command Before After
npm test 15.7 s 13.1 s
npm run test:edge 14.5 s 12.8 s
npm run test:collaboration 5.1 s 4.6 s

The PR smoke set (npm run test:e2e:smoke) goes from 31 to 29 tests. The two removed tests repeat the /app startup-shell smoke test, and every route keeps its smoke load test.

Delete: 74

A test is deleted when it restates a type, schema or config, checks that something exists, asserts static copy, only renders, only exercises mocks, can never fail, or duplicates another test at the same layer.

Layer Deleted
pgTAP 32 assertions
Deno 26
Vitest 9
Playwright 7 definitions (24 listed runs)
Collaboration 0

Examples to spot-check:

  • In workspaces_rls_test.sql, four has_table checks sit right before an assertion that casts the same four tables to regclass.
  • In control-matrix.test.ts, "ask toggles and modes appear verbatim" checks an all-on and an all-off prompt. Both are rows of the 64-row matrix test directly below it.
  • startup-shell.spec.ts has /login and / delayed-entry tests that repeat the /app one. The startup shell is the same static HTML on every path.
  • vercel-deployment-config.test.ts "pins the Vercel runtime to Node 22" only compares engines.node to the literal "22.x".

Fix: 9

These tests should have caught a regression and didn't. Each one now asserts observable behavior.

Layer Fixed
Playwright 4
Vitest 2
Deno 2
Collaboration 1
pgTAP 0

Examples to spot-check:

  • admin/demo-code-contract.test.ts used to grep admin/index.ts for variable names. Storing the raw demo code would have passed as long as the identifiers stayed. The test now drives the real handler and asserts:

    • a 201 with a DEMO-XXXX-XXXX code;
    • one inserted row whose code_hash equals the hash of the returned code;
    • no raw code anywhere in the row;
    • a 400 and no insert for role: "admin".

    Each of three mutations to a temp copy of the handler makes it fail: storing the raw code, deriving the email from it, and dropping the role check.

  • In debate-context.test.tsx, the one-off-mode test only rendered a notice. It now sends a request and asserts that no debateContext and no sourceIds go out, which is the isolation guarantee.

  • postgres-store.test.ts only asserted the fake client's canned true. It now asserts the exact membership query arguments [documentId, epoch, authorId, false].

  • The other fixes:

    • formats.test.ts now requires the displayed minutes to equal the summed speech times.
    • Three .seo-fallback assertions targeted an element removed in perf: fix startup and route loading #49, and navigation-performance had a metrics block whose comparisons were true by construction. Both were cut.
    • The sparring mobile test lost its pixel and attribute checks.

Keep: everything else

I kept specs that guard auth, RLS, billing, quotas, migrations, concurrency, parsers or fixed bugs, including the ugly ones. Three to check:

  • workspace_collaboration_test.sql has a has_trigger ... notify_access_revoked_after_delete existence check. It is still the only guard on the revocation fence, because pgTAP can't observe a NOTIFY inside a rolled-back transaction.
  • quality-backlog.spec.ts "Sources does not show the stale consultation date" looks like static copy, but it is the regression test for the bug fixed in fix: resolve retained UI bugs #45.
  • The es/hu iterations of the authed-pages and public-pages loops look like the English runs with different strings. ci: three-minute PR check and two previews per PR #95 removed i18n.test.ts, so these loops are now the only check that a Spanish or Hungarian translation gap doesn't crash a page. They run nightly, not in the PR check.

docs/testing.md:126 still describes the i18n.test.ts that #95 removed. I left it for a follow-up, because the doc should state the replacement once one is chosen.

Verification

GitHub Actions did not run on this head: every job failed in one to two seconds with no steps, which is the out-of-minutes pattern. Both Vercel previews built. These are local results at 9c717f7, not CI results:

  • npm run verify passes: docs, lint, types, unit, collaboration, edge, build, service worker, and the 29-test smoke set (28 passed; crossfire.spec.ts was flaky and passed on retry).
  • The full Playwright suite (npm run test:e2e, desktop and mobile Chromium) passes: 233 passed, 5 skipped, 4 flaky that passed on retry. The flaky ones were page-load waits while the database gate shared the CPU. Two are in hungarian-parity, which this PR does not touch. Two are unchanged tests in loading-performance.
  • npm test -- --coverage: 265 passed. npm run test:edge: 318 passed. npm run test:collaboration: 30 passed.
  • The database gate (./.superset/db-gate.sh) passes: pgTAP 19 files and 419 tests, then the full-stack browser gate with 71 passed and 1 skipped. An earlier run under load average 37 timed out on three AI-call waits. None of those specs changed, and all three pass here.
  • The Codex review (gpt-6.1-sol, high effort) found no actionable issues. It also ran the seven changed specs on desktop and mobile Chromium (88 passed) and confirmed each pgTAP file's assertion count matches its plan(). Copilot was out of quota.

🤖 Generated with Claude Code

Programcode and others added 9 commits October 3, 2026 06:57
Removes 32 has_table, has_function and has_column assertions from six
pgTAP files. A behavioral assertion in the same suite already reads,
writes or calls each object, so it fails if the object goes missing.
Grants, RLS, trigger and constraint checks stay. Plans go from 451 to 419.

Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
- Delete prompt tests that only assert fixed prompt wording, and
  control-matrix spot checks that repeat the matrix tests.
- Delete tests that grep handler source text instead of calling it, and
  a cancelled-stream billing test that ai-stream's aborted scenario
  already covers.
- Rewrite the demo-code contract test to call the real create-demo-code
  handler: it checks the stored hash, that the stored row never reveals
  the code, and that admin-role codes are refused.
- Rewrite the model-catalog test to check the rules behind the list
  (low effort everywhere, valid defaults) instead of the ten IDs.

Deno tests: 341 to 315.

Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
The isAuthorized test only checked the fake database's canned `true`, so
swapped document and author arguments would still pass. It now asserts
the exact parameters sent to the membership query.

Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
Drop four vercel-deployment-config cases that restate config literals,
static copy or dependency keys. The security-header, SPA-fallback and
cache-rule cases stay.

Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
"renders the empty state" and "displays results when store has data"
only check that mocked children render. "handles form submission"
repeats "keeps one-off results out of every debate", which also checks
debate scoping.

Other page tests are left alone because open PR #95 changes them.

Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
… duplicate

- debate-context: the one-off mode test only rendered a notice. It now
  sends a request and asserts no debate context or sources go out.
- EnvironmentSwitcher: drop a case the sign-out-failure test already
  covers by clicking the same "Switch to Production" button.

Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
…at cannot fail

- animation-polish: the normal-motion test runs the same flow as the
  reduced-motion test with weaker assertions.
- loading-performance: the AppLayout-stays-mounted test is a subset of
  navigation-performance's delayed-chunk test.
- navigation-performance: the es/hu delayed-route tests only check
  translated labels that route-skeleton.test.tsx already pins. The
  delayed-chunk test loses a transitionMetrics block whose comparisons
  are true by construction; its shell-identity checks stay.
- home-navigation: the desktop header test only asserts link labels
  and that old tool links are absent.

Specs that open PRs #63, #94, #95, #99 and #100 change are left alone.

Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
The metadata test only checked approximateMinutes > 0, so the "About N
minutes" in Sparring setup could drift from the real schedule. It now
requires the summed speech times. Drop a test of fixed copy and
numbers for the school format.

Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
- startup-shell: the /login and / delayed-entry tests repeat the /app
  startup-shell test; the shell is the same static HTML on every path.
  Three `.seo-fallback` assertions targeted an element removed in #49,
  so they could never fail.
- public-pages: drop the logo test that restates the component's own
  src, width and height.
- sparring: the mobile reduced-motion test drops logo attribute,
  removed-copy and 1px icon-alignment checks. It still checks the
  default format, the speaking-order toggle and overflow.

The es/hu locale loops stay: since i18n.test.ts was removed they are
the only check that a translation gap does not crash a page.

Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
Copilot AI balanced review requested due to automatic review settings October 3, 2026 06:59
@vercel

vercel Bot commented Oct 3, 2026 •

Copy link
Copy Markdown

The latest updates on your projects. Learn more about Vercel for GitHub.

Project Deployment Actions Updated
debate-navigator Ready Ready Preview Oct 3, 2026 7:00am UTC
debatelab-staging Ready Ready Preview Oct 3, 2026 7:00am UTC

Copilot AI 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.

Copilot was unable to review this pull request because the user who requested the review has reached their quota limit.

@coderabbitai

coderabbitai Bot commented Oct 3, 2026 •

Copy link
Copy Markdown

Review in Change Stack →

Navigate logical layers of code changes, visualize relationships, and explore their blast radius.

ℹ️ Recent review info
⚙️ Run configuration
  • Configuration used: Organization UI
  • Review profile: CHILL
  • Plan: Free
  • Run ID: bb642589-ec65-4e4f-8e82-a424deb34bcf
📥 Commits

Reviewing files that changed from the base of the PR and between 5ef8b24 and 9c717f7.

📒 Files selected for processing (29)
  • e2e/animation-polish.spec.ts
  • e2e/home-navigation.spec.ts
  • e2e/loading-performance.spec.ts
  • e2e/navigation-performance.spec.ts
  • e2e/public-pages.spec.ts
  • e2e/sparring.spec.ts
  • e2e/startup-shell.spec.ts
  • services/collaboration/src/postgres-store.test.ts
  • src/test/components/EnvironmentSwitcher.test.tsx
  • src/test/debate/debate-context.test.tsx
  • src/test/pages/GeneratePage.test.tsx
  • src/test/sparring/formats.test.ts
  • src/test/vercel-deployment-config.test.ts
  • supabase/functions/_shared/auto-model-router.test.ts
  • supabase/functions/_shared/cors.test.ts
  • supabase/functions/_shared/model-catalog.test.ts
  • supabase/functions/_shared/prompts.test.ts
  • supabase/functions/_shared/prompts/prompt-examples.test.ts
  • supabase/functions/admin/demo-code-contract.test.ts
  • supabase/functions/ai-stream/prompt.test.ts
  • supabase/functions/ai/control-matrix.test.ts
  • supabase/functions/ai/handler-research.test.ts
  • supabase/functions/ai/prompt-builder.test.ts
  • supabase/tests/daily_usage_quota_test.sql
  • supabase/tests/workspace_collaboration_test.sql
  • supabase/tests/workspace_invites_test.sql
  • supabase/tests/workspace_practice_test.sql
  • supabase/tests/workspace_review_test.sql
  • supabase/tests/workspaces_rls_test.sql
💤 Files with no reviewable changes (14)
  • e2e/animation-polish.spec.ts
  • supabase/functions/_shared/prompts/prompt-examples.test.ts
  • e2e/loading-performance.spec.ts
  • e2e/sparring.spec.ts
  • src/test/components/EnvironmentSwitcher.test.tsx
  • e2e/home-navigation.spec.ts
  • supabase/functions/ai-stream/prompt.test.ts
  • e2e/public-pages.spec.ts
  • supabase/functions/ai/handler-research.test.ts
  • src/test/pages/GeneratePage.test.tsx
  • e2e/navigation-performance.spec.ts
  • supabase/functions/_shared/prompts.test.ts
  • e2e/startup-shell.spec.ts
  • supabase/functions/ai/control-matrix.test.ts

Included review availability: This review used your included allowance. Your plan provides up to 1 included review per hour; 0 remain after this review.


📝 Walkthrough

Walkthrough

This pull request changes tests across end-to-end, application, service, Supabase function, and database suites. It removes or narrows many existing assertions, adds a request-level demo-code test, and strengthens checks for membership-query parameters, one-off brainstorm requests, sparring-format duration, and model-catalog behavior.

Changes

End-to-end test coverage

Layer / File(s) Summary
Navigation, shell, and page checks
e2e/animation-polish.spec.ts, e2e/home-navigation.spec.ts, e2e/loading-performance.spec.ts, e2e/navigation-performance.spec.ts, e2e/startup-shell.spec.ts, e2e/public-pages.spec.ts, e2e/sparring.spec.ts
Removes checks for route transitions, navigation, delayed route loading, startup-shell fallback behavior, and landing-page logos. The sparring test retains its default format and initial hidden-state assertions.

Application and service tests

Layer / File(s) Summary
Service and application test assertions
services/collaboration/src/postgres-store.test.ts, src/test/components/EnvironmentSwitcher.test.tsx, src/test/debate/debate-context.test.tsx, src/test/pages/GeneratePage.test.tsx, src/test/sparring/formats.test.ts
Adds a membership-query parameter assertion. The one-off brainstorm test now awaits the request and checks its context and source IDs. The sparring-format test checks exact duration from scheduled speaking time. Other tests are removed.
Deployment configuration tests
src/test/vercel-deployment-config.test.ts
Removes deployment configuration assertions and narrows test-local type and package-loading declarations.

Supabase function tests

Layer / File(s) Summary
Shared model and prompt assertions
supabase/functions/_shared/auto-model-router.test.ts, supabase/functions/_shared/cors.test.ts, supabase/functions/_shared/model-catalog.test.ts, supabase/functions/_shared/prompts.test.ts, supabase/functions/_shared/prompts/prompt-examples.test.ts
Removes fixed model-selection, share-URL, prompt-content, and example-count assertions. The catalog test now checks lookup identity, reasoning-effort support, and default-model availability.
AI prompt and control tests
supabase/functions/ai-stream/prompt.test.ts, supabase/functions/ai/control-matrix.test.ts, supabase/functions/ai/handler-research.test.ts, supabase/functions/ai/prompt-builder.test.ts
Removes several focused control, streaming-eligibility, cancellation, and prompt tests. Adds Hungarian output-language coverage for the generate prompt.
Demo-code creation contract
supabase/functions/admin/demo-code-contract.test.ts
Replaces source-text checks with a mocked request test for returned code, stored hash and role, raw-code omission, and rejection of an admin role without insertion.

Database test assertions

Layer / File(s) Summary
Quota and workspace assertions
supabase/tests/daily_usage_quota_test.sql, supabase/tests/workspace_collaboration_test.sql, supabase/tests/workspace_invites_test.sql, supabase/tests/workspace_practice_test.sql, supabase/tests/workspace_review_test.sql, supabase/tests/workspaces_rls_test.sql
Removes the quota-column assertion and selected workspace table, RPC, and function-signature assertions. Updates the corresponding pgTAP plan counts.

Estimated code review effort: 3 (Moderate) | ~20 minutes

Architecture Summary

Architecture risk: 🔵 Low · up to 9c717

The change affects 4 systems.

Changed systems: supabase, e2e, src, services/collaboration

Architecture concerns
No architecture-level concerns identified.

Review details

Systems and components

  • observed — supabase (service) was modified; 16 changed files map to changed impact.
  • observed — e2e (service) was modified; 7 changed files map to changed impact.
  • observed — src (service) was modified; 5 changed files map to changed impact.
  • observed — services/collaboration (service) was modified; 1 changed file maps to changed impact.

Before / after behavior

  • observed — Modified behavior in e2e/animation-polish.spec.ts: Removed the normal-motion test covering option transition duration, route-transition attributes, generated-result visibility and scrolling, page-entry classes, and completion-toast dismissal.
  • observed — Modified behavior in e2e/home-navigation.spec.ts: Removed the desktop-only test that asserted the navigation links, Current debate label, absence of tool links, Settings visibility, and no document overflow.
  • observed — Modified behavior in e2e/loading-performance.spec.ts: Removed the test that delayed loading AttackPage.tsx during navigation from /app to /app/attack and asserted that the header remained visible and retained its layout marker.
  • observed — Modified behavior in e2e/navigation-performance.spec.ts: Removed the optional Window.__baselineClickAt property declaration.
  • Autopilot · Keep fixing CodeRabbit findings and required CI, and resolving merge conflicts

Note

🎁 Summarized by CodeRabbit Free

Your organization is on the Free plan. CodeRabbit will generate a high-level summary and a walkthrough for each pull request. For a comprehensive line-by-line review, please upgrade your subscription to CodeRabbit Essentials by visiting https://app.coderabbit.ai/settings/billing.

Comment @coderabbitai help to get the list of available commands.

@Programcode
Programcode merged commit f511b29 into main Oct 3, 2026
6 of 11 checks passed
@Programcode
Programcode deleted the chore/test-diet branch October 3, 2026 07:24

This branch was successfully deployed

2 active deployments
Preview – debatelab-staging — 9c717f78 Deployed Oct 3, 2026 by vercel[bot]
Preview – debate-navigator — 9c717f78 Deployed Oct 3, 2026 by vercel[bot]
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.

2 participants