— non-diagnostic framing", () => {
expect(html).toContain("as reported by the recording device");
});
- it("says a failed read failed instead of painting an empty recording", () => {
+ it("shows a recoverable read failure instead of painting an empty recording", () => {
useQueryMock.mockReturnValue({
data: undefined,
isLoading: false,
isError: true,
+ refetch: vi.fn(),
});
const html = renderToStaticMarkup(
,
);
- expect(html).toContain('data-slot="ecg-detail-error"');
+ // The failure is a recoverable card, not a muted "no data" line.
+ expect(html).toContain('data-slot="query-error-card"');
+ expect(html).toContain('data-slot="query-error-retry"');
expect(html).not.toContain('data-slot="ecg-trace"');
});
});
diff --git a/src/components/insights/ecg-detail.tsx b/src/components/insights/ecg-detail.tsx
index 8c2f5fc11..c60c2abee 100644
--- a/src/components/insights/ecg-detail.tsx
+++ b/src/components/insights/ecg-detail.tsx
@@ -7,6 +7,7 @@ import { apiGet } from "@/lib/api/api-fetch";
import { useTranslations, useFormatters } from "@/lib/i18n/context";
import { EcgWaveform } from "@/components/insights/ecg-waveform";
import { InsightSectionCard } from "@/components/insights/insight-section-card";
+import { QueryErrorCard } from "@/components/ui/query-error-card";
import {
ecgResultLabel,
isNonNormalEcg,
@@ -41,7 +42,7 @@ export function EcgDetail({ recordingId }: { recordingId: string }) {
const { t } = useTranslations();
const fmt = useFormatters();
- const { data, isLoading, isError } = useQuery({
+ const { data, isLoading, isError, refetch } = useQuery({
queryKey: queryKeys.insightsEcgDetail(recordingId, false),
queryFn: async () => {
try {
@@ -55,15 +56,13 @@ export function EcgDetail({ recordingId }: { recordingId: string }) {
});
if (isError) {
- // A failed read must never read as "no data" (UI-STANDARDS §6).
+ // A failed read must never read as "no data" (UI-STANDARDS §6), and the
+ // alert is content, not muted meta — it also has to be recoverable.
return (
-
- {t("insights.ecg.loadError")}
-
+ refetch()}
+ />
);
}