mirror of
https://github.com/Sea-Haven-Industries/shoc-frontend-new.git
synced 2026-10-07 08:09:00 +00:00
fix(uplifts): align approval journey test (SH-207)
This commit is contained in:
parent
0d95a32071
commit
6b84db18ca
1 changed files with 61 additions and 44 deletions
105
e2e/vendors/vendor-uplift-workflow.spec.ts
vendored
105
e2e/vendors/vendor-uplift-workflow.spec.ts
vendored
|
|
@ -268,7 +268,7 @@ test("vendor revises a changes-requested uplift using its existing evidence", as
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
test("internal approver can approve and request changes with audited notes", async ({ page }) => {
|
test("internal approver can approve, reject, and revoke with audited notes", async ({ page }) => {
|
||||||
const decisions: Array<{ path: string; body: unknown }> = [];
|
const decisions: Array<{ path: string; body: unknown }> = [];
|
||||||
const statuses = new Map<number, string>([
|
const statuses = new Map<number, string>([
|
||||||
[41, "Pending"],
|
[41, "Pending"],
|
||||||
|
|
@ -284,73 +284,90 @@ test("internal approver can approve and request changes with audited notes", asy
|
||||||
await page.route(/\/api\/uplifts(?:[/?]|$)/, async (route) => {
|
await page.route(/\/api\/uplifts(?:[/?]|$)/, async (route) => {
|
||||||
const request = route.request();
|
const request = route.request();
|
||||||
const path = new URL(request.url()).pathname;
|
const path = new URL(request.url()).pathname;
|
||||||
const action = path.match(/\/uplifts\/(41|42)\/(approve|request-changes)$/);
|
const action = path.match(/\/uplifts\/(41|42)\/(approve|reject|revoke)$/);
|
||||||
if (action && request.method() === "POST") {
|
if (action && request.method() === "POST") {
|
||||||
const id = Number(action[1]);
|
const id = Number(action[1]);
|
||||||
statuses.set(id, action[2] === "approve" ? "Approved" : "ChangesRequested");
|
statuses.set(
|
||||||
|
id,
|
||||||
|
action[2] === "approve" ? "Approved" : action[2] === "revoke" ? "Revoked" : "Rejected",
|
||||||
|
);
|
||||||
decisions.push({ path, body: request.postDataJSON() });
|
decisions.push({ path, body: request.postDataJSON() });
|
||||||
await fulfillJson(route, { id, status: statuses.get(id) });
|
await fulfillJson(route, { id, status: statuses.get(id) });
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
const requestedStatus = new URL(request.url()).searchParams.get("status");
|
||||||
|
const items = [
|
||||||
|
{
|
||||||
|
id: 41,
|
||||||
|
dispatchId: 7,
|
||||||
|
workOrderId: 501,
|
||||||
|
dispatchNumber: "DSP-41",
|
||||||
|
poNumber: "PO-41",
|
||||||
|
vendorCompanyName: "Gateway Plumbing",
|
||||||
|
currentNTE: 100,
|
||||||
|
requestedNTE: 125,
|
||||||
|
delta: 25,
|
||||||
|
requiredTier: 1,
|
||||||
|
status: statuses.get(41),
|
||||||
|
canDecide: true,
|
||||||
|
evidenceDocumentId: 22,
|
||||||
|
evidenceFileName: "estimate.pdf",
|
||||||
|
evidenceContentType: "application/pdf",
|
||||||
|
evidenceSizeBytes: 2048,
|
||||||
|
},
|
||||||
|
{
|
||||||
|
id: 42,
|
||||||
|
dispatchId: 8,
|
||||||
|
workOrderId: 502,
|
||||||
|
dispatchNumber: "DSP-42",
|
||||||
|
poNumber: "PO-42",
|
||||||
|
vendorCompanyName: "Metro HVAC",
|
||||||
|
currentNTE: 200,
|
||||||
|
requestedNTE: 260,
|
||||||
|
delta: 60,
|
||||||
|
requiredTier: 2,
|
||||||
|
status: statuses.get(42),
|
||||||
|
canDecide: true,
|
||||||
|
evidenceDocumentId: 23,
|
||||||
|
evidenceFileName: "quote.pdf",
|
||||||
|
},
|
||||||
|
].filter((item) => requestedStatus == null || item.status === requestedStatus);
|
||||||
|
|
||||||
await fulfillJson(route, {
|
await fulfillJson(route, {
|
||||||
total: 2,
|
total: items.length,
|
||||||
items: [
|
items,
|
||||||
{
|
|
||||||
id: 41,
|
|
||||||
dispatchId: 7,
|
|
||||||
dispatchNumber: "DSP-41",
|
|
||||||
poNumber: "PO-41",
|
|
||||||
vendorCompanyName: "Gateway Plumbing",
|
|
||||||
currentNTE: 100,
|
|
||||||
requestedNTE: 125,
|
|
||||||
delta: 25,
|
|
||||||
requiredTier: 1,
|
|
||||||
status: statuses.get(41),
|
|
||||||
canDecide: true,
|
|
||||||
evidenceDocumentId: 22,
|
|
||||||
evidenceFileName: "estimate.pdf",
|
|
||||||
evidenceContentType: "application/pdf",
|
|
||||||
evidenceSizeBytes: 2048,
|
|
||||||
},
|
|
||||||
{
|
|
||||||
id: 42,
|
|
||||||
dispatchId: 8,
|
|
||||||
dispatchNumber: "DSP-42",
|
|
||||||
poNumber: "PO-42",
|
|
||||||
vendorCompanyName: "Metro HVAC",
|
|
||||||
currentNTE: 200,
|
|
||||||
requestedNTE: 260,
|
|
||||||
delta: 60,
|
|
||||||
requiredTier: 2,
|
|
||||||
status: statuses.get(42),
|
|
||||||
canDecide: true,
|
|
||||||
evidenceDocumentId: 23,
|
|
||||||
evidenceFileName: "quote.pdf",
|
|
||||||
},
|
|
||||||
],
|
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
await page.goto("/uplifts");
|
await page.goto("/uplifts");
|
||||||
await expect(page.getByRole("heading", { name: "Uplift Queue" })).toBeVisible();
|
await expect(page.getByRole("heading", { name: "Uplift Approvals" })).toBeVisible();
|
||||||
|
|
||||||
const approvalRow = page.getByRole("row").filter({ hasText: "DSP-41" });
|
const approvalRow = page.getByRole("row").filter({ hasText: "DSP-41" });
|
||||||
await approvalRow.getByRole("button", { name: "Approve" }).click();
|
await approvalRow.getByRole("button", { name: "Approve" }).click();
|
||||||
await page.getByRole("button", { name: "Confirm" }).click();
|
|
||||||
|
|
||||||
const changesRow = page.getByRole("row").filter({ hasText: "DSP-42" });
|
const changesRow = page.getByRole("row").filter({ hasText: "DSP-42" });
|
||||||
await changesRow.getByRole("button", { name: "Request Changes" }).click();
|
await changesRow.getByRole("button", { name: "Reject" }).click();
|
||||||
await page.getByLabel("Note (required)").fill("Please itemize labor and parts.");
|
await page.getByLabel("Reason for rejection").fill("Please itemize labor and parts.");
|
||||||
await page.getByRole("button", { name: "Confirm" }).click();
|
await page.getByRole("button", { name: "Reject uplift" }).click();
|
||||||
|
|
||||||
|
await page.getByRole("tab", { name: "Approved" }).click();
|
||||||
|
const approvedRow = page.getByRole("row").filter({ hasText: "DSP-41" });
|
||||||
|
await approvedRow.getByRole("button", { name: "Revoke" }).click();
|
||||||
|
await page.getByLabel("Reason for revoking").fill("Approval was made in error.");
|
||||||
|
await page.getByRole("button", { name: "Revoke $125" }).click();
|
||||||
|
|
||||||
await expect
|
await expect
|
||||||
.poll(() => decisions)
|
.poll(() => decisions)
|
||||||
.toEqual([
|
.toEqual([
|
||||||
{ path: "/api/uplifts/41/approve", body: {} },
|
{ path: "/api/uplifts/41/approve", body: {} },
|
||||||
{
|
{
|
||||||
path: "/api/uplifts/42/request-changes",
|
path: "/api/uplifts/42/reject",
|
||||||
body: { note: "Please itemize labor and parts." },
|
body: { note: "Please itemize labor and parts." },
|
||||||
},
|
},
|
||||||
|
{
|
||||||
|
path: "/api/uplifts/41/revoke",
|
||||||
|
body: { reason: "Approval was made in error." },
|
||||||
|
},
|
||||||
]);
|
]);
|
||||||
});
|
});
|
||||||
|
|
|
||||||
Loading…
Add table
Reference in a new issue