Skip to content

test: trim duplicate tests and cut suite run time - #87

Merged
lorenzocorallo merged 3 commits into
mainfrom
test/trim-suite-and-speed-up
Oct 20, 2026
Merged

lorenzocorallo merged 3 commits into
mainfrom
test/trim-suite-and-speed-up

Conversation

@lorenzocorallo

Copy link
Copy Markdown
Member

Why

The suite took ~6.6 s locally (~15.6 s in CI). Most of that was waiting, not testing. A few tests also repeated coverage that other tests already provide.

Speed

  • src/trpc.ts: the timing middleware adds a 100–200 ms delay to every call when tRPC's isDev is set. isDev is true for any NODE_ENV except production, so test got the delay too. It now runs only when env.NODE_ENV === "development". Development and production behave as before.
    • azure-router 6.0 s → 0.26 s, idp-policy 3.2 s → 3 ms, idp-router 3.2 s → 1.2 s (what's left is the import of the app router).
  • tests/seed-db.test.ts: beforeAll did a full seed (~1.9 s), but beforeEach truncates every table right after. The tests only needed the migrated schema, so beforeAll now imports @/db, which applies the migrations (~0.3 s). This file is the slowest one in CI.

Measured locally: the suite without the DB went from 6.6 s to 1.8 s, and seed-db from 14.6 s to 10.5 s (run-to-run noise included).

Removed tests (each one checks something another test already covers)

  • cipher › has stable payload format: the IV is always zero, so the pinned DETERMINISTIC_PAYLOAD already fixes the format.
  • tg-users-creation-history › is limited to token callers…: this checked the policy through a mocked dashboard(). idp-router asserts the real policy of tg.users.getCreationHistory, including the scope and tokenOnly.
  • azure-router › the two stale snapshot cases: they only made the mocked has() return false. That is the same code path as the no permission cases, because nothing in the router reads status().
  • azure-router › the addMember assertion with member permissions: the member permissions alone case of the it.each makes the same check with the same context.

Checks

  • bun run typecheck and biome ci pass
  • Full suite passes, with seed-db run against a fresh Postgres 18 on an empty schema

tRPC's isDev is true for every NODE_ENV but production, so the 100-200 ms
per-call delay also ran under tests. It made up most of the suite's run
time (azure-router 6 s, idp-policy 3 s, idp-router 2 s).
- cipher: the payload format test is implied by the pinned deterministic
  payload, since the IV is always zero.
- tg-users-creation-history: idp-router already asserts the real policy
  of tg.users.getCreationHistory, including its scope.
- azure-router: the stale-snapshot cases only made the mocked has()
  return false, the same path as the no-permission cases; the addMember
  check with member permissions repeats the matching it.each case.
Every test truncates all tables first, so the initial seed (~1.9 s) was
thrown away; only the schema it migrated was needed (~0.3 s).
@coderabbitai

coderabbitai Bot commented Oct 20, 2026

Copy link
Copy Markdown
Contributor

Warning

Review limit reached

You've used all free OSS reviews for now. Wait for the free limit to reset to keep reviewing this public repository.

Next included review available in 44 minutes.

Check out review usage here.

View limit details

Limit details: You’ve used the included review currently available.

Learn how review limits work.

Review configuration:

⚙️ Run configuration
  • Configuration used: Organization UI
  • Review profile: CHILL
  • Plan: Advanced
  • Run ID: 84ccbecc-c4f2-47e6-8f7a-4a4046456b6e
📥 Commits

Reviewing files that changed from the base of the PR and between 5867df6 and 722a707.

📒 Files selected for processing: 5
  • src/trpc.ts
  • tests/azure-router.test.ts
  • tests/cipher.test.ts
  • tests/seed-db.test.ts
  • tests/tg-users-creation-history.test.ts
  • Autofix · Keep fixing CodeRabbit findings and required CI, and resolving merge conflicts

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

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

@lorenzocorallo
lorenzocorallo merged commit bc082e6 into main Oct 20, 2026
2 checks passed
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