diff --git a/src/app/(protected)/workorders/_components/detail/work-order-slide-over-tabs.tsx b/src/app/(protected)/workorders/_components/detail/work-order-slide-over-tabs.tsx index 4a7dfd3f..9522168c 100644 --- a/src/app/(protected)/workorders/_components/detail/work-order-slide-over-tabs.tsx +++ b/src/app/(protected)/workorders/_components/detail/work-order-slide-over-tabs.tsx @@ -20,28 +20,23 @@ type SlideOverState = ReturnType; function SlideOverUpliftsPanel({ tab, - editing, infoSource, - activeDraft, upliftCreatePending, onUpliftCreatePendingChange, }: { tab: SlideOverTab; - editing: boolean; infoSource: WorkOrderTableRow | null | undefined; - activeDraft: WorkOrderTableRow | null | undefined; upliftCreatePending: boolean; onUpliftCreatePendingChange?: (pending: boolean) => void; }) { const visible = tab === "uplifts"; if (infoSource == null || (!visible && !upliftCreatePending)) return null; - const source = editing && activeDraft != null ? activeDraft : infoSource; return ( @@ -174,9 +169,7 @@ export function WorkOrderSlideOverTabs({ diff --git a/src/test/app/(protected)/workorders/slide-over-uplifts-draft.test.tsx b/src/test/app/(protected)/workorders/slide-over-uplifts-draft.test.tsx index a1dfb20e..a288257a 100644 --- a/src/test/app/(protected)/workorders/slide-over-uplifts-draft.test.tsx +++ b/src/test/app/(protected)/workorders/slide-over-uplifts-draft.test.tsx @@ -142,10 +142,11 @@ function renderUplifts(state: SlideOverState) { } describe("WorkOrderSlideOverTabs Uplifts draft", () => { - it("uses the unsaved Info type for the auto-approval allowance", () => { + it("keeps the saved work order type for the allowance while Info is unsaved", () => { renderUplifts(upliftsState(true, { type: "PM" }, { type: "Emergency" })); - expect(screen.getByText(/\$5,000 left to auto-approve/i)).toBeInTheDocument(); + expect(screen.getByText(/\$500 left to auto-approve/i)).toBeInTheDocument(); + expect(screen.queryByText(/\$5,000 left to auto-approve/i)).not.toBeInTheDocument(); }); it("keeps the persisted allowance when the slide-over is not editing", () => { @@ -155,11 +156,11 @@ describe("WorkOrderSlideOverTabs Uplifts draft", () => { expect(screen.queryByText(/\$5,000 left to auto-approve/i)).not.toBeInTheDocument(); }); - it("closes uplift requests from an unsaved completed status", () => { + it("keeps uplift requests open when only the unsaved Info status is completed", () => { renderUplifts(upliftsState(true, { status: "Scheduled" }, { status: "Completed" })); - expect(screen.getByText(/uplifts can no longer be requested/i)).toBeInTheDocument(); - expect(screen.queryByRole("button", { name: /request uplift/i })).not.toBeInTheDocument(); + expect(screen.queryByText(/uplifts can no longer be requested/i)).not.toBeInTheDocument(); + expect(screen.getByRole("button", { name: /request uplift/i })).toBeInTheDocument(); }); it("keeps the request form when a completed status exists only on an inactive draft", () => {