mirror of
https://github.com/Sea-Haven-Industries/shoc-frontend-new.git
synced 2026-10-06 18:12:05 +00:00
test: find pending creation in unscheduled results
This commit is contained in:
parent
52b682283c
commit
a61ab1919a
1 changed files with 26 additions and 3 deletions
|
|
@ -23,7 +23,12 @@ async function fulfillJson(route: Route, body: unknown) {
|
||||||
await route.fulfill({ status: 200, contentType: "application/json", body: JSON.stringify(body) });
|
await route.fulfill({ status: 200, contentType: "application/json", body: JSON.stringify(body) });
|
||||||
}
|
}
|
||||||
|
|
||||||
async function mockApi(page: Page, role: Role, createPayloads: unknown[] = []) {
|
async function mockApi(
|
||||||
|
page: Page,
|
||||||
|
role: Role,
|
||||||
|
createPayloads: unknown[] = [],
|
||||||
|
searchUrls: string[] = [],
|
||||||
|
) {
|
||||||
await page.clock.install({ time: new Date(FROZEN_NOW) });
|
await page.clock.install({ time: new Date(FROZEN_NOW) });
|
||||||
await page.clock.resume();
|
await page.clock.resume();
|
||||||
await page.addInitScript(
|
await page.addInitScript(
|
||||||
|
|
@ -53,7 +58,13 @@ async function mockApi(page: Page, role: Role, createPayloads: unknown[] = []) {
|
||||||
const { pathname } = new URL(request.url());
|
const { pathname } = new URL(request.url());
|
||||||
|
|
||||||
if (pathname.includes("/workorders/board/search")) {
|
if (pathname.includes("/workorders/board/search")) {
|
||||||
await fulfillJson(route, { items: [], totalCount: 0, page: 0, pageSize: 50 });
|
searchUrls.push(request.url());
|
||||||
|
await fulfillJson(route, {
|
||||||
|
items: createdRow ? [createdRow] : [],
|
||||||
|
totalCount: createdRow ? 1 : 0,
|
||||||
|
page: 0,
|
||||||
|
pageSize: 50,
|
||||||
|
});
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
if (pathname === "/api/workorders/board" && request.method() === "GET") {
|
if (pathname === "/api/workorders/board" && request.method() === "GET") {
|
||||||
|
|
@ -148,7 +159,8 @@ test.describe("existing work order status menu", () => {
|
||||||
page,
|
page,
|
||||||
}) => {
|
}) => {
|
||||||
const createPayloads: unknown[] = [];
|
const createPayloads: unknown[] = [];
|
||||||
await mockApi(page, "Admin", createPayloads);
|
const searchUrls: string[] = [];
|
||||||
|
await mockApi(page, "Admin", createPayloads, searchUrls);
|
||||||
await page.goto("/workorders");
|
await page.goto("/workorders");
|
||||||
await expect(page.getByRole("heading", { name: "Work Orders" })).toBeVisible({
|
await expect(page.getByRole("heading", { name: "Work Orders" })).toBeVisible({
|
||||||
timeout: 20_000,
|
timeout: 20_000,
|
||||||
|
|
@ -178,6 +190,17 @@ test.describe("existing work order status menu", () => {
|
||||||
await expect
|
await expect
|
||||||
.poll(() => createPayloads)
|
.poll(() => createPayloads)
|
||||||
.toEqual([expect.objectContaining({ lifecycleStatus: 2 })]);
|
.toEqual([expect.objectContaining({ lifecycleStatus: 2 })]);
|
||||||
|
|
||||||
|
const filtersSheet = page.getByRole("dialog", { name: "Advanced Filters" });
|
||||||
|
await page.getByRole("button", { name: "Advanced Filters" }).click();
|
||||||
|
await expect(filtersSheet).toBeVisible();
|
||||||
|
await filtersSheet.getByRole("button", { name: "Date range" }).click();
|
||||||
|
await filtersSheet.getByRole("button", { name: "Unscheduled", exact: true }).click();
|
||||||
|
await filtersSheet.getByRole("button", { name: "Apply filters" }).click();
|
||||||
|
|
||||||
|
await expect
|
||||||
|
.poll(() => searchUrls.some((url) => url.includes("unscheduledOnly=true")))
|
||||||
|
.toBe(true);
|
||||||
const createdRow = page.locator("#wo-row-900");
|
const createdRow = page.locator("#wo-row-900");
|
||||||
await expect(createdRow.getByText("WO-900")).toBeVisible();
|
await expect(createdRow.getByText("WO-900")).toBeVisible();
|
||||||
await expect(createdRow.getByRole("button", { name: "Pending" })).toBeVisible();
|
await expect(createdRow.getByRole("button", { name: "Pending" })).toBeVisible();
|
||||||
|
|
|
||||||
Loading…
Add table
Reference in a new issue