diff --git a/src/components/buyer-tasks/buyer-task-group-card.test.tsx b/src/components/buyer-tasks/buyer-task-group-card.test.tsx index 126981b..c3b3bc3 100644 --- a/src/components/buyer-tasks/buyer-task-group-card.test.tsx +++ b/src/components/buyer-tasks/buyer-task-group-card.test.tsx @@ -18,6 +18,7 @@ const baseGroup = { purchaseOrderId: null, poStatus: null, poNumber: null, + emailError: null, supplierEmail: null, step: "needs_po" as const, }; @@ -63,6 +64,46 @@ describe("BuyerTaskGroupCard", () => { expect(screen.getByText("HSS drill")).toBeInTheDocument(); }); + it("renders the email_error banner and 'Resend' button when poStatus is mail_failed", () => { + render( + , + ); + expect(screen.getByText(/mail failed/i)).toBeInTheDocument(); + expect(screen.getByText(/webhook returned http 502/i)).toBeInTheDocument(); + // Button label changes to "Resend" when the underlying PO is mail_failed. + const action = screen.getByTestId(`buyer-task-action-${baseGroup.groupId}-po_draft`); + expect(action).toHaveTextContent(/resend/i); + }); + + it("keeps the original 'Send PO' label and amber class when poStatus is draft", () => { + render( + , + ); + const action = screen.getByTestId(`buyer-task-action-${baseGroup.groupId}-po_draft`); + expect(action).toHaveTextContent(/send po/i); + // Amber class is the pre-existing po_draft class. + expect(action.className).toMatch(/amber/i); + // No failure banner on a clean draft. + expect(screen.queryByText(/mail failed/i)).toBeNull(); + }); + it("shows the PO number prominently at the top when one exists", () => { render( onAction(group)} disabled={disabled} - className={ACTION_CLASS[group.step]} + className={cn( + ACTION_CLASS[group.step], + group.poStatus === "mail_failed" && + "bg-destructive hover:bg-destructive/90 text-destructive-foreground", + )} data-testid={`buyer-task-action-${group.groupId}-${group.step}`} + data-po-status={group.poStatus ?? "none"} > - {ACTION_LABEL[group.step]} + {group.poStatus === "mail_failed" ? "Resend" : ACTION_LABEL[group.step]} + {group.poStatus === "mail_failed" && group.emailError && ( +
+
+ )}