Merge pull request #115 from Sea-Haven-Industries/fix/vendor-portal-locked-banner-copy
Some checks are pending
CI / ci (push) Waiting to run
CI / governance (push) Waiting to run
CI / vendor-visual-regression (push) Waiting to run
Deploy / deploy (push) Waiting to run

fix(vendor-portal): accurate locked banner copy by dispatch status
This commit is contained in:
Alexandre Brandizzi 2026-08-12 12:29:31 -03:00 • committed by GitHub
commit 4e189e903f
No known key found for this signature in database
GPG key ID: B5690EEEBB952194

View file

@ -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> = {},
): 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(<DispatchSnapshotDetails data={buildData({ status })} locked />, {
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(
<DispatchSnapshotDetails data={buildData({ status: "In Progress" })} locked={false} />,
{ withAuth: false },
);
expect(screen.queryByText(/locked to further changes/i)).not.toBeInTheDocument();
});
});