diff --git a/src/app/v/[token]/dispatch/_components/dispatch-snapshot-details.tsx b/src/app/v/[token]/dispatch/_components/dispatch-snapshot-details.tsx index 3c128caa..4f71d6d8 100644 --- a/src/app/v/[token]/dispatch/_components/dispatch-snapshot-details.tsx +++ b/src/app/v/[token]/dispatch/_components/dispatch-snapshot-details.tsx @@ -149,9 +149,8 @@ export function DispatchSnapshotDetails({ data, locked }: DispatchSnapshotDetail {locked && ( - {data.status === "Refused" - ? "This dispatch is refused and locked to further changes. Comments remain open." - : `This dispatch is ${data.status.toLowerCase()} and locked to further status changes. Sign-off actions may still be available.`} + This dispatch is {data.status.toLowerCase()} and locked to further changes. Comments + remain open. )} {Boolean(description) && ( diff --git a/src/test/app/v/dispatch-snapshot-details.test.tsx b/src/test/app/v/dispatch-snapshot-details.test.tsx new file mode 100644 index 00000000..66f31610 --- /dev/null +++ b/src/test/app/v/dispatch-snapshot-details.test.tsx @@ -0,0 +1,52 @@ +import { screen } from "@testing-library/react"; +import { describe, expect, it } from "vitest"; +import { DispatchSnapshotDetails } from "@/app/v/[token]/dispatch/_components/dispatch-snapshot-details"; +import type { VendorPortalDispatchDetail } from "@/domain/vendor-portal/types/vendor-portal"; +import { renderWithProviders } from "@/test/test-utils"; + +function buildData( + overrides: Partial = {}, +): VendorPortalDispatchDetail { + return { + id: 9, + dispatchNumber: "DSP-9", + status: "Verified", + nteAmount: 500, + checklist: [], + comments: [], + upliftRequests: [], + signoffs: [], + documents: [], + ...overrides, + }; +} + +describe("DispatchSnapshotDetails locked banner", () => { + it.each(["Verified", "Cancelled", "Refused"])( + "states that comments remain open when status is %s", + (status) => { + renderWithProviders(, { + withAuth: false, + }); + + expect( + screen.getByText( + new RegExp( + `This dispatch is ${status.toLowerCase()} and locked to further changes\\. Comments remain open\\.`, + "i", + ), + ), + ).toBeInTheDocument(); + expect(screen.queryByText(/sign-off/i)).not.toBeInTheDocument(); + }, + ); + + it("hides the locked banner when the dispatch is not locked", () => { + renderWithProviders( + , + { withAuth: false }, + ); + + expect(screen.queryByText(/locked to further changes/i)).not.toBeInTheDocument(); + }); +});