Skip to content

Harden test determinism and restore frontend CI gating#135

Merged
rendall merged 4 commits intomasterfrom
harden-phase3-plan
Mar 3, 2026
Merged

Harden test determinism and restore frontend CI gating#135
rendall merged 4 commits intomasterfrom
harden-phase3-plan

Conversation

@rendall
Copy link
Owner

@rendall rendall commented Mar 3, 2026

Summary

Implements Phase 03: test determinism and CI hardening.

This PR completes checklist items C01-C11 and restores required frontend test gating in CI while preserving full locale coverage.

What changed

Backend test env determinism

  • Added backend Jest setup env injection:
    • src/tests/backend/setup-env.ts
    • wired via setupFiles in jest.backend.config.ts
  • Backend tests now derive missing env values from example.env and inject deterministic non-default values for *SECRET*/*PASSWORD*.
  • Refactored src/tests/backend/secrets.test.ts:
    • removed hard failure on .env file existence
    • kept local onboarding signal as non-blocking warning

Frontend locale/date determinism (full matrix preserved)

  • Refactored src/tests/frontend/frontend-utilities.test.ts:
    • replaced brittle exact-locale prose assertions with deterministic structural checks
    • kept the full existing locale matrix
    • added locale support/resolution guardrails
    • normalized fixtures to UTC-stable inputs
    • retained integration-style localized rendering check
  • Updated test script wiring to run frontend tests with TZ=UTC:
    • package.json
    • yarn.lock (added cross-env)

CI hardening and gating

  • Updated .github/workflows/netlify-api-test.yml:
    • removed .env bootstrap command (node ./scripts/createTestEnv.mjs) from backend test path
    • set TZ=UTC for test execution
    • restored frontend CI gating by running yarn test:frontend in required workflow
    • kept existing MongoDB binary pinning behavior intact

Documentation

  • Added and completed Phase 03 checklist:
    • docs/plans/phase-03-checklist.md
  • Hardened plan with QC/integration/sanity pass decisions:
    • docs/plans/phase-03-test-determinism-and-ci-hardening.md
  • Added implementation convention final clean pass:
    • docs/norms/implementation.md (yarn run fix before PR)
  • Updated README test section with deterministic test contract:
    • backend tests do not require .env on disk
    • frontend tests run under TZ=UTC

Validation

  • yarn test:backend (with .env present)
  • yarn test:backend (with .env temporarily removed)
  • yarn test:frontend
  • yarn test
  • yarn run fix then yarn test again

All suites pass locally after changes.

Scope notes

  • No locale removals; i18n coverage remains full-matrix.
  • No product formatting redesign; only test determinism and CI gating hardening.

@rendall rendall requested a review from Copilot March 3, 2026 16:49
@rendall rendall merged commit 709fdd5 into master Mar 3, 2026
9 checks passed
@rendall rendall deleted the harden-phase3-plan branch March 3, 2026 16:55
Copy link

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

This PR hardens test determinism across backend and frontend suites and restores required frontend test gating in CI, while preserving the existing full locale coverage.

Changes:

  • Inject backend test environment variables deterministically from example.env via a Jest setupFiles hook (including non-default secret/password values).
  • Refactor frontend longFormatDate tests to avoid brittle exact-string assertions while keeping the full locale matrix, and run frontend tests under TZ=UTC.
  • Update CI workflow to remove .env bootstrapping, set TZ=UTC, and run both backend and frontend test suites as part of the required gate.

Reviewed changes

Copilot reviewed 10 out of 14 changed files in this pull request and generated 3 comments.

Show a summary per file
File Description
yarn.lock Adds cross-env lock entry for cross-platform TZ=UTC script support.
package.json Runs frontend tests with TZ=UTC via cross-env; adds cross-env to devDependencies.
jest.backend.config.ts Wires new backend Jest setup file into setupFiles while preserving preset setup files.
src/tests/backend/setup-env.ts New Jest setup file to load/inject env from example.env with deterministic secret/password values.
src/tests/backend/secrets.test.ts Removes hard failure on missing .env; replaces with non-blocking onboarding warning.
src/tests/frontend/frontend-utilities.test.ts Replaces brittle locale prose assertions with deterministic Intl-based structural/equality checks across full locale matrix.
.github/workflows/netlify-api-test.yml Removes .env bootstrap, sets TZ=UTC, and restores frontend test gating alongside backend tests.
README.md Updates test instructions to reflect deterministic backend env injection and frontend TZ=UTC contract.
docs/plans/phase-03-test-determinism-and-ci-hardening.md Expands Phase 03 plan with explicit scope decisions and determinism strategy.
docs/plans/phase-03-checklist.md Adds completed Phase 03 checklist mapping to implemented work items.
docs/norms/implementation.md Adds “run yarn run fix before opening a PR” convention.
docs/archive/phase-02-backend-correctness-and-cors.md Archives Phase 02 checklist documentation.
docs/archive/phase-01-5-ci-stabilization-and-test-gating.md Archives Phase 01.5 CI stabilization/test gating documentation.
docs/archive/phase-01-5-checklist.md Archives Phase 01.5 checklist documentation.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

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