// @vitest-environment happy-dom import { describe, expect, it, vi } from "vitest"; import { render, screen, fireEvent } from "@testing-library/react"; import { InboxRow } from "./InboxRow"; import type { InboxClaimRow, InboxCandidateRow } from "@/lib/inbox-api"; const baseClaim: InboxClaimRow = { id: "CLP-7741", kind: "claim", patient_control_number: "PCN-001", charge_amount: 1240, payer_id: "CO-MCD", provider_npi: "1234567890", state: "rejected", rejection_reason: "999 AK9 R", rejected_at: "2026-06-20T09:12:00Z", service_date_from: null, score: null, score_tier: null, score_breakdown: null, }; describe("InboxRow", () => { it("renders the claim id, payer, and formatted charge", () => { const { container } = render(
".
expect(container.textContent).toContain("991102989·A");
expect(container.textContent).toContain("991102989·R");
expect(container.textContent).toContain("991102989·E");
// Overflow "+1 more" — total=4 but only 3 chips fit.
expect(container.textContent).toContain("+1 more");
// Resubmit button rendered with the per-row testid.
const btn = screen.getByTestId("resubmit-REJ1") as HTMLButtonElement;
expect(btn).toBeTruthy();
expect(btn.textContent).toBe("Resubmit");
// Click fires the per-row handler with the claim id; click does
// NOT bubble to onClick (the row-onClick is for drilldown, the
// button is a separate download gesture).
fireEvent.click(btn);
expect(onResubmitOne).toHaveBeenCalledTimes(1);
expect(onResubmitOne).toHaveBeenCalledWith("REJ1");
});
it("SP29: rejected row with no linked 999 acks shows the '999 not linked' orphan marker", () => {
// A rejected claim whose 999 ack didn't match any ST02 in the
// batch — the operator needs to know the drill lacked ack
// evidence. The "999 not linked" italic line is the marker.
const rejectedRow: InboxClaimRow = {
...baseClaim,
id: "REJ-ORPH",
claim_acks: {
total: 0,
rejected: 0,
items: [],
},
};
const onResubmitOne = vi.fn();
const { container } = render(
{}}
onResubmitOne={onResubmitOne}
/>
,
);
expect(container.textContent).toContain("999 not linked");
// The Resubmit button still renders so the operator can fix the
// claim without first manually linking the orphan.
expect(screen.getByTestId("resubmit-REJ-ORPH")).toBeTruthy();
});
});