Files
vitareba/lib/domain/programmes.test.ts
GandClaude Opus 5 3e059f0818 chore: add a formatter (#83)
* chore: add a formatter, matching the style this repo already writes

singleQuote=false was chosen by counting this repo's own
imports, not by fleet decree. The fleet is genuinely split and the two repos
that already had a .prettierrc disagreed with each other, so there was no
standard to restore. Quote style does not cross repo boundaries; having a
gate does.

Markdown is ignored for now — prettier rewraps prose, which would bury the
real diff.

Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>

* style: format with prettier (304 files)

Mechanical. No behaviour change. This SHA is listed in
.git-blame-ignore-revs so `git blame` skips it.

Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>

* chore: teach git blame to skip the reformat

Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>

* style: format the two files the reformat pass missed

prettier --check flagged app/shared.module.css and lib/domain/clinicians.test.ts
on a branch whose whole point was that everything had been formatted. Re-running
the same command with the same version fixes both, so the rollout's write step
did not finish what it reported.

The rollout now runs --check straight after --write and refuses to open a PR
unless it comes back clean, so a partial reformat fails at the source instead of
in CI.

---------

Co-authored-by: Claude Opus 5 <noreply@anthropic.com>
2026-08-29 10:48:01 +00:00

96 lines
3.0 KiB
TypeScript

/// <reference types="vitest/globals" />
import { programmeUpdateSchema } from "./programmes";
import { PROGRAMME_ENUM_VALUES, PHASE_ENUM_VALUES } from "@/lib/config/programmes";
import { PATIENT_NOTE_MAX_LENGTH, PROGRAMME_START_DATE_MAX_LENGTH } from "@/lib/config/portal";
describe("programmeUpdateSchema", () => {
it("accepts a minimal valid update (required fields only)", () => {
const result = programmeUpdateSchema.safeParse({
programme: PROGRAMME_ENUM_VALUES[0],
phase: PHASE_ENUM_VALUES[0],
});
expect(result.success).toBe(true);
});
it("accepts a fully populated update", () => {
const result = programmeUpdateSchema.safeParse({
programme: "riding_the_wave",
phase: "active",
startDate: "2026-01-15",
notes: "Patient is progressing well.",
});
expect(result.success).toBe(true);
});
it("accepts null startDate and notes", () => {
const result = programmeUpdateSchema.safeParse({
programme: "edge_diagnostic",
phase: "intake",
startDate: null,
notes: null,
});
expect(result.success).toBe(true);
});
it("rejects an invalid programme key", () => {
const result = programmeUpdateSchema.safeParse({
programme: "basic_therapy",
phase: "active",
});
expect(result.success).toBe(false);
});
it("rejects an invalid phase key", () => {
const result = programmeUpdateSchema.safeParse({
programme: "riding_the_wave",
phase: "maintenance",
});
expect(result.success).toBe(false);
});
it("rejects missing programme", () => {
const result = programmeUpdateSchema.safeParse({ phase: "active" });
expect(result.success).toBe(false);
});
it("rejects missing phase", () => {
const result = programmeUpdateSchema.safeParse({ programme: "riding_the_wave" });
expect(result.success).toBe(false);
});
it(`rejects startDate longer than ${PROGRAMME_START_DATE_MAX_LENGTH} chars`, () => {
const result = programmeUpdateSchema.safeParse({
programme: "riding_the_wave",
phase: "active",
startDate: "x".repeat(PROGRAMME_START_DATE_MAX_LENGTH + 1),
});
expect(result.success).toBe(false);
});
it(`rejects notes longer than ${PATIENT_NOTE_MAX_LENGTH} chars`, () => {
const result = programmeUpdateSchema.safeParse({
programme: "riding_the_wave",
phase: "active",
notes: "n".repeat(PATIENT_NOTE_MAX_LENGTH + 1),
});
expect(result.success).toBe(false);
});
it("accepts all PROGRAMME_ENUM_VALUES", () => {
for (const programme of PROGRAMME_ENUM_VALUES) {
const result = programmeUpdateSchema.safeParse({ programme, phase: PHASE_ENUM_VALUES[0] });
expect(result.success).toBe(true);
}
});
it("accepts all PHASE_ENUM_VALUES", () => {
for (const phase of PHASE_ENUM_VALUES) {
const result = programmeUpdateSchema.safeParse({
programme: PROGRAMME_ENUM_VALUES[0],
phase,
});
expect(result.success).toBe(true);
}
});
});