Skip to content

feat: adopt TDD — backfill tests, add Vitest, wire CI#13

Merged
GRACENOBLE merged 1 commit into
mainfrom
repo.tdd
Jun 14, 2026
Merged

feat: adopt TDD — backfill tests, add Vitest, wire CI#13
GRACENOBLE merged 1 commit into
mainfrom
repo.tdd

Conversation

@GRACENOBLE

@GRACENOBLE GRACENOBLE commented Jun 14, 2026

Copy link
Copy Markdown
Owner

Summary

  • TDD mandate enforced across all layers — CLAUDE.md, all AGENTS.md files updated with write-tests-first workflow step and "no new feature without tests" hard rule
  • Backend tests backfilled — 5 new test files covering every previously-untested layer (usecase, health handler, logger middleware, Redis cache via Testcontainers, bootstrap config/probe logic). 30 unit tests, all passing
  • Web testing stack installed — Vitest v4 + @testing-library/react v16 + jsdom; pnpm test wired up; 3 smoke tests for the home page
  • Mobile scaffold tests replacedExampleUnitTest and ExampleInstrumentedTest deleted; replaced with GreetingFormatTest (JVM unit) and GreetingTest (Compose UI instrumented)
  • CI wired upbackend-ci.yml, web-ci.yml (replaces frontend-ci.yml), mobile-ci.yml all corrected: action versions, working directories, make targets, and stripped Playwright/Firebase stubs that don't belong in this project
  • Docs updatedbackend/docs/testing.md expanded; web/docs/testing.md created; mobile/docs/testing.md updated

Test plan

  • cd backend && go vet ./... — passes clean
  • cd backend && go test ./internal/usecase/... ./internal/transport/... ./internal/bootstrap/... -v — 30/30 unit tests pass (no Docker needed)
  • cd backend && make itest — Postgres + Redis integration tests pass (requires Docker)
  • cd web && pnpm test — 3/3 Vitest tests pass
  • cd web && pnpm lint && pnpm build — clean
  • cd mobile && ./gradlew lint && ./gradlew test — lint clean, GreetingFormatTest passes
  • cd mobile && ./gradlew connectedAndroidTestGreetingTest passes (requires emulator/device)
  • CI workflows trigger on PRs touching backend/**, web/**, mobile/** respectively

Summary by CodeRabbit

  • Tests

    • Added comprehensive test suites across all platforms with TDD requirements.
    • Established testing patterns for backend, mobile, and web applications.
    • Added example tests and test infrastructure configuration.
  • Chores

    • Added automated CI/CD pipelines for backend, mobile, and web platforms.
    • Updated development guidelines and documentation to enforce testing standards.
    • Configured testing tools and dependencies across all projects.

Establishes test-driven development as the mandatory approach across all
three layers and backfills coverage for all previously untested code.

Backend (Go):
- health_usecase: 11 table-driven unit tests covering every message branch
- health_handler: 200 and 503 path unit tests
- logger middleware: 2xx/4xx/5xx pass-through, query string, gin errors
- redis cache: Testcontainers integration tests for all 7 CacheService methods
- bootstrap: loadConfig defaults/overrides, validateConfig all-present/missing,
  jitteredBackoff bounds, probeWithRetry success/retry/timeout/cancel
- Makefile itest now covers ./internal/infrastructure/... (adds Redis)

Web (Next.js):
- Vitest v4 + @testing-library/react v16 + jsdom installed and configured
- vitest.config.ts: jsdom env, @vitejs/plugin-react, next/image+link mocks
- __tests__/page.test.tsx: 3 smoke tests for the home page
- pnpm test / test:watch / test:ui scripts added to package.json

Mobile (Android):
- GreetingFormatTest.kt replaces ExampleUnitTest (JVM, real greeting logic)
- GreetingTest.kt replaces ExampleInstrumentedTest (Compose UI, createComposeRule)

Docs + instructions:
- CLAUDE.md, AGENTS.md (all layers): TDD mandate, write-tests-first workflow
  step, "no new feature without tests" hard rule
- backend/docs/testing.md: expanded with usecase, handler, Redis, bootstrap patterns
- web/docs/testing.md: created (framework, patterns, what to test, quality gate)
- mobile/docs/testing.md: updated with TDD mandate, Composable test checklist

CI:
- backend-ci.yml: fixed action versions, added working-directory, corrected make targets
- web-ci.yml: replaces frontend-ci.yml — correct paths, pnpm test, removed
  Playwright/Firebase stubs that don't exist in this project
- mobile-ci.yml: fixed action version
@github-actions github-actions Bot added area: backend Go REST API area: web Next.js web app area: mobile Android app (Kotlin + Jetpack Compose) area: infra CI/CD, infrastructure, deployment, and DevOps type: chore Cleanup or maintenance tasks labels Jun 14, 2026
@coderabbitai

coderabbitai Bot commented Jun 14, 2026

Copy link
Copy Markdown

Review Change Stack

Caution

Review failed

Pull request was closed or merged during review

📝 Walkthrough

Walkthrough

Adds three GitHub Actions CI workflows (backend, web, mobile), installs Vitest with React Testing Library for the web layer, adds backend unit tests for usecase/handler/middleware and integration tests for Redis cache and bootstrap, replaces mobile scaffold tests with Greeting-based examples, expands the Makefile itest scope to all infrastructure packages, and updates all developer guidance documents to mandate TDD.

Changes

TDD Testing Infrastructure & CI

Layer / File(s) Summary
Per-platform CI workflows
.github/workflows/backend-ci.yml, .github/workflows/mobile-ci.yml, .github/workflows/web-ci.yml
Adds three new GitHub Actions workflows triggered on pull_request to main, each path-filtered and sequentially executing lint, test, and build steps for their respective platform.
Web Vitest setup, mocks, first test, and docs
web/package.json, web/vitest.config.ts, web/vitest.setup.ts, web/__mocks__/next/image.tsx, web/__mocks__/next/link.tsx, web/__tests__/page.test.tsx, web/docs/testing.md, web/docs/_index.md, web/AGENTS.md
Installs Vitest, React Testing Library, and jsdom; configures Vitest with jsdom environment and module aliases for next/image and next/link pointing to new mock components; adds the first Home page test; adds comprehensive web/docs/testing.md and updates commands and testing guidance in web/AGENTS.md.
Backend usecase, handler, and middleware unit tests
backend/internal/usecase/health_usecase_test.go, backend/internal/transport/handlers/health_handler_test.go, backend/internal/transport/middleware/logger_test.go, backend/docs/testing.md
Adds mockHealthReader and table-driven usecase tests; adds Gin-TestMode handler tests for 200 and 503 responses; adds four Logger middleware behavior tests. Accompanied by usecase and handler unit test sections in backend/docs/testing.md.
Backend Redis & bootstrap integration tests + Makefile
backend/internal/infrastructure/cache/redis/cache_test.go, backend/internal/bootstrap/bootstrap_test.go, backend/Makefile, backend/docs/testing.md, backend/docs/_index.md
Adds a Testcontainers Redis integration suite with TestMain lifecycle and tests for all cache operations; adds bootstrap unit tests for loadConfig, validateConfig, jitteredBackoff, and probeWithRetry; expands itest Makefile target to ./internal/infrastructure/...; documents Redis, bootstrap, and Postgres patterns in backend/docs/testing.md.
Mobile Greeting tests replacing scaffold tests
mobile/app/src/test/java/com/company/template/GreetingFormatTest.kt, mobile/app/src/androidTest/java/com/company/template/GreetingTest.kt, mobile/app/src/test/java/com/company/template/ExampleUnitTest.kt, mobile/app/src/androidTest/java/com/company/template/ExampleInstrumentedTest.kt, mobile/docs/testing.md, mobile/docs/_index.md, mobile/AGENTS.md
Removes scaffold ExampleUnitTest and ExampleInstrumentedTest; adds GreetingFormatTest (JVM unit) and GreetingTest (Compose instrumented UI test for "Hello World!" and "Hello Android!"); updates mobile/docs/testing.md with canonical examples, TDD mandate, and New Composable checklist.
Cross-cutting TDD mandate docs
AGENTS.md, CLAUDE.md, backend/AGENTS.md
Updates root AGENTS.md and CLAUDE.md with TDD requirements, per-platform test commands, Testcontainers/Vitest/Compose guidance, and a hard rule forbidding new features without tests; updates backend/AGENTS.md with TDD directive, real-instance Testcontainers guidance, and a Test placement table.

Estimated code review effort

🎯 3 (Moderate) | ⏱️ ~25 minutes

Poem

🐇 Hop, hop, tests first before the code!
Red then green, that's TDD's road.
Containers spin for Redis and Postgres too,
Compose rules test what Composables do.
Vitest mocks the links and images away,
CI guards every PR come what may!

🚥 Pre-merge checks | ✅ 4 | ❌ 1

❌ Failed checks (1 warning)

Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 15.91% which is insufficient. The required threshold is 80.00%. Write docstrings for the functions missing them to satisfy the coverage threshold.
✅ Passed checks (4 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title 'feat: adopt TDD — backfill tests, add Vitest, wire CI' accurately captures the main change: establishing TDD across all three layers and backfilling test coverage.
Linked Issues check ✅ Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check ✅ Passed Check skipped because no linked issues were found for this pull request.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.

✨ Finishing Touches
📝 Generate docstrings
  • Create stacked PR
  • Commit on current branch
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch repo.tdd

Warning

There were issues while running some tools. Please review the errors and either fix the tool's configuration or disable the tool if it's a critical failure.

🔧 golangci-lint (2.12.2)

level=error msg="[linters_context] typechecking error: pattern ./...: directory prefix . does not contain main module or its selected dependencies"


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 and usage tips.

@GRACENOBLE GRACENOBLE merged commit a08a756 into main Jun 14, 2026
4 of 5 checks passed
@GRACENOBLE GRACENOBLE deleted the repo.tdd branch June 14, 2026 23:10
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

area: backend Go REST API area: infra CI/CD, infrastructure, deployment, and DevOps area: mobile Android app (Kotlin + Jetpack Compose) area: web Next.js web app type: chore Cleanup or maintenance tasks

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant