diff --git a/src/components/order-sprint-process-modal.test.tsx b/src/components/order-sprint-process-modal.test.tsx index 8f1b497..4946a3e 100644 --- a/src/components/order-sprint-process-modal.test.tsx +++ b/src/components/order-sprint-process-modal.test.tsx @@ -307,6 +307,72 @@ describe("OrderSprintProcessModal", () => { ).toBeInTheDocument(); }); + it("shows the resolved supplier name on each Recent Orders row", async () => { + // The history fetch is the FIRST getList call (PB returns the + // most recent matching order_items). Seed it with a row whose + // supplier id maps to "Steel Co" in our suppliers list — the + // row should render that name so the operator can see who + // supplied it last time without expanding the PB relation. + getListMock.mockResolvedValueOnce({ + items: [{ + id: "hist-1", + description: "HSS drill bit", + sku: "DRL-001", + supplier: "sup-1", + cost_price: 20, + selling_price: 50, + markup: 150, + order: "order-prev", + updated: "2026-07-01", + expand: { order: { order_number: "ORD-PREV" } }, + }], + totalItems: 1, + totalPages: 1, + }); + // Subsequent fetches (price_list) stay empty. + getListMock.mockResolvedValue({ items: [], totalItems: 0, totalPages: 1 }); + + renderModal(); + await waitFor(() => { + expect(screen.getByText("Steel Co")).toBeInTheDocument(); + }); + // Order number + cost + selling still show alongside. + expect(screen.getByText("ORD-PREV")).toBeInTheDocument(); + expect(screen.getByText(/R20\.00/)).toBeInTheDocument(); + }); + + it("omits the supplier chip when the history row's supplier id is not in the suppliers list", async () => { + getListMock.mockResolvedValueOnce({ + items: [{ + id: "hist-1", + description: "HSS drill bit", + sku: "DRL-001", + supplier: "sup-deleted", + cost_price: 20, + selling_price: 50, + markup: 150, + order: "order-prev", + updated: "2026-07-01", + expand: { order: { order_number: "ORD-PREV" } }, + }], + totalItems: 1, + totalPages: 1, + }); + getListMock.mockResolvedValue({ items: [], totalItems: 0, totalPages: 1 }); + + renderModal(); + await waitFor(() => { + expect(screen.getByText("ORD-PREV")).toBeInTheDocument(); + }); + // The unknown supplier id should not be surfaced as a fallback + // — the chip is omitted entirely so the operator doesn't see a + // stale id. (Both "Steel Co" and "Bolt Suppliers" appear in the + // mocked SupplierSearch