mirror of
https://github.com/Sea-Haven-Industries/shoc-frontend-new.git
synced 2026-10-07 16:19:01 +00:00
fix(SH-357): reconcile Incomplete after clearing Schedule On
This commit is contained in:
parent
cbb2edf2a6
commit
d1b53105a2
5 changed files with 36 additions and 14 deletions
|
|
@ -181,8 +181,9 @@ test.describe("existing work order status menu", () => {
|
||||||
.click();
|
.click();
|
||||||
await page.getByRole("button", { name: "Continue" }).click();
|
await page.getByRole("button", { name: "Continue" }).click();
|
||||||
|
|
||||||
await page.getByRole("button", { name: "Incomplete", exact: true }).last().click();
|
await page.getByRole("button", { name: "Pending", exact: true }).last().click();
|
||||||
const menu = page.locator(".MuiPopover-paper").last();
|
const menu = page.locator(".MuiPopover-paper").last();
|
||||||
|
await expect(menu.getByRole("button", { name: "Incomplete", exact: true })).toBeDisabled();
|
||||||
await expect(menu.getByRole("button", { name: "Pending", exact: true })).toBeEnabled();
|
await expect(menu.getByRole("button", { name: "Pending", exact: true })).toBeEnabled();
|
||||||
await menu.getByRole("button", { name: "Pending", exact: true }).click();
|
await menu.getByRole("button", { name: "Pending", exact: true }).click();
|
||||||
await expect(
|
await expect(
|
||||||
|
|
@ -228,8 +229,9 @@ test.describe("existing work order status menu", () => {
|
||||||
.click();
|
.click();
|
||||||
await page.getByRole("button", { name: "Continue" }).click();
|
await page.getByRole("button", { name: "Continue" }).click();
|
||||||
|
|
||||||
await page.getByRole("button", { name: "Incomplete", exact: true }).last().click();
|
await page.getByRole("button", { name: "Pending", exact: true }).last().click();
|
||||||
const menu = page.locator(".MuiPopover-paper").last();
|
const menu = page.locator(".MuiPopover-paper").last();
|
||||||
|
await expect(menu.getByRole("button", { name: "Incomplete", exact: true })).toBeDisabled();
|
||||||
await menu.getByRole("button", { name: "Pending", exact: true }).click();
|
await menu.getByRole("button", { name: "Pending", exact: true }).click();
|
||||||
await expect(
|
await expect(
|
||||||
page.getByRole("dialog").getByRole("button", { name: "Pending", exact: true }),
|
page.getByRole("dialog").getByRole("button", { name: "Pending", exact: true }),
|
||||||
|
|
|
||||||
|
|
@ -162,7 +162,7 @@ export function maybeAutoSchedulePatch(
|
||||||
if (hasDate && isPreScheduleStatus(row.status ?? "")) {
|
if (hasDate && isPreScheduleStatus(row.status ?? "")) {
|
||||||
return { status: "Scheduled" };
|
return { status: "Scheduled" };
|
||||||
}
|
}
|
||||||
if (!hasDate && row.status === "Scheduled") {
|
if (!hasDate && (row.status === "Scheduled" || row.status === "Incomplete")) {
|
||||||
return { status: "Pending" };
|
return { status: "Pending" };
|
||||||
}
|
}
|
||||||
return {};
|
return {};
|
||||||
|
|
|
||||||
|
|
@ -134,7 +134,7 @@ describe("workOrdersApi.createFromBoard", () => {
|
||||||
expect(apiPost).toHaveBeenCalledWith(API_PATHS.workOrder.boardCreate, {
|
expect(apiPost).toHaveBeenCalledWith(API_PATHS.workOrder.boardCreate, {
|
||||||
workOrderType: 2,
|
workOrderType: 2,
|
||||||
siteCode: "BK5",
|
siteCode: "BK5",
|
||||||
lifecycleStatus: 1,
|
lifecycleStatus: 2,
|
||||||
woNumber: "12345",
|
woNumber: "12345",
|
||||||
isAddOn: false,
|
isAddOn: false,
|
||||||
locationId: 9,
|
locationId: 9,
|
||||||
|
|
|
||||||
|
|
@ -162,6 +162,7 @@ describe("mapWizardDraftToBoardCreatePayload", () => {
|
||||||
type: "PM",
|
type: "PM",
|
||||||
siteCode: "BK5",
|
siteCode: "BK5",
|
||||||
status: "Scheduled",
|
status: "Scheduled",
|
||||||
|
scheduledOn: "2026-06-01",
|
||||||
});
|
});
|
||||||
|
|
||||||
expect(payload.lifecycleStatus).toBe(3);
|
expect(payload.lifecycleStatus).toBe(3);
|
||||||
|
|
|
||||||
|
|
@ -6,6 +6,7 @@ import {
|
||||||
COMPLETED_DOC_BLOCK_MSG,
|
COMPLETED_DOC_BLOCK_MSG,
|
||||||
COMPLETED_MEDIA_BLOCK_MSG,
|
COMPLETED_MEDIA_BLOCK_MSG,
|
||||||
CREATION_INLINE_STATUSES,
|
CREATION_INLINE_STATUSES,
|
||||||
|
INCOMPLETE_NEEDS_DATE_MSG,
|
||||||
PENDING_NEEDS_NO_DATE_MSG,
|
PENDING_NEEDS_NO_DATE_MSG,
|
||||||
SCHEDULED_NEEDS_DATE_MSG,
|
SCHEDULED_NEEDS_DATE_MSG,
|
||||||
formatAapCompletedBlockTitle,
|
formatAapCompletedBlockTitle,
|
||||||
|
|
@ -59,7 +60,17 @@ describe("wo-lifecycle-transitions", () => {
|
||||||
expect(hasConcreteScheduleDate({ scheduledOn: "2026-06-01" })).toBe(true);
|
expect(hasConcreteScheduleDate({ scheduledOn: "2026-06-01" })).toBe(true);
|
||||||
});
|
});
|
||||||
|
|
||||||
it("disables Scheduled without a concrete date", () => {
|
it("disables Incomplete and Scheduled without a concrete date", () => {
|
||||||
|
expect(getStatusOptionState({ scheduledOn: "" }, "Incomplete", [])).toEqual({
|
||||||
|
disabled: true,
|
||||||
|
title: INCOMPLETE_NEEDS_DATE_MSG,
|
||||||
|
});
|
||||||
|
expect(
|
||||||
|
getStatusOptionState({ scheduledOn: "2026-06-01", scheduleWeekOnly: true }, "Incomplete", []),
|
||||||
|
).toEqual({ disabled: true, title: INCOMPLETE_NEEDS_DATE_MSG });
|
||||||
|
expect(getStatusOptionState({ scheduledOn: "2026-06-01" }, "Incomplete", [])).toEqual({
|
||||||
|
disabled: false,
|
||||||
|
});
|
||||||
expect(getStatusOptionState({ scheduledOn: "" }, "Scheduled", [])).toEqual({
|
expect(getStatusOptionState({ scheduledOn: "" }, "Scheduled", [])).toEqual({
|
||||||
disabled: true,
|
disabled: true,
|
||||||
title: SCHEDULED_NEEDS_DATE_MSG,
|
title: SCHEDULED_NEEDS_DATE_MSG,
|
||||||
|
|
@ -102,14 +113,15 @@ describe("wo-lifecycle-transitions", () => {
|
||||||
).toEqual({ status: "Scheduled" });
|
).toEqual({ status: "Scheduled" });
|
||||||
});
|
});
|
||||||
|
|
||||||
it("reverts Scheduled without a concrete date to Pending", () => {
|
it("reverts Scheduled or Incomplete without a concrete date to Pending", () => {
|
||||||
expect(
|
for (const status of ["Scheduled", "Incomplete"]) {
|
||||||
maybeAutoSchedulePatch({
|
expect(maybeAutoSchedulePatch({ status, scheduledOn: "", scheduleWeekOnly: false })).toEqual({
|
||||||
status: "Scheduled",
|
status: "Pending",
|
||||||
scheduledOn: "",
|
});
|
||||||
scheduleWeekOnly: false,
|
expect(
|
||||||
}),
|
maybeAutoSchedulePatch({ status, scheduledOn: "2026-06-01", scheduleWeekOnly: true }),
|
||||||
).toEqual({ status: "Pending" });
|
).toEqual({ status: "Pending" });
|
||||||
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
it("does not auto-change In Progress when a date exists", () => {
|
it("does not auto-change In Progress when a date exists", () => {
|
||||||
|
|
@ -180,7 +192,7 @@ describe("wo-lifecycle-transitions", () => {
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
it("still demotes Scheduled when the schedule is cleared", () => {
|
it("demotes Scheduled or Incomplete when the schedule is cleared", () => {
|
||||||
const row = {
|
const row = {
|
||||||
status: "Scheduled",
|
status: "Scheduled",
|
||||||
scheduledOn: "2026-06-01",
|
scheduledOn: "2026-06-01",
|
||||||
|
|
@ -191,6 +203,13 @@ describe("wo-lifecycle-transitions", () => {
|
||||||
scheduleWeekOnly: false,
|
scheduleWeekOnly: false,
|
||||||
status: "Pending",
|
status: "Pending",
|
||||||
});
|
});
|
||||||
|
expect(withAutoScheduleStatus({ ...row, status: "Incomplete" }, { scheduledOn: "" })).toEqual({
|
||||||
|
scheduledOn: "",
|
||||||
|
status: "Pending",
|
||||||
|
});
|
||||||
|
expect(
|
||||||
|
withAutoScheduleStatus({ ...row, status: "Incomplete" }, { scheduleWeekOnly: true }),
|
||||||
|
).toEqual({ scheduleWeekOnly: true, status: "Pending" });
|
||||||
});
|
});
|
||||||
|
|
||||||
it("promotes a Pending create pick to Scheduled when the draft is dated", () => {
|
it("promotes a Pending create pick to Scheduled when the draft is dated", () => {
|
||||||
|
|
|
||||||
Loading…
Add table
Reference in a new issue