diff --git a/apps/api/features/step-definitions/planning.steps.ts b/apps/api/features/step-definitions/planning.steps.ts index 952660a..7a065dc 100644 --- a/apps/api/features/step-definitions/planning.steps.ts +++ b/apps/api/features/step-definitions/planning.steps.ts @@ -1,12 +1,14 @@ import assert from "node:assert/strict"; -import { DateTime } from "@batch-cooking/date-tools"; import { Given, Then, When } from "@cucumber/cucumber"; import { prisma } from "../../src/db/prisma.js"; +import { TEST_REFERENCE_DATE } from "../../test-support/reference-date.js"; import type { CustomWorld } from "../support/world.js"; -/** `GET /planning` takes `?date=` explicitly — this scenario wording ("the current planning") maps to "today". */ +/** `GET /planning` takes `?date=` explicitly — this scenario wording ("the current planning") maps to the fixed test "today" (see `TEST_REFERENCE_DATE`). */ When("I request the current planning", async function (this: CustomWorld) { - this.response = await this.agent.get("/planning").query({ date: DateTime.utc().toISODate() }); + this.response = await this.agent + .get("/planning") + .query({ date: TEST_REFERENCE_DATE.toISODate() }); }); Then("the current planning response should be empty", function (this: CustomWorld) { @@ -27,16 +29,11 @@ Given( const houseId: number = houseRes.body.id; const recipe = await prisma.recipe.create({ data: { name: recipeName } }); - const today = new Date(); const planning = await prisma.planning.create({ data: { houseId, - startDate: new Date( - Date.UTC(today.getUTCFullYear(), today.getUTCMonth(), today.getUTCDate() - 2), - ), - finishDate: new Date( - Date.UTC(today.getUTCFullYear(), today.getUTCMonth(), today.getUTCDate() + 2), - ), + startDate: TEST_REFERENCE_DATE.minus({ days: 2 }).toJSDate(), + finishDate: TEST_REFERENCE_DATE.plus({ days: 2 }).toJSDate(), }, }); await prisma.planningItem.create({ diff --git a/apps/api/test-support/reference-date.ts b/apps/api/test-support/reference-date.ts new file mode 100644 index 0000000..cc82e40 --- /dev/null +++ b/apps/api/test-support/reference-date.ts @@ -0,0 +1,15 @@ +import { DateTime } from "@batch-cooking/date-tools"; + +/** + * The fixed "today" every date-sensitive test builds its fixtures and + * queries around, instead of the real system clock (`new Date()` / + * `DateTime.utc()`). Reading the real clock made those tests + * non-deterministic: behavior could shift depending on which day/time they + * happened to run (e.g. a UTC-midnight boundary behaving differently right + * around real midnight), and made it impossible to reliably target a + * specific day-of-week. Any fixed UTC date works here; this one has no + * special meaning — tests that care about a specific weekday should derive + * it from this constant (e.g. `.set({ weekday: 1 })`) rather than hardcode + * one that happens to match today by coincidence. + */ +export const TEST_REFERENCE_DATE = DateTime.fromISO("2026-06-15", { zone: "utc" }); diff --git a/apps/api/test/planning.test.ts b/apps/api/test/planning.test.ts index 2dd885d..e96a609 100644 --- a/apps/api/test/planning.test.ts +++ b/apps/api/test/planning.test.ts @@ -1,10 +1,11 @@ -import { DateTime } from "@batch-cooking/date-tools"; +import type { DateTime } from "@batch-cooking/date-tools"; import { ErrorCode, type SignupInput } from "@batch-cooking/shared"; import { faker } from "@faker-js/faker"; import { expect } from "chai"; import request from "supertest"; import { createApp } from "../src/app.js"; import { prisma } from "../src/db/prisma.js"; +import { TEST_REFERENCE_DATE } from "../test-support/reference-date.js"; import { resetDatabase } from "../test-support/reset-db.js"; /** See `auth.test.ts` — same rationale for generating rather than hardcoding. */ @@ -19,9 +20,9 @@ function buildSignupPayload(): SignupInput { }; } -/** Today, as the `YYYY-MM-DD` string `GET /planning`'s `?date=` expects. */ +/** The fixed test "today", as the `YYYY-MM-DD` string `GET /planning`'s `?date=` expects. */ function today(): string { - return isoDate(DateTime.utc()); + return isoDate(TEST_REFERENCE_DATE); } /** `toISODate()` only returns `null` for an invalid `DateTime` — never the case for the always-valid values built in this file. */ @@ -97,16 +98,11 @@ describe("Planning", () => { const houseId: number = houseRes.body.id; const recipe = await prisma.recipe.create({ data: { name: "Ratatouille" } }); - const now = new Date(); const planning = await prisma.planning.create({ data: { houseId, - startDate: new Date( - Date.UTC(now.getUTCFullYear(), now.getUTCMonth(), now.getUTCDate() - 2), - ), - finishDate: new Date( - Date.UTC(now.getUTCFullYear(), now.getUTCMonth(), now.getUTCDate() + 2), - ), + startDate: TEST_REFERENCE_DATE.minus({ days: 2 }).toJSDate(), + finishDate: TEST_REFERENCE_DATE.plus({ days: 2 }).toJSDate(), }, }); await prisma.planningItem.create({ @@ -150,7 +146,7 @@ describe("Planning", () => { const houseId: number = houseRes.body.id; const recipe = await prisma.recipe.create({ data: { name: "Curry de lentilles" } }); - const nextWeek = DateTime.utc().plus({ weeks: 1 }); + const nextWeek = TEST_REFERENCE_DATE.plus({ weeks: 1 }); const planning = await prisma.planning.create({ data: { houseId, diff --git a/apps/web/src/features/profile/AllergySelect.tsx b/apps/web/src/features/profile/AllergySelect.tsx index 0141dae..824b321 100644 --- a/apps/web/src/features/profile/AllergySelect.tsx +++ b/apps/web/src/features/profile/AllergySelect.tsx @@ -35,16 +35,24 @@ export function AllergySelect({ legend, allergies, value, onChange }: AllergySel return (
); } diff --git a/apps/web/src/features/profile/profile-forms.scss b/apps/web/src/features/profile/profile-forms.scss index 68fdce2..c7aa570 100644 --- a/apps/web/src/features/profile/profile-forms.scss +++ b/apps/web/src/features/profile/profile-forms.scss @@ -18,7 +18,11 @@ label { margin-top: var(--space-sm); } -input, +// Excludes checkbox/radio — those get their own deliberate, fixed-size +// appearance from global.scss instead of stretching to the field width +// like a text/select input (this used to bleed onto them unscoped, which +// is why they used to render oversized and misaligned with their label). +input:not([type="checkbox"]):not([type="radio"]), select { width: 100%; padding: var(--space-sm); @@ -57,19 +61,15 @@ select { font-weight: 600; } + // The option row's own look (bordered "card", checked state, checkmark) + // is entirely global.scss's — this only overrides what doesn't fit a + // grid cell: the block/margin-top label rule above (this wraps an inline + // checkbox + text pair, not a field caption above an input) and the + // heavier default label weight (checked rows re-bold themselves via + // global.scss; unchecked ones should read as plain body text). &__option { - display: flex; - align-items: center; - gap: var(--space-xs); - // Overrides the block/margin-top label rule above — this label wraps - // an inline checkbox + text pair, not a field caption above an input. margin-top: 0; font-weight: 400; font-size: var(--font-size-base); - cursor: pointer; - - input[type="checkbox"] { - width: auto; - } } } diff --git a/apps/web/src/pages/settings/UserPreferencesPage.tsx b/apps/web/src/pages/settings/UserPreferencesPage.tsx index 5efb2a7..fe50380 100644 --- a/apps/web/src/pages/settings/UserPreferencesPage.tsx +++ b/apps/web/src/pages/settings/UserPreferencesPage.tsx @@ -43,18 +43,28 @@ export function UserPreferencesPage() {{t("common.saving")}
} diff --git a/apps/web/src/pages/settings/settings-pages.scss b/apps/web/src/pages/settings/settings-pages.scss index 9eebd4c..9717d4d 100644 --- a/apps/web/src/pages/settings/settings-pages.scss +++ b/apps/web/src/pages/settings/settings-pages.scss @@ -152,7 +152,11 @@ button.settings-page__link-button { // Theme choice (UserPreferencesPage) — a plain radio group, no fieldset/ // legend styling exists elsewhere yet to reuse (AllergySelect's `.allergy- -// select` in profile-forms.scss is checkbox-grid specific). +// select` in profile-forms.scss is checkbox-grid specific). The option +// rows' own look (bordered "card", checked state, checkmark) is entirely +// global.scss's — this only resets the fieldset chrome; the generic +// `label { margin-top }` rule (profile-forms.scss) already stacks the +// rows with breathing room between them. .theme-select { border: none; padding: 0; @@ -163,12 +167,4 @@ button.settings-page__link-button { font-weight: 600; font-size: var(--font-size-sm); } - - &__option { - display: flex; - align-items: center; - gap: var(--space-sm); - padding: var(--space-xs) 0; - cursor: pointer; - } } diff --git a/apps/web/src/styles/global.scss b/apps/web/src/styles/global.scss index efce8ca..18ada73 100644 --- a/apps/web/src/styles/global.scss +++ b/apps/web/src/styles/global.scss @@ -1,55 +1,148 @@ -// ============================================================================= -// Global stylesheet — imported exactly once, in main.tsx. Contains only -// truly app-wide rules: the theme tokens and a minimal reset/base styling -// that every page inherits. Anything specific to one component or page -// belongs in a .scss file colocated next to that component/page instead. -// ============================================================================= - -@use "./theme"; - -// Include borders/padding in an element's declared width/height everywhere, -// rather than the browser default of adding them on top. -*, -*::before, -*::after { - box-sizing: border-box; -} - -// Minimal reset: remove the default body margin so pages can control their -// own layout without fighting the browser's default 8px margin. -body { - margin: 0; - font-family: var(--font-body); - font-size: var(--font-size-base); - line-height: 1.55; - color: var(--color-text); - background: var(--color-background); -} - -// Headings use the condensed "label" face app-wide — see _theme.scss for -// the rationale. `text-wrap: balance` avoids a lone short word wrapping -// onto its own line in multi-line titles. -h1, -h2, -h3, -h4, -h5, -h6 { - margin: 0; - font-family: var(--font-display); - font-weight: 700; - text-wrap: balance; -} - -// Default to the page-title size; a heading used as a smaller component -// title (e.g. the auth card's