mirror of
https://github.com/MBombeck/HealthLog.git
synced 2026-11-18 08:02:12 +00:00
Merge branch 'fix/v1437-r2-errors' into release/v1.43.7
# Conflicts: # src/components/charts/health-chart.tsx # src/components/insights/ecg-cross-link.tsx # src/components/insights/ecg-section.tsx # src/components/insights/rhythm-events-card.tsx
This commit is contained in:
commit
86eb743a69
134 files changed
+1567
-594
No files matched your search
@@ -58,6 +58,21 @@ describe("readFailureKind", () => {
|
||||
expect(readFailureKind(new TypeError("Failed to fetch"))).toBe("failed");
|
||||
expect(readFailureKind(null)).toBe("failed");
|
||||
});
|
||||
|
||||
it("reads the code before the status", () => {
|
||||
const withCode = (status: number, errorCode: string) =>
|
||||
readFailureKind(new ApiError("x", status, { errorCode }));
|
||||
// A step-up or re-proof gate answers 401 on a session that is still good:
|
||||
// sending that reader to sign-in would end it.
|
||||
expect(withCode(401, "auth.stepup.required")).toBe("failed");
|
||||
expect(withCode(401, "auth.reproof.required")).toBe("failed");
|
||||
expect(withCode(401, "auth.mfa.code_invalid")).toBe("failed");
|
||||
expect(withCode(401, "auth.token.expired")).toBe("unauthenticated");
|
||||
expect(withCode(401, "http.unauthenticated")).toBe("unauthenticated");
|
||||
// An unknown code falls back to the status.
|
||||
expect(withCode(401, "auth.something.new")).toBe("unauthenticated");
|
||||
expect(withCode(403, "http.forbidden")).toBe("refused");
|
||||
});
|
||||
});
|
||||
|
||||
describe.each([
|
||||
@@ -76,7 +91,7 @@ describe.each([
|
||||
|
||||
it("says a spent budget without offering a retry", () => {
|
||||
const html = render(new ApiError("Too many", 429));
|
||||
expect(html).toContain("Too many requests just now.");
|
||||
expect(html).toContain("There are too many requests just now");
|
||||
expect(html).not.toContain("retry");
|
||||
expect(html).not.toContain("Could not load");
|
||||
expect(html).not.toContain("Something on our side.");
|
||||
@@ -85,7 +100,7 @@ describe.each([
|
||||
it("offers sign-in for an ended session, never a blank", () => {
|
||||
const html = render(new ApiError("Unauthorized", 401));
|
||||
expect(html).not.toBe("");
|
||||
expect(html).toContain("Your session has ended.");
|
||||
expect(html).toContain("Your session has ended");
|
||||
expect(html).toContain('data-slot="query-error-sign-in"');
|
||||
expect(html).not.toContain("retry");
|
||||
});
|
||||
|
||||
@@ -53,10 +53,10 @@ export function QueryErrorCard({
|
||||
<Card data-slot="query-error-card" className={cn(className)}>
|
||||
<CardContent
|
||||
role="alert"
|
||||
className="flex flex-col items-center justify-center gap-3 px-6 py-10 text-center"
|
||||
className="flex flex-col items-center justify-center gap-3 py-10 text-center"
|
||||
>
|
||||
<AlertTriangle
|
||||
className="text-muted-foreground h-8 w-8"
|
||||
className="text-muted-foreground size-6"
|
||||
aria-hidden="true"
|
||||
/>
|
||||
<p className="text-sm font-medium">{failure.message}</p>
|
||||
@@ -74,7 +74,7 @@ export function QueryErrorCard({
|
||||
size="sm"
|
||||
onClick={action.onClick}
|
||||
>
|
||||
<RotateCw className="h-3.5 w-3.5" aria-hidden="true" />
|
||||
<RotateCw className="size-3.5" aria-hidden="true" />
|
||||
{retryLabel ?? action.label}
|
||||
</Button>
|
||||
) : action ? (
|
||||
|
||||
@@ -29,6 +29,9 @@ import { cn } from "@/lib/utils";
|
||||
*
|
||||
* The message renders in `text-foreground`: an alert IS the content of a
|
||||
* failed surface, and §3 reserves muted for meta.
|
||||
*
|
||||
* `inset` drops the row's own frame for a failure inside a card or tile body
|
||||
* that already draws one; a framed row there would be a card inside a card.
|
||||
*/
|
||||
export function QueryErrorRow({
|
||||
error,
|
||||
@@ -38,6 +41,7 @@ export function QueryErrorRow({
|
||||
retryLabel,
|
||||
slot,
|
||||
retrySlot,
|
||||
inset = false,
|
||||
className,
|
||||
}: {
|
||||
/** The query's error. It decides what the row offers. */
|
||||
@@ -56,6 +60,8 @@ export function QueryErrorRow({
|
||||
slot?: string;
|
||||
/** Same, for the Retry button's own `data-slot`. */
|
||||
retrySlot?: string;
|
||||
/** Inside a card or tile body: no frame of its own. */
|
||||
inset?: boolean;
|
||||
className?: string;
|
||||
}) {
|
||||
const failure = useReadFailure(error, { message, onRetry });
|
||||
@@ -66,7 +72,8 @@ export function QueryErrorRow({
|
||||
data-slot={slot ?? "query-error-row"}
|
||||
role="alert"
|
||||
className={cn(
|
||||
"bg-card border-border text-foreground flex flex-col items-start gap-3 rounded-xl border p-4 text-sm sm:flex-row sm:items-center sm:justify-between",
|
||||
"text-foreground flex flex-col items-start gap-3 text-sm sm:flex-row sm:items-center sm:justify-between",
|
||||
!inset && "bg-card border-border rounded-xl border p-4 md:p-6",
|
||||
className,
|
||||
)}
|
||||
>
|
||||
|
||||
Reference in new issue
Block a user