mirror of
https://github.com/Sea-Haven-Industries/shoc-frontend-new.git
synced 2026-10-07 16:19:01 +00:00
test(vendors): cover work order assignment flow
This commit is contained in:
parent
8ecf9e0cfb
commit
0f261d6c16
2 changed files with 86 additions and 7 deletions
83
e2e/vendors/vendor-operations.spec.ts
vendored
83
e2e/vendors/vendor-operations.spec.ts
vendored
|
|
@ -187,4 +187,87 @@ test.describe("Vendor operations", () => {
|
|||
{ vendorId: 7, trade: "Plumbing", sortOrder: 1 },
|
||||
]);
|
||||
});
|
||||
|
||||
test("creates a work order and assigns the selected technician with ETA", async ({ page }) => {
|
||||
await authenticate(page);
|
||||
let assignment: unknown;
|
||||
|
||||
await page.route("**/api/Contact/GetLocations", (route) =>
|
||||
fulfillJson(route, { data: [{ Id: 10, Name: "St. Louis HQ" }] }),
|
||||
);
|
||||
await page.route("**/api/Employee/Dropdown", (route) => fulfillJson(route, { data: [] }));
|
||||
await page.route("**/api/DropdownOptions/ByCategory/**", (route) =>
|
||||
fulfillJson(route, { data: [] }),
|
||||
);
|
||||
await page.route("**/api/vendor-operations/availability*", (route) =>
|
||||
fulfillJson(route, {
|
||||
data: [
|
||||
{
|
||||
id: 7,
|
||||
companyName: "Gateway Plumbing",
|
||||
contactName: "Taylor Tech",
|
||||
availabilityStatus: "Available",
|
||||
isPreferred: true,
|
||||
conflicts: [],
|
||||
},
|
||||
],
|
||||
}),
|
||||
);
|
||||
await page.route("**/api/WorkOrder/AddWorkorder", (route) =>
|
||||
fulfillJson(route, {
|
||||
data: {
|
||||
Id: 900,
|
||||
WorkerOrderTitle: "Boiler repair",
|
||||
LocationId: 10,
|
||||
Priority: "Sev 1",
|
||||
Status: "Open",
|
||||
Comments: [],
|
||||
AuditLog: [],
|
||||
Dispatches: [],
|
||||
},
|
||||
}),
|
||||
);
|
||||
await page.route("**/api/vendor-operations/work-orders/900/assignment", async (route) => {
|
||||
assignment = route.request().postDataJSON();
|
||||
await fulfillJson(route, {});
|
||||
});
|
||||
await page.route("**/api/WorkOrder/GetWorkorderById*", (route) =>
|
||||
fulfillJson(route, {
|
||||
data: {
|
||||
Id: 900,
|
||||
WorkerOrderTitle: "Boiler repair",
|
||||
LocationId: 10,
|
||||
Priority: "Sev 1",
|
||||
Status: "Open",
|
||||
Comments: [],
|
||||
AuditLog: [],
|
||||
Dispatches: [],
|
||||
},
|
||||
}),
|
||||
);
|
||||
|
||||
await page.goto("/workorders/new");
|
||||
await page.getByLabel("Title").fill("Boiler repair");
|
||||
await page.getByLabel("Location").click();
|
||||
await page.getByRole("option", { name: "St. Louis HQ" }).click();
|
||||
await page.getByLabel("Priority").click();
|
||||
await page.getByRole("option", { name: "Sev 1" }).click();
|
||||
await page.getByLabel("Scheduled").fill("2026-07-25");
|
||||
await page.getByLabel("Company + Technician").click();
|
||||
await page.getByRole("option", { name: /Gateway Plumbing · Taylor Tech/ }).click();
|
||||
await page.getByLabel("Assignment ETA").fill("2026-07-25T08:30");
|
||||
await page.getByLabel("Manual ETA override").check();
|
||||
await page.getByRole("button", { name: "Create" }).click();
|
||||
|
||||
await expect
|
||||
.poll(() => assignment)
|
||||
.toEqual({
|
||||
vendorId: 7,
|
||||
scheduledStart: "2026-07-25T12:00:00.000Z",
|
||||
scheduledEnd: "2026-07-25T14:00:00.000Z",
|
||||
estimatedArrivalAt: "2026-07-25T11:30:00.000Z",
|
||||
etaManualOverride: true,
|
||||
});
|
||||
await expect(page).toHaveURL(/\/workorders\/900$/);
|
||||
});
|
||||
});
|
||||
|
|
|
|||
|
|
@ -116,8 +116,8 @@ export default function WorkOrderFormPage() {
|
|||
const isSaving = saveMutation.isPending;
|
||||
const isLoading = isEdit && isLoadingDetail;
|
||||
|
||||
const onSubmit = async (values: WorkOrderFormSchemaValues) => {
|
||||
await saveMutation.mutateAsync({
|
||||
const onSubmit = (values: WorkOrderFormSchemaValues) => {
|
||||
saveMutation.mutate({
|
||||
workOrderId: isEdit ? id : undefined,
|
||||
values,
|
||||
vendorAssignment:
|
||||
|
|
@ -179,11 +179,7 @@ export default function WorkOrderFormPage() {
|
|||
{isEdit ? `Edit Work Order ${detail?.internalWONumber ?? id}` : "Create a Work Order"}
|
||||
</Typography>
|
||||
<Paper variant="outlined" className="p-6">
|
||||
<Box
|
||||
component="form"
|
||||
onSubmit={handleSubmit((values) => void onSubmit(values))}
|
||||
className="flex flex-col gap-8"
|
||||
>
|
||||
<Box component="form" onSubmit={handleSubmit(onSubmit)} className="flex flex-col gap-8">
|
||||
<Box>
|
||||
<SectionTitle>Work Order Details</SectionTitle>
|
||||
<Stack direction={{ xs: "column", md: "row" }} spacing={2}>
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue