import { describe, expect, it } from "vitest"; import { assertCustomerUsername, CustomerAccountError, } from "@/services/auth/customers"; import { hashPassword, passwordMatches } from "@/services/auth/passwords"; import { isStaffRole } from "@/services/tenant/access"; describe("customer accounts", () => { it("rejects reserved-like short names", () => { expect(() => assertCustomerUsername("ab")).toThrow(CustomerAccountError); }); it("accepts dotted customer usernames", () => { expect(assertCustomerUsername("acme.ops")).toBe("acme.ops"); }); it("matches sha256 password hash", () => { const hash = hashPassword("secret-1"); expect(passwordMatches("secret-1", hash, "")).toBe(true); expect(passwordMatches("wrong", hash, "")).toBe(false); }); it("treats admin/ops as staff", () => { expect(isStaffRole("admin")).toBe(true); expect(isStaffRole("ops")).toBe(true); expect(isStaffRole("customer")).toBe(false); }); });