mirror of
https://github.com/Sea-Haven-Industries/shoc-frontend-new.git
synced 2026-09-30 09:13:11 +00:00
fix(vendor-portal): align locked banner with comments-only actions
This commit is contained in:
parent
2ce7210668
commit
5d3fd1f986
2 changed files with 54 additions and 3 deletions
|
|
@ -149,9 +149,8 @@ export function DispatchSnapshotDetails({ data, locked }: DispatchSnapshotDetail
|
|||
<DispatcherContactDetails data={data} />
|
||||
{locked && (
|
||||
<Text variant="feedback" className="vp-muted" sx={{ marginTop: 2 }}>
|
||||
{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.
|
||||
</Text>
|
||||
)}
|
||||
{Boolean(description) && (
|
||||
|
|
|
|||
52
src/test/app/v/dispatch-snapshot-details.test.tsx
Normal file
52
src/test/app/v/dispatch-snapshot-details.test.tsx
Normal 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();
|
||||
});
|
||||
});
|
||||
Loading…
Add table
Reference in a new issue