6ee87174d3
The live-tail stream (now reachable through the new Vite /api proxy) started delivering activity rows with kind="manual_match", a kind the ActivityFeed kindConfig map didn't know about. The map lookup returned undefined, and reading .icon on it threw — taking the whole Activity Log page down. Two fixes: 1. Add "manual_match" to the ActivityKind union in src/types/index.ts and to the kindConfig map in src/components/ActivityFeed.tsx (with a Wrench icon + neutral tone), so the kind is properly typed and rendered. 2. Add a FALLBACK_KIND guard so any future backend-emitted kind that arrives before the frontend is updated no longer crashes the page. kindConfig stays exhaustive for known kinds, so TypeScript still catches missing entries at compile time. Also adds src/components/ActivityFeed.test.tsx with three regression tests (empty state, multi-item render, unknown-kind safety).
51 lines
1.7 KiB
TypeScript
51 lines
1.7 KiB
TypeScript
// @vitest-environment happy-dom
|
|
(globalThis as { IS_REACT_ACT_ENVIRONMENT?: boolean }).IS_REACT_ACT_ENVIRONMENT = true;
|
|
|
|
import { describe, expect, it } from "vitest";
|
|
import { render, screen } from "@testing-library/react";
|
|
import { ActivityFeed } from "./ActivityFeed";
|
|
import type { Activity } from "@/types";
|
|
|
|
const baseActivity: Activity = {
|
|
id: "a-1",
|
|
kind: "claim_submitted",
|
|
message: "Claim ABC-1 submitted",
|
|
timestamp: "2026-06-20T12:00:00Z",
|
|
};
|
|
|
|
describe("ActivityFeed", () => {
|
|
it("renders the empty-state copy when items is empty", () => {
|
|
render(<ActivityFeed items={[]} />);
|
|
expect(screen.getByText("No activity yet.")).toBeTruthy();
|
|
});
|
|
|
|
it("renders each item's message", () => {
|
|
render(
|
|
<ActivityFeed
|
|
items={[
|
|
baseActivity,
|
|
{ ...baseActivity, id: "a-2", message: "Remit XYZ received" },
|
|
]}
|
|
/>,
|
|
);
|
|
expect(screen.getByText("Claim ABC-1 submitted")).toBeTruthy();
|
|
expect(screen.getByText("Remit XYZ received")).toBeTruthy();
|
|
});
|
|
|
|
it("does not crash on an unknown kind", () => {
|
|
// Backwards-compat guard: the backend may emit a kind the frontend
|
|
// hasn't been updated for yet (manual_match was the original case).
|
|
// The feed must fall back to a neutral icon instead of throwing.
|
|
const unknown = {
|
|
...baseActivity,
|
|
id: "a-3",
|
|
message: "future_kind event arrived",
|
|
// Cast through `unknown` so the type-checker doesn't widen the
|
|
// `kind` literal away from the exhaustive union.
|
|
kind: "future_kind" as Activity["kind"],
|
|
};
|
|
expect(() => render(<ActivityFeed items={[unknown]} />)).not.toThrow();
|
|
expect(screen.getByText("future_kind event arrived")).toBeTruthy();
|
|
});
|
|
});
|