## Summary - add chauffeur/subuser password recovery by SMS and authenticated password changes - add a read-only pre-authorized access-request preview with explicit approve/deny actions - replace duplicate customer grants with one deduplicated Buefy dropdown - show colored vehicle, toolbox, calendar, order, and driver permission indicators - add localized copy across all supported locale sources and generated catalogs ## Verification - ESLint passed - grant deduplication/icon unit tests: 2 passed - authentication Playwright coverage: 3 passed - authorized subuser management Playwright coverage: 1 passed - mocked direct approval browser flow passed - i18n source/runtime checks passed - production build passed (2,034 modules transformed) - `git diff --check` passed ## Paired delivery Paired API PR: https://github.com/copenhagentruckwash/api/pull/325 ## Visual change previews ### View: Forgot-password account selection **Description:** Visitors can now choose customer or chauffeur recovery; chauffeur recovery requests the country code and phone number used for the SMS reset link. #### Mobile (390 x 844) **Before:**  **After:**  #### Tablet (768 x 1024) **Before:**  **After:**  #### Desktop (1440 x 900) **Before:**  **After:**  ### View: Pre-authorized customer access decision **Description:** The SMS destination now previews the exact chauffeur and customer request and requires an explicit approve or deny action before mutating access. #### Mobile (390 x 844) **Before:**  **After:**  #### Tablet (768 x 1024) **Before:**  **After:**  #### Desktop (1440 x 900) **Before:**  **After:**  --------- Co-authored-by: Jeppe Bundgaard <jb@truckwash.dk>
55 lines
1.7 KiB
JavaScript
55 lines
1.7 KiB
JavaScript
import { describe, expect, it } from "vitest";
|
|
import {
|
|
normalizeSubuserGrantOptions,
|
|
permissionGroupsForGrant,
|
|
} from "@/components/session/subuser/subuserGrantOptions.js";
|
|
|
|
describe("subuser grant options", () => {
|
|
it("deduplicates customer rows while preserving the best name and all permissions", () => {
|
|
const result = normalizeSubuserGrantOptions([
|
|
{
|
|
billing_customer_number: 200,
|
|
name: "Beta Logistics",
|
|
enabled: false,
|
|
permissions: ["VEHICLES_LIST"],
|
|
},
|
|
{
|
|
billing_customer_number: 100,
|
|
name: "Alpha Transport",
|
|
enabled: true,
|
|
permissions: ["BOOKINGS_LIST"],
|
|
},
|
|
{
|
|
billing_customer_number: 200,
|
|
name: "",
|
|
enabled: true,
|
|
permissions: ["SELFSERVE_ADD", "VEHICLES_LIST"],
|
|
},
|
|
]);
|
|
|
|
expect(result).toHaveLength(2);
|
|
expect(result.map((grant) => grant.billing_customer_number)).toEqual([100, 200]);
|
|
expect(result[1]).toMatchObject({
|
|
name: "Beta Logistics",
|
|
enabled: true,
|
|
permissions: ["VEHICLES_LIST", "SELFSERVE_ADD"],
|
|
});
|
|
});
|
|
|
|
it("maps capabilities to colored vehicle, toolbox, calendar, order, and driver icons", () => {
|
|
const groups = permissionGroupsForGrant({
|
|
permissions: ["vehicles_list", "SELFSERVE_ADD", "BOOKINGS_EDIT", "ORDERS_LIST", "SUBUSERS_LIST"],
|
|
});
|
|
|
|
expect(groups.map((group) => group.key)).toEqual([
|
|
"vehicles",
|
|
"selfserve",
|
|
"bookings",
|
|
"orders",
|
|
"driver_management",
|
|
]);
|
|
expect(groups.map((group) => group.icon)).toContain("fas fa-toolbox");
|
|
expect(groups.map((group) => group.icon)).toContain("fas fa-calendar-check");
|
|
});
|
|
});
|