mirror of
https://github.com/MBombeck/HealthLog.git
synced 2026-11-17 07:42:23 +00:00
release: v1.32.0 — hardening and scalability (#580)
* release: prepare v1.32.0 * test: stabilize water capture re-entry
This commit is contained in:
1 parent
b01822be48
commit
62eb431d66
372 files changed
+25178
-8561
No files matched your search
@@ -16,6 +16,27 @@ import { renderToStaticMarkup } from "react-dom/server";
|
||||
|
||||
import { I18nProvider } from "@/lib/i18n/context";
|
||||
|
||||
const moduleGate = vi.hoisted(() => ({ nutrientsEnabled: true }));
|
||||
|
||||
vi.mock("@/hooks/use-module-enabled", () => ({
|
||||
useModuleEnabled: (moduleKey: string) =>
|
||||
moduleKey === "nutrients" ? moduleGate.nutrientsEnabled : true,
|
||||
}));
|
||||
|
||||
vi.mock("@/components/ui/dropdown-menu", () => ({
|
||||
DropdownMenu: ({ children }: { children: React.ReactNode }) => (
|
||||
<>{children}</>
|
||||
),
|
||||
DropdownMenuContent: ({ children }: { children: React.ReactNode }) => (
|
||||
<div>{children}</div>
|
||||
),
|
||||
DropdownMenuItem: ({ children }: { children: React.ReactNode }) => (
|
||||
<div>{children}</div>
|
||||
),
|
||||
DropdownMenuTrigger: ({ children }: { children: React.ReactNode }) => (
|
||||
<>{children}</>
|
||||
),
|
||||
}));
|
||||
vi.mock("@/hooks/use-auth", () => ({
|
||||
useAuth: () => ({
|
||||
user: { username: "tester", timezone: "Europe/Berlin" },
|
||||
@@ -55,3 +76,30 @@ describe("<DashboardHeader> — greeting", () => {
|
||||
expect(html).toMatch(/<h1[^>]*>Dashboard<\/h1>/);
|
||||
});
|
||||
});
|
||||
|
||||
describe("<DashboardHeader> — nutrients module gate", () => {
|
||||
it("hides only the water quick-add item when nutrients are disabled", () => {
|
||||
moduleGate.nutrientsEnabled = false;
|
||||
|
||||
const html = renderSSR(
|
||||
<DashboardHeader onQuickEntry={() => undefined} />,
|
||||
"en",
|
||||
);
|
||||
|
||||
expect(html).not.toContain("Log water");
|
||||
expect(html).toContain("Log measurement");
|
||||
expect(html).toContain("Log mood");
|
||||
expect(html).toContain("Log medication intake");
|
||||
});
|
||||
|
||||
it("keeps the water quick-add item available when nutrients are enabled", () => {
|
||||
moduleGate.nutrientsEnabled = true;
|
||||
|
||||
const html = renderSSR(
|
||||
<DashboardHeader onQuickEntry={() => undefined} />,
|
||||
"en",
|
||||
);
|
||||
|
||||
expect(html).toContain("Log water");
|
||||
});
|
||||
});
|
||||
@@ -50,9 +50,9 @@ vi.mock("@/hooks/use-auth", () => ({
|
||||
|
||||
import {
|
||||
MedicationIntakeQuickAdd,
|
||||
pickDefaultMedicationId,
|
||||
type MedicationOption,
|
||||
} from "../medication-intake-quick-add";
|
||||
import { pickDefaultMedicationId } from "@/lib/medications/default-medication";
|
||||
|
||||
function makeMed(
|
||||
id: string,
|
||||
@@ -273,6 +273,41 @@ describe("<MedicationIntakeQuickAdd> — SSR contract", () => {
|
||||
).toBeGreaterThanOrEqual(1);
|
||||
});
|
||||
|
||||
it("renders the current-window medication as selected ahead of array order", () => {
|
||||
vi.useFakeTimers();
|
||||
vi.setSystemTime(new Date("2026-05-12T08:00:00.000Z"));
|
||||
mockUseQuery.mockReturnValue({
|
||||
data: [
|
||||
makeMed("first", { name: "Alpha" }),
|
||||
makeMed("due", {
|
||||
name: "Zulu",
|
||||
nextDueAt: "2026-05-12T07:00:00.000Z",
|
||||
nextDueOverdue: false,
|
||||
schedules: [
|
||||
{
|
||||
id: "due-schedule",
|
||||
windowStart: "08:00",
|
||||
windowEnd: "11:00",
|
||||
daysOfWeek: null,
|
||||
label: null,
|
||||
dose: null,
|
||||
},
|
||||
],
|
||||
}),
|
||||
],
|
||||
isLoading: false,
|
||||
});
|
||||
|
||||
try {
|
||||
const html = renderSSR(<MedicationIntakeQuickAdd />);
|
||||
expect(html).toMatch(
|
||||
/data-slot="select-value"[^>]*>[\s\S]*?Zulu[\s\S]*?<\/span>/,
|
||||
);
|
||||
} finally {
|
||||
vi.useRealTimers();
|
||||
}
|
||||
});
|
||||
|
||||
it("does not leak raw i18n keys in either locale", () => {
|
||||
mockUseQuery.mockReturnValue({ data: [], isLoading: false });
|
||||
const en = renderSSR(<MedicationIntakeQuickAdd />, "en");
|
||||
|
||||
Reference in new issue
Block a user