Skip to content

Add Vitest unit tests for critical business logic#75

Open
tommy-mor wants to merge 1 commit into
masterfrom
cursor/vitest-unit-service-tests-c58e
Open

Add Vitest unit tests for critical business logic#75
tommy-mor wants to merge 1 commit into
masterfrom
cursor/vitest-unit-service-tests-c58e

Conversation

@tommy-mor

Copy link
Copy Markdown
Contributor

Summary

Adds Vitest and a first suite of 86 unit tests covering the highest-risk pure logic paths (no Playwright / no DB integration).

What

  • Install Vitest with bun run test / test:watch
  • CI job for unit tests
  • Extract pure helpers for testability:
    • mapBanLogic.ts (ban/pick turn machine)
    • matchScoring.ts (winner tally, manage-match checks, score validation)
    • redirect.ts (open-redirect sanitization)
  • Raise scrypt maxmem so N=32768 hashing works under OpenSSL’s default memory ceiling

Coverage

Auth guards, match scoring (incl. playoff arena tallies), map ban BO3/5/7 sequences, password hash/verify (versioned + legacy, no plaintext fallback), redirect sanitization, rate limiting, form/Zod helpers, Steam ID conversions, tournament draft validation, bracket topology helpers.

Intentionally out of scope

  • Playwright / E2E
  • Prisma-backed service integration tests (payments capture, roster mutations) — needs a test DB next

Test plan

  • bun run test — 14 files, 86 passing
  • bun run format / check / boundary-check / knip
  • CI green on this PR
Open in Web Open in Cursor 

Stand up Vitest with CI coverage and 86 unit tests across auth,
scoring, map bans, passwords, redirects, rate limits, and draft
validation. Extract map ban and match scoring helpers so they can
be tested without loading Prisma.
@tommy-mor
tommy-mor marked this pull request as ready for review July 26, 2026 20:44
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