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"); });