fix(settings): end the allergy and family-history cards in one action row

The allergy card had two action rows, the list's add button and the
free-text note's save, and the family-history card on a shared record
put its sentence about relatives after the list's actions. The add
button now rides the note's row before save, and the sentence moves
above the list.
This commit is contained in:
Marc-André Bombeck committed 2026-10-08 22:57:47 +02:00
1 parent 04084dd6e2
commit 7525d2ed00
6 files changed
+130 -31

No files matched your search

@@ -1,3 +1,4 @@
import type React from "react";
import { beforeEach, describe, expect, it, vi } from "vitest";
import { renderToStaticMarkup } from "react-dom/server";
import { readFileSync } from "node:fs";
@@ -38,10 +39,30 @@ vi.mock("@/components/records/health-profile-facts-manager", () => ({
HealthProfileFactsManager: () => null,
}));
vi.mock("@/components/records/allergy-manager", () => ({
AllergyManager: () => <div data-slot="allergy-manager-probe" />,
AllergyManager: ({
afterList,
}: {
afterList?: (add: React.ReactNode) => React.ReactNode;
}) => (
<div data-slot="allergy-manager-probe">
{afterList ? (
afterList(<button data-slot="allergy-add-probe" />)
) : (
<div data-slot="allergy-manager-own-actions" />
)}
</div>
),
}));
vi.mock("@/components/records/allergy-free-text-note", () => ({
AllergyFreeTextNote: () => <div data-slot="allergy-free-text-probe" />,
AllergyFreeTextNote: ({
leadingAction,
}: {
leadingAction?: React.ReactNode;
}) => (
<div data-slot="allergy-free-text-probe">
<div data-slot="settings-card-actions">{leadingAction}</div>
</div>
),
}));
vi.mock("@/components/records/about-me-note-manager", () => ({
AboutMeNoteManager: () => <div data-slot="about-me-note-probe" />,
@@ -88,6 +109,19 @@ describe("Anamnese — the About-me note card (#159)", () => {
expect(between).not.toContain("<h2");
});
it("ends the allergies card in one action row carrying the add action", () => {
// The list's add button rides the note's row (design standards §12):
// the manager renders no row of its own, and the note's row holds add.
const html = renderSection();
expect(html).not.toContain('data-slot="allergy-manager-own-actions"');
const note = html.slice(
html.indexOf('data-slot="allergy-free-text-probe"'),
);
expect(note).toMatch(
/data-slot="settings-card-actions"><button data-slot="allergy-add-probe"/,
);
});
it("keeps the same AI-surface gate as the inclusion card", () => {
moduleState.coach = false;
moduleState.insights = false;
@@ -0,0 +1,33 @@
/**
* A card's action row is its last element (design standards §12). The
* family-history card on a shared record carries a sentence about relatives;
* it sits above the list, whose manager closes with the card's actions.
*/
import { describe, expect, it, vi } from "vitest";
import { renderToStaticMarkup } from "react-dom/server";
vi.mock("@/components/records/allergy-manager", () => ({
AllergyManager: () => null,
}));
vi.mock("@/components/records/family-history-manager", () => ({
FamilyHistoryManager: () => (
<div data-slot="settings-card-actions">family-actions</div>
),
}));
import { I18nProvider } from "@/lib/i18n/context";
import { RecordAnamnesisSection } from "../record-anamnesis-section";
describe("<RecordAnamnesisSection> card order", () => {
it("puts the relatives sentence above the family list and its actions", () => {
const html = renderToStaticMarkup(
<I18nProvider initialLocale="en">
<RecordAnamnesisSection />
</I18nProvider>,
);
const note = html.indexOf('data-slot="record-anamnesis-relative-note"');
const actions = html.indexOf("family-actions");
expect(note).toBeGreaterThan(-1);
expect(actions).toBeGreaterThan(note);
});
});
@@ -111,11 +111,13 @@ export function AnamnesisSection() {
title={t("records.allergies.cardTitle")}
description={t("records.allergies.cardDescription")}
/>
<AllergyManager />
{/* #159 — the free-text supplement to the structured list above,
moved here from the account-settings "About me" panel so both
allergy inputs live in one card. */}
<AllergyFreeTextNote />
allergy inputs live in one card. The list's add button rides the
note's action row, so the card ends in one row. */}
<AllergyManager
afterList={(add) => <AllergyFreeTextNote leadingAction={add} />}
/>
</SettingsCard>
<SettingsCard>
@@ -36,8 +36,8 @@ import { useTranslations } from "@/lib/i18n/context";
* relatives, and often enough the delegate IS that relative, asserting a
* condition about themselves into somebody else's record. The route's own
* comment named that discomfort and left it for the surface to say out loud,
* because no route comment can. The sentence under the card is where it gets
* said.
* because no route comment can. The sentence at the top of the card body,
* above the list, is where it gets said.
*
* The cache is not a concern here and the reason is worth naming: switching
* records clears the whole query client, so the allergy and family-history
@@ -63,13 +63,15 @@ export function RecordAnamnesisSection() {
title={t("records.family.cardTitle")}
description={t("records.family.cardDescription")}
/>
<FamilyHistoryManager />
{/* Above the list: the manager closes with its action row, and
nothing follows a card's actions (design standards §12). */}
<p
data-slot="record-anamnesis-relative-note"
className="text-foreground text-sm"
>
{t("recordSharing.anamnesis.relativeNote")}
</p>
<FamilyHistoryManager />
</SettingsCard>
<p className="text-muted-foreground text-xs">{t("records.disclaimer")}</p>