mega-plant/lib/clock-access.test.ts
David 1ec52961ee Cash float card, Office role + Slips tab, job card PDF, manual close/delete
- Cash Floats: ledger card (opening balance, top-ups, slips), manual entries, slip photos
- Office access level; clock app Slips tab (photograph a slip, popup for supplier/cost
  code/comments/amount); only Office sees it; per-role route table in lib/clock-access
- Job cards: Machine Service PDF (with Oil block), JC numbers, manual Close job, Delete
- Hide Expenses > Vehicle Costs and Finance (Bastion) from the menu

Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
2026-10-22 15:09:57 +02:00

31 lines
1.8 KiB
TypeScript

import test from "node:test";
import assert from "node:assert/strict";
import { clockHome, clockPathAllowed } from "./clock-access";
test("mechanics reach Fuel and Job cards but not the clock-in scanner or slips", () => {
assert.equal(clockPathAllowed("mechanic", "/clock/job-cards"), true);
assert.equal(clockPathAllowed("mechanic", "/api/clock/oil-out"), true);
assert.equal(clockPathAllowed("mechanic", "/clock"), false);
assert.equal(clockPathAllowed("mechanic", "/api/clock/scan"), false);
assert.equal(clockPathAllowed("mechanic", "/clock/slips"), false);
});
test("office reaches only slips and the cash float", () => {
assert.equal(clockPathAllowed("office", "/clock/slips"), true);
assert.equal(clockPathAllowed("office", "/api/clock/slip"), true);
assert.equal(clockPathAllowed("office", "/api/clock/cash-float/opening"), true);
for (const p of ["/clock", "/clock/stock", "/clock/job-cards", "/api/clock/scan", "/api/clock/stock-out"]) assert.equal(clockPathAllowed("office", p), false, p);
});
test("only office reaches the slip scanner; full and clock-in users do not", () => {
assert.equal(clockPathAllowed("clock", "/clock/stock"), true);
assert.equal(clockPathAllowed("clock", "/clock/slips"), false);
assert.equal(clockPathAllowed("full", "/clock/slips"), false);
assert.equal(clockPathAllowed("full", "/api/clock/slip"), false);
assert.equal(clockPathAllowed("full", "/api/clock/cash-float/opening"), true);
assert.equal(clockPathAllowed("full", "/clock/job-cards"), true);
assert.equal(clockPathAllowed("office", "/clock/change-password"), true);
});
test("each role lands on its own home", () => {
assert.equal(clockHome("mechanic"), "/clock/job-cards");
assert.equal(clockHome("office"), "/clock/slips");
assert.equal(clockHome("clock"), "/clock");
});