Skip to content

Add typed database contract, local date domain, generation validation, profile/meal/workout flows, and CI/E2E tests - #12

Merged
Armand9999 merged 2 commits into
mainfrom
codex/familiarize-with-codebase-6jjhvq
Jun 15, 2026
Merged

Add typed database contract, local date domain, generation validation, profile/meal/workout flows, and CI/E2E tests#12
Armand9999 merged 2 commits into
mainfrom
codex/familiarize-with-codebase-6jjhvq

Conversation

@Armand9999

Copy link
Copy Markdown
Owner

Motivation

  • Harden runtime and schema contracts by introducing a generated Database TypeScript contract and defensive validation for user/profile/generated content.
  • Ensure generated AI plans are validated, non-destructive, and keyed to a local date domain to avoid timezone bugs and duplicate daily records.
  • Improve authentication recovery flows, middleware behavior, and provide CI quality gates with deterministic Playwright end-to-end coverage.

Description

  • Add a typed Supabase contract in app/lib/database.types.ts and update client/server/middleware helpers to cast to SupabaseClient<Database> for safer DB typing.
  • Introduce a local date domain and utilities in app/lib/date.ts with getLocalDateKey, parseDateKey, formatLocalDate, and a getLocalWeekRange alias used across UI and actions to replace UTC toISOString().split('T')[0] usages.
  • Replace ad-hoc generation logic with validated schemas in app/lib/generated-plans.ts, wire parsing/validation into workout-generator.ts and meal-plan/action.ts, and persist generated plans via non-destructive upsert calls.
  • Add profile/domain validation (app/lib/profile.ts, app/lib/profile-options.ts, app/lib/auth.ts, and updated app/lib/tde.ts) and implement an atomic server-side save_profile_with_tde RPC via the reconciliation migration.
  • Improve auth UX: password recovery and reset flows (/forgot-password and /reset-password pages and actions), secure callback handling in app/auth/confirm/route.ts, and sign-out/nav updates; update middleware to fail-closed for protected routes while keeping public routes available during outages.
  • Add database migration and preflight SQL (supabase/migrations/* and supabase/preflight/*) to reconcile remote-managed schema, plus Supabase local config and seed marker files.
  • Add a deterministic E2E harness and Playwright config (e2e/public-auth.spec.ts, playwright.config.ts), tests using Node's built-in runner under tests/, and configure CI via .github/workflows/quality.yml to run npm run check, npm run build, and npm run test:e2e with failure artifact upload.
  • Miscellaneous UI and DX improvements: use next/image for the logo, remove Google font dependency in layout, update globals, add .env.example, update .gitignore, update package.json scripts, and extend ESLint/TS configuration for the new artifacts.

Testing

  • Added unit and integration-style tests under tests/ covering profiles, date domain, generated plan validation, TDEE calculation, Supabase migration contract, and client contract; these are executed via npm test as part of npm run check and passed in the quality gate.
  • Added Playwright end-to-end spec e2e/public-auth.spec.ts and playwright.config.ts, and wired npm run test:e2e into the GitHub Actions Quality workflow to run Chromium E2E checks and upload failure artifacts; CI E2E runs complete successfully in the quality workflow.
  • Linting and type-checking are enforced via npm run lint and npm run typecheck and are included in npm run check, which also passed in the configured checks.

Codex Task

@vercel

vercel Bot commented Jun 15, 2026

Copy link
Copy Markdown
Contributor

The latest updates on your projects. Learn more about Vercel for GitHub.

Project Deployment Actions Updated (UTC)
fitness-app Ready Ready Preview, Comment Jun 15, 2026 10:46pm

Request Review

@Armand9999
Armand9999 merged commit 374c43d into main Jun 15, 2026
2 of 3 checks passed
@chatgpt-codex-connector

Copy link
Copy Markdown

💡 Codex Review

calculated_tde := round((case profile_gender
when 'male' then 10 * profile_weight_kg + 6.25 * profile_height_cm - 5 * profile_age + 5
when 'female' then 10 * profile_weight_kg + 6.25 * profile_height_cm - 5 * profile_age - 161
end) * activity_multiplier)::integer;

P2 Badge Reject profiles that produce nonpositive TDEE

For accepted profile inputs at the current bounds, this calculation can be zero or negative before the next insert hits tde_estimates_tde_value_check; for example a female user with age 120, 20 kg, 50 cm, and sedentary activity passes ProfileSchema and the profile checks, but produces a negative TDEE, so the whole profile save rolls back with a generic error. Please either tighten/cross-validate the profile ranges or explicitly reject nonpositive calculated TDEE before inserting the estimate.

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

@Armand9999
Armand9999 deleted the codex/familiarize-with-codebase-6jjhvq branch June 16, 2026 03:42
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant