From 173c3e1d9c15596743afa66b6ce461e888b2ba90 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Marc-Andr=C3=A9=20Bombeck?= Date: Sun, 10 May 2026 01:39:58 +0200 Subject: [PATCH] test(insights): rec-card-confidence test plays nice with B5e thumbs MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit After B5e wired the feedback thumbs into rec-card-feedback-slot, the B5d test needs the same useAuth + useMutation + tanstack-query SSR mocks that the existing rec-card.test.tsx carries. The test that asserted "rec-feedback-slot is empty" is relaxed to "rec-feedback-slot is still rendered" — B5e legitimately fills it now, and the slot's mere presence is what B5d needs to guarantee its plug-in point stayed intact. Co-Authored-By: Claude Opus 4.7 (1M context) --- .../recommendation-card-confidence.test.tsx | 33 ++++++++++++++++--- 1 file changed, 29 insertions(+), 4 deletions(-) diff --git a/src/components/insights/__tests__/recommendation-card-confidence.test.tsx b/src/components/insights/__tests__/recommendation-card-confidence.test.tsx index ad27d0ae0..8c16dd7f3 100644 --- a/src/components/insights/__tests__/recommendation-card-confidence.test.tsx +++ b/src/components/insights/__tests__/recommendation-card-confidence.test.tsx @@ -11,6 +11,29 @@ vi.mock("@/components/charts/mood-chart", () => ({ MoodChart: () =>
, })); +// B5e wired RecommendationFeedback into the rec card; that component +// pulls in useAuth + useMutation from tanstack-query, both of which +// need stubbing for SSR rendering in tests. +vi.mock("@tanstack/react-query", () => ({ + useQuery: () => ({ data: null, isLoading: false }), + useMutation: () => ({ + mutate: vi.fn(), + isPending: false, + isSuccess: false, + isError: false, + error: null, + }), + useQueryClient: () => ({ invalidateQueries: vi.fn() }), +})); + +vi.mock("@/hooks/use-auth", () => ({ + useAuth: () => ({ + user: { id: "test-user", username: "tester", role: "USER" }, + isAuthenticated: true, + isLoading: false, + }), +})); + /** * v1.4.16 phase B5d — confidence meter wiring inside * ``. @@ -126,7 +149,7 @@ describe(" — confidence slot wiring", () => { expect(html).toMatch(/Geringes Vertrauen/); }); - it("does NOT touch rec-feedback-slot (owned by B5e)", () => { + it("rec-feedback-slot is still rendered (B5e plug-in point intact)", () => { const html = render( — confidence slot wiring", () => { initiallyExpanded />, ); - // The feedback slot is still present, but B5d must not have - // injected anything into it. - expect(html).toMatch(/data-slot="rec-feedback-slot"[^>]*>\s*<\/div>/); + // The feedback slot itself is present so B5e (or future phases) + // can plug in. We don't assert anything about its contents + // because B5e fills it with the thumbs component on its own + // surface. + expect(html).toMatch(/data-slot="rec-feedback-slot"/); }); });