import { readFileSync } from "node:fs"; import { join } from "node:path"; import { describe, expect, it } from "vitest"; const managerSource = readFileSync(join(process.cwd(), "src/features/edgeGateways/EdgeGatewayManager.vue"), "utf8"); const overviewSource = readFileSync(join(process.cwd(), "src/features/edgeGateways/EdgeGatewayOverviewPage.vue"), "utf8"); const inventorySource = readFileSync(join(process.cwd(), "src/features/edgeGateways/EdgeGatewayInventoryPage.vue"), "utf8"); const operationsSource = readFileSync(join(process.cwd(), "src/features/edgeGateways/EdgeGatewayOperationsPage.vue"), "utf8"); const manageSource = readFileSync(join(process.cwd(), "src/features/edgeGateways/EdgeGatewayManagePage.vue"), "utf8"); const routerSource = readFileSync(join(process.cwd(), "src/router.js"), "utf8"); const edgeGatewaysPageSource = readFileSync( join(process.cwd(), "src/views/dashboards/superUserDashboard/EdgeGatewaysWorkspacePage.vue"), "utf8" ); const departmentGatewaysPageSource = readFileSync( join(process.cwd(), "src/views/dashboards/superUserDashboard/department/DepartmentGatewaysWorkspacePage.vue"), "utf8" ); describe("edge gateway workspace contract", () => { it("splits the v2 UI into route-driven overview, inventory, operations, and manage modules", () => { expect(managerSource).toContain('data-testid="edge-gateway-workspace"'); expect(managerSource).toContain('import EdgeGatewayOverviewPage'); expect(managerSource).toContain('import EdgeGatewayInventoryPage'); expect(managerSource).toContain('import EdgeGatewayOperationsPage'); expect(managerSource).toContain('import EdgeGatewayManagePage'); expect(overviewSource).toContain('data-testid="gateway-overview-page"'); expect(inventorySource).toContain('data-testid="gateway-inventory-page"'); expect(operationsSource).toContain('data-testid="gateway-operations-page"'); expect(manageSource).toContain('data-testid="gateway-manage-page"'); }); it("mounts route-driven full-page and safe-subset department workspaces", () => { expect(edgeGatewaysPageSource).toContain(':route-driven="true"'); expect(edgeGatewaysPageSource).toContain(':allow-destructive="true"'); expect(departmentGatewaysPageSource).toContain(':route-driven="false"'); expect(departmentGatewaysPageSource).toContain(':allow-destructive="false"'); expect(departmentGatewaysPageSource).toContain('@open-gateway-page="openGatewayPage"'); }); it("registers v2 gateway routes and legacy redirects", () => { expect(routerSource).toContain("path: '/superuser/gateways'"); expect(routerSource).toContain("name: 'edgegatewayoverview'"); expect(routerSource).toContain("path: '/superuser/gateways/:id/overview'"); expect(routerSource).toContain("name: 'edgegatewayinventory'"); expect(routerSource).toContain("path: '/superuser/gateways/:id/inventory'"); expect(routerSource).toContain("name: 'edgegatewayoperations'"); expect(routerSource).toContain("path: '/superuser/gateways/:id/operations'"); expect(routerSource).toContain("name: 'edgegatewaymanage'"); expect(routerSource).toContain("path: '/superuser/gateways/:id/manage'"); expect(routerSource).toContain("path: '/superuser/departments/:departmentId/gateways'"); expect(routerSource).toContain("configure: 'inventory'"); expect(routerSource).toContain("assess: 'overview'"); }); });