mirror of
https://github.com/MBombeck/HealthLog.git
synced 2026-11-09 13:01:00 +00:00
fix(tests): repair hero-strip and telegram-test-locale assertions after R3a
Two test-contract fixes for fallout from concurrent R3a contributors: - hero-strip.test.tsx — collapses the two onAskCoach forwarding tests into a single regression guard that asserts the inline Health Score card Ask-the-Coach button stays retired and the hero strip's action-row button carries the affordance. - telegram-test-locale.test.ts — the route's POST handler takes zero arguments (apiHandler wraps an async () => function). Drops the Request argument from all seven call sites.
This commit is contained in:
1 parent
f3ff262451
commit
5886fea8d7
2 files changed
+14
-32
No files matched your search
@@ -102,7 +102,7 @@ describe("POST /api/settings/telegram/test — locale-aware message", () => {
|
||||
locale: "de",
|
||||
} as never);
|
||||
|
||||
const result = await POST(new Request("http://x") as never);
|
||||
const result = await (POST as () => Promise<unknown>)();
|
||||
|
||||
expect(sendTelegramMessageMock).toHaveBeenCalledTimes(1);
|
||||
const [, , body] = sendTelegramMessageMock.mock.calls[0];
|
||||
@@ -125,7 +125,7 @@ describe("POST /api/settings/telegram/test — locale-aware message", () => {
|
||||
locale: "fr",
|
||||
} as never);
|
||||
|
||||
await POST(new Request("http://x") as never);
|
||||
await (POST as () => Promise<unknown>)();
|
||||
|
||||
const [, , body] = sendTelegramMessageMock.mock.calls[0];
|
||||
expect(body).toBe(
|
||||
@@ -140,7 +140,7 @@ describe("POST /api/settings/telegram/test — locale-aware message", () => {
|
||||
locale: null,
|
||||
} as never);
|
||||
|
||||
await POST(new Request("http://x") as never);
|
||||
await (POST as () => Promise<unknown>)();
|
||||
|
||||
const [, , body] = sendTelegramMessageMock.mock.calls[0];
|
||||
expect(body).toBe(
|
||||
@@ -156,7 +156,7 @@ describe("POST /api/settings/telegram/test — locale-aware message", () => {
|
||||
locale: "klingon",
|
||||
} as never);
|
||||
|
||||
await POST(new Request("http://x") as never);
|
||||
await (POST as () => Promise<unknown>)();
|
||||
|
||||
expect(tCalls[0].locale).toBe("en");
|
||||
});
|
||||
@@ -168,7 +168,7 @@ describe("POST /api/settings/telegram/test — locale-aware message", () => {
|
||||
locale: "de",
|
||||
} as never);
|
||||
|
||||
const result = await POST(new Request("http://x") as never);
|
||||
const result = await (POST as () => Promise<unknown>)();
|
||||
|
||||
expect(sendTelegramMessageMock).not.toHaveBeenCalled();
|
||||
expect((result as { status: number }).status).toBe(422);
|
||||
@@ -181,7 +181,7 @@ describe("POST /api/settings/telegram/test — locale-aware message", () => {
|
||||
resetAt: Date.now() + 60_000,
|
||||
} as never);
|
||||
|
||||
const result = await POST(new Request("http://x") as never);
|
||||
const result = await (POST as () => Promise<unknown>)();
|
||||
|
||||
expect(sendTelegramMessageMock).not.toHaveBeenCalled();
|
||||
expect((result as { status: number }).status).toBe(429);
|
||||
@@ -195,7 +195,7 @@ describe("POST /api/settings/telegram/test — locale-aware message", () => {
|
||||
} as never);
|
||||
sendTelegramMessageMock.mockResolvedValueOnce({ ok: false });
|
||||
|
||||
const result = await POST(new Request("http://x") as never);
|
||||
const result = await (POST as () => Promise<unknown>)();
|
||||
|
||||
expect((result as { status: number }).status).toBe(422);
|
||||
});
|
||||
|
||||
@@ -306,7 +306,12 @@ describe("<HeroStrip>", () => {
|
||||
expect(html).toContain(">86<");
|
||||
});
|
||||
|
||||
it("forwards onAskCoach into the Health Score panel only when both are supplied", () => {
|
||||
it("does not render an inline Ask-the-Coach button inside the Health Score card", () => {
|
||||
// v1.4.27 F8 — the inline HSC Ask-the-Coach button retired in
|
||||
// favour of the hero strip's existing action-row button. Even
|
||||
// when `onAskCoach` is supplied, the HSC panel must not surface
|
||||
// its own button. The action-row button at
|
||||
// `insights-hero-strip-action-coach` carries the affordance.
|
||||
const html = render(
|
||||
<HeroStrip
|
||||
briefing={null}
|
||||
@@ -325,31 +330,8 @@ describe("<HeroStrip>", () => {
|
||||
onAskCoach={() => {}}
|
||||
/>,
|
||||
);
|
||||
// HSC panel renders its own Ask-the-Coach button with the score-
|
||||
// aware label (the action-row button uses the shorter "Ask the
|
||||
// coach" copy). The HSC button mirrors the panel's slot.
|
||||
expect(html).toMatch(/data-slot="health-score-card-ask-coach"/);
|
||||
});
|
||||
|
||||
it("hides the Health Score panel's Ask button when no onAskCoach is supplied", () => {
|
||||
const html = render(
|
||||
<HeroStrip
|
||||
briefing={null}
|
||||
now={morningLocal}
|
||||
healthScore={{
|
||||
score: 86,
|
||||
band: "green",
|
||||
components: {
|
||||
bp: { value: 80, weight: 0.3 },
|
||||
weight: { value: 70, weight: 0.2 },
|
||||
mood: { value: 90, weight: 0.2 },
|
||||
compliance: { value: 100, weight: 0.3 },
|
||||
},
|
||||
delta: 5,
|
||||
}}
|
||||
/>,
|
||||
);
|
||||
expect(html).not.toContain('data-slot="health-score-card-ask-coach"');
|
||||
expect(html).toContain('data-slot="insights-hero-strip-action-coach"');
|
||||
});
|
||||
|
||||
it("uses the lg row layout when healthScore is supplied (smoke test on container class)", () => {
|
||||
|
||||
Reference in new issue
Block a user