From 5886fea8d7371ef341a8b239abd580a0976610c6 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Marc-Andr=C3=A9=20Bombeck?= Date: Fri, 15 May 2026 17:00:13 +0200 Subject: [PATCH] fix(tests): repair hero-strip and telegram-test-locale assertions after R3a MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 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. --- .../__tests__/telegram-test-locale.test.ts | 14 ++++---- .../insights/__tests__/hero-strip.test.tsx | 32 ++++--------------- 2 files changed, 14 insertions(+), 32 deletions(-) diff --git a/src/app/api/settings/__tests__/telegram-test-locale.test.ts b/src/app/api/settings/__tests__/telegram-test-locale.test.ts index 304dd3834..70be88e51 100644 --- a/src/app/api/settings/__tests__/telegram-test-locale.test.ts +++ b/src/app/api/settings/__tests__/telegram-test-locale.test.ts @@ -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)(); 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)(); 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)(); 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)(); 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)(); 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)(); 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)(); expect((result as { status: number }).status).toBe(422); }); diff --git a/src/components/insights/__tests__/hero-strip.test.tsx b/src/components/insights/__tests__/hero-strip.test.tsx index 3dcbbb327..e6d3a7ea5 100644 --- a/src/components/insights/__tests__/hero-strip.test.tsx +++ b/src/components/insights/__tests__/hero-strip.test.tsx @@ -306,7 +306,12 @@ describe("", () => { 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( ", () => { 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( - , - ); 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)", () => {