mirror of
https://github.com/Sea-Haven-Industries/shoc-frontend-new.git
synced 2026-09-30 05:43:12 +00:00
test: cover pending schedule date promotion
This commit is contained in:
parent
a61ab1919a
commit
4771f6f8eb
1 changed files with 54 additions and 3 deletions
|
|
@ -78,13 +78,17 @@ async function mockApi(
|
|||
return;
|
||||
}
|
||||
if (pathname === "/api/workorders/board" && request.method() === "POST") {
|
||||
createPayloads.push(request.postDataJSON());
|
||||
const payload = request.postDataJSON() as {
|
||||
lifecycleStatus: number;
|
||||
scheduledDate?: string;
|
||||
};
|
||||
createPayloads.push(payload);
|
||||
createdRow = {
|
||||
...BOARD_ROW,
|
||||
id: 900,
|
||||
woNumber: "WO-900",
|
||||
lifecycleStatusLabel: "Pending",
|
||||
scheduledDate: "",
|
||||
lifecycleStatusLabel: payload.lifecycleStatus === 3 ? "Scheduled" : "Pending",
|
||||
scheduledDate: payload.scheduledDate ?? "",
|
||||
rowVersion: "rv-created",
|
||||
};
|
||||
await fulfillJson(route, { data: { id: 900, internalWONumber: "WO-900" } });
|
||||
|
|
@ -205,4 +209,51 @@ test.describe("existing work order status menu", () => {
|
|||
await expect(createdRow.getByText("WO-900")).toBeVisible();
|
||||
await expect(createdRow.getByRole("button", { name: "Pending" })).toBeVisible();
|
||||
});
|
||||
|
||||
test("Admin gets Scheduled when adding Schedule On after selecting Pending", async ({ page }) => {
|
||||
const createPayloads: unknown[] = [];
|
||||
await mockApi(page, "Admin", createPayloads);
|
||||
await page.goto("/workorders");
|
||||
await expect(page.getByRole("heading", { name: "Work Orders" })).toBeVisible({
|
||||
timeout: 20_000,
|
||||
});
|
||||
await page.getByRole("button", { name: "New WO" }).click();
|
||||
await expect(page.getByRole("heading", { name: "Type & schedule" })).toBeVisible();
|
||||
await page.getByRole("button", { name: "Continue" }).click();
|
||||
|
||||
await page.getByRole("button", { name: /select site/i }).click();
|
||||
await page
|
||||
.getByRole("button", { name: /STL-01/ })
|
||||
.last()
|
||||
.click();
|
||||
await page.getByRole("button", { name: "Continue" }).click();
|
||||
|
||||
await page.getByRole("button", { name: "Incomplete", exact: true }).last().click();
|
||||
const menu = page.locator(".MuiPopover-paper").last();
|
||||
await menu.getByRole("button", { name: "Pending", exact: true }).click();
|
||||
await expect(
|
||||
page.getByRole("dialog").getByRole("button", { name: "Pending", exact: true }),
|
||||
).toBeVisible();
|
||||
|
||||
await page.getByRole("button", { name: "Back" }).click();
|
||||
await page.getByRole("button", { name: "Back" }).click();
|
||||
await page.getByRole("button", { name: "Pick a date" }).click();
|
||||
const dateTab = page.getByRole("button", { name: "Date", exact: true });
|
||||
if (await dateTab.isVisible()) {
|
||||
await dateTab.click();
|
||||
}
|
||||
await page.getByRole("button", { name: "20", exact: true }).click();
|
||||
await expect(page.getByRole("button", { name: /Aug 20/ })).toBeVisible();
|
||||
await page.getByRole("button", { name: "Continue" }).click();
|
||||
await page.getByRole("button", { name: "Continue" }).click();
|
||||
|
||||
await expect(
|
||||
page.getByRole("dialog").getByRole("button", { name: "Scheduled", exact: true }),
|
||||
).toBeVisible();
|
||||
await page.getByRole("button", { name: "Create work order" }).click();
|
||||
await expect(page.getByRole("heading", { name: "Type & schedule" })).toBeHidden();
|
||||
await expect
|
||||
.poll(() => createPayloads)
|
||||
.toEqual([expect.objectContaining({ lifecycleStatus: 3, scheduledDate: "2026-08-20" })]);
|
||||
});
|
||||
});
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue