Skip to content

feat: add unit coverage thresholds, Testcontainers Redis, real health contract tests, and expanded admin tests#678

Open
JoyAdah wants to merge 477 commits into
Vatix-Protocol:mainfrom
JoyAdah:feat/testing-coverage-threshold-redis-health-admin
Open

feat: add unit coverage thresholds, Testcontainers Redis, real health contract tests, and expanded admin tests#678
JoyAdah wants to merge 477 commits into
Vatix-Protocol:mainfrom
JoyAdah:feat/testing-coverage-threshold-redis-health-admin

Conversation

@JoyAdah

@JoyAdah JoyAdah commented Jun 29, 2026

Copy link
Copy Markdown

This PR closes #608, closes #609, closes #611, closes #612.

Summary

  • Add vitest coverage threshold in CI #608 — Added 80% global coverage thresholds to vitest.unit.config.ts; updated CI to run test:unit:coverage so thresholds are enforced on every push
  • Add Testcontainers Redis for integration tests #609 — Integration setup now spins up a Redis container via testcontainers (using GenericContainer("redis:7-alpine")) instead of blindly defaulting to localhost:6379; added testcontainers devDependency
  • Replace mock health test with real /v1/health #611 — Rewrote tests/contract/health-and-ready.test.ts to use buildTestApp + a mocked Prisma client; all health assertions are now deterministic (toBe(200), toBe("ok")) instead of soft [200, 503] checks
  • Add admin markets integration test suite #612 — Expanded tests/integration/admin.test.ts with ordering, count-matches-length, field-preservation, all status transitions (ACTIVE→RESOLVED, CANCELLED→ACTIVE), and auth rejection tests for the PATCH endpoint

Test plan

  • pnpm test:unit:coverage passes with coverage ≥ 80% on all metrics
  • pnpm test:integration passes with Redis container started automatically (no manual Redis needed)
  • Contract health tests all pass deterministically without a live DB or Redis
  • All new admin integration tests pass against the test DB

Mimah97 and others added 30 commits May 27, 2026 20:07
…egration-setup-237

test(api): add Vitest test for integration test setup
…ons-route-242

chore(api): add env vars for positions route to .env.example
…sma-schema-243

test(api): add Vitest test for Prisma schema
…validator-type-244

feat(api): add TypeScript type for migration validator
…e/onboarding-tasks

Feature/onboarding tasks
…-env-example

chore: add Redis env vars to .env.example
…ve-error-handler-log

fix: improve error handler log message with structured fields
…pi-input-validation

feat: add input validation to OpenAPI stub
…ent-rate-limiter

docs: document rate limiter in docs/rate-limiting.md
…sor-env-example

docs: add indexer cursor env example
…atix-Protocol#349

- Vatix-Protocol#346 [api]: Add Vitest test for docker-compose.yml
  Added tests/docker-compose.test.ts that validates the compose file
  exists, defines postgres and redis services, exposes the expected
  ports, and declares named volumes for persistence.

- Vatix-Protocol#347 [indexer]: Add TypeScript type for metrics log
  Added IndexerMetricsLog interface to apps/indexer/src/metrics.ts and
  used it with a 'satisfies' check in main.ts when logging the startup
  metrics snapshot. No 'any' in new code; exported from metrics module.

- Vatix-Protocol#348 [oracle]: Improve log messages in submission queue
  Replaced all console.log/warn/error calls in oracle-service.ts with
  structured Logger calls (info/warn/error). Logger is injected via
  OracleServiceConfig.logger (optional, defaults to no-op) so existing
  tests require no changes. Each log entry carries structured fields
  (marketId, source, error, attempt, delayMs) at the appropriate level.

- Vatix-Protocol#349 [workers]: Add input validation to finalization job
  Added FinalizationValidationError (statusCode=400) and a guard at the
  top of FinalizationJob.run() that throws it when challengeWindowSeconds
  is negative, NaN, or Infinity. Added job.test.ts covering the invalid
  and valid input cases.
…-api-indexer-oracle-workers-improvements

feat(api,indexer,oracle,workers): address issues Vatix-Protocol#346-Vatix-Protocol#349
…env-error-handler-comment

[topup] [api] Add env var to .env.example for error handler (2)
…atix-Protocol#299 Vatix-Protocol#344

- Vatix-Protocol#297: Add input validation to test utilities
  - Add validateDatabaseUrl() function with comprehensive input validation
  - Return false for invalid inputs (non-strings, empty, invalid URLs, wrong schemes)
  - Validate parameters in cleanDatabase()
  - Add 13 test cases covering all validation scenarios

- Vatix-Protocol#298: Document logger in docs/
  - Create logger.md with complete Logger API documentation
  - Include usage examples for routes, workers, and databases
  - Document log levels, environment configuration, and best practices
  - Add link from README

- Vatix-Protocol#299: Add env var for config types to .env.example
  - Add Configuration Types Reference section
  - Document REQUIRED vs OPTIONAL distinction
  - Explain Enum, Integer, URL, and String type validation
  - Add missing env vars: ORACLE_CHALLENGE_WINDOW_SECONDS, ORACLE_LOG_LEVEL, LOG_LEVEL

- Vatix-Protocol#344: Document graceful shutdown in docs/
  - Create graceful-shutdown.md with comprehensive guide
  - Include signal handling, worker pattern, and resource cleanup
  - Add timeout protection and testing strategies
  - Cover environment-specific considerations (Docker, Kubernetes)
  - Add link from README
…xample

chore: add comprehensive env var documentation to .env.example (Vatix-Protocol#230)
Mimah97 and others added 28 commits June 27, 2026 16:01
…-queue-migration

feat(workers): migrate oracle and settlement consumers to BullMQ (Vatix-Protocol#551)
…idate-position-routes

feat: add GET /v1/wallets/:wallet/positions/:marketId sub-route (Vatix-Protocol#556)
…openapi-docs

feat: mount interactive OpenAPI docs at /docs (Vatix-Protocol#557)
The /v1/ready endpoint was missing response body schemas for both
200 and 503 responses. Added DependencyResult component schema and
wired it into the readiness endpoint responses.
redisConnectionFromEnv() returned { url } which BullMQ does not
accept as a connection option. Parse the URL into { host, port,
password } so BullMQ workers can connect properly.
…ring

Trade.outcome was declared as String @db.VarChar(8) which bypasses
Prisma's enum validation, unlike Order.outcome which correctly uses
the Outcome enum. Align both models to use the same type.
Audit stream keys were hardcoded without REDIS_KEY_PREFIX, unlike
the settlement queue. This caused cross-environment contamination
in shared Redis deployments. Read prefix from env at construction.
…arison

The resolution parser in the workers scope was using `outcome === true`
which is redundant for boolean values and fragile if outcome type changes.
…orker"

The oracle queue nack() was using a hardcoded "nack-worker" consumer name
in xclaim, causing retried messages to be assigned to a phantom consumer
that never processes them. Messages would get stuck instead of being retried.
…Failure

Both methods had empty data: {} in their Prisma calls, making them no-ops.
updateAttempt now degrades confidence on retry. updateOnFailure now clears
candidateResolution and marks the ResolutionCandidate as REJECTED.
…-resolution-oracle-submission

Fix/minimal tasks resolution oracle submission
…egration tests

- Enforce 80% coverage thresholds via vitest.unit.config.ts in CI (Vatix-Protocol#608)
- Spin up Redis via Testcontainers in integration setup instead of defaulting to localhost (Vatix-Protocol#609)
- Rewrite contract health tests to use buildTestApp with deterministic mocked DB assertions (Vatix-Protocol#611)
- Add comprehensive admin markets integration tests: ordering, count accuracy, all status transitions, field preservation, edge cases (Vatix-Protocol#612)

Co-Authored-By: JoyAdah <joyadah101@gmail.com>
@Mimah97

Mimah97 commented Jun 30, 2026

Copy link
Copy Markdown
Contributor

Fix this pr and link issue @JoyAdah

@JoyAdah

JoyAdah commented Jul 1, 2026

Copy link
Copy Markdown
Author

no conflict

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.