test(medications): type the container fixture so the overrides compile

`Partial<typeof item>` inferred the literal types off the base fixture, so an
override could not swap the container kind or null a date. The fixture takes
an explicit row shape instead.
This commit is contained in:
Marc-André Bombeck committed 2026-07-26 18:00:08 +02:00
1 parent d91b7cb57a
commit 5b38838594
1 file changed
+15 -5
@@ -95,13 +95,23 @@ function seedItems(items: unknown[]) {
});
}
interface Row {
id: string;
state: "ACTIVE" | "IN_USE" | "EXPIRED" | "USED_UP";
containerType: "PEN" | "AMPOULE" | "BLISTER" | "INHALER" | "BOTTLE" | "OTHER";
unitsTotal: number | null;
unitsRemaining: number | null;
printedExpiry: string | null;
firstUseAt: string | null;
}
const BASE = {
id: "i1",
state: "IN_USE" as const,
containerType: "BLISTER" as const,
state: "IN_USE",
containerType: "BLISTER",
unitsTotal: 60,
unitsRemaining: 54,
};
} satisfies Omit<Row, "printedExpiry" | "firstUseAt">;
describe("<InventorySection> — item-row dates", () => {
it("renders the opening date on the row", () => {
@@ -161,13 +171,13 @@ describe("<InventorySection> — item-row dates", () => {
});
describe("<AdjustInventoryDialog> — editable dates", () => {
const item = {
const item: Row = {
...BASE,
firstUseAt: "2026-06-12T00:00:00.000Z",
printedExpiry: "2027-06-01T00:00:00.000Z",
};
function renderDialog(over: Partial<typeof item> = {}): string {
function renderDialog(over: Partial<Row> = {}): string {
return render(
<AdjustInventoryDialog
medicationId="med-1"