From 85f24bdb0c678aa42c6e5cbbea50af531fd8951e Mon Sep 17 00:00:00 2001 From: Jeppe Bundgaard Date: Thu, 23 Apr 2026 09:02:41 +0200 Subject: [PATCH] Improve readability in edge gateway tests and helper functions through consistent formatting adjustments --- tests/e2e/edge-gateways.smoke.spec.js | 3 +- .../release/edge-gateways.live-smoke.spec.ts | 4 +- tests/e2e/support/network.js | 47 ++++++++++++++----- tests/unit/edge-gateway-workspace.spec.js | 7 ++- 4 files changed, 43 insertions(+), 18 deletions(-) diff --git a/tests/e2e/edge-gateways.smoke.spec.js b/tests/e2e/edge-gateways.smoke.spec.js index 0eff603c..f3919615 100644 --- a/tests/e2e/edge-gateways.smoke.spec.js +++ b/tests/e2e/edge-gateways.smoke.spec.js @@ -184,7 +184,8 @@ test.describe("Edge gateway management smoke", () => { installSessionFailure: { step: "START_STACK", failurePoll: 4, - message: "Job for truckwash-edge-gateway-stack.service failed because the control process exited with error code.", + message: + "Job for truckwash-edge-gateway-stack.service failed because the control process exited with error code.", diagnostics: [ { name: "systemctl status", diff --git a/tests/e2e/release/edge-gateways.live-smoke.spec.ts b/tests/e2e/release/edge-gateways.live-smoke.spec.ts index 7cf6bd96..20e74ae3 100644 --- a/tests/e2e/release/edge-gateways.live-smoke.spec.ts +++ b/tests/e2e/release/edge-gateways.live-smoke.spec.ts @@ -44,9 +44,7 @@ test.describe("Edge gateway live smoke gate", () => { await page.goto(`/superuser/configuration/edgegateway/${gatewayId}/overview`); await settlePage(page); - await expect(page).toHaveURL( - new RegExp(`/superuser/configuration/edgegateway/${gatewayId}/overview(?:\\?.*)?$`) - ); + await expect(page).toHaveURL(new RegExp(`/superuser/configuration/edgegateway/${gatewayId}/overview(?:\\?.*)?$`)); await expect(page.getByTestId("gateway-detail-header")).toBeVisible(); await expect(page.locator("body")).not.toContainText(/404/i); diff --git a/tests/e2e/support/network.js b/tests/e2e/support/network.js index f09e2bb9..a2da3216 100644 --- a/tests/e2e/support/network.js +++ b/tests/e2e/support/network.js @@ -1289,7 +1289,9 @@ function buildHttpEdgeGatewayStatisticsPage(edgeGatewayFixture, gateway) { transport_health: cloneJson(gatewayPayload.transport_health || {}), backlog_depth: cloneJson(gatewayPayload.backlog_depth || {}), container_health: cloneJson(gatewayPayload.container_health || {}), - system_metrics: cloneJson(gatewayPayload.metadata?.system_metrics || gatewayPayload.agent_runtime?.system_metrics || {}), + system_metrics: cloneJson( + gatewayPayload.metadata?.system_metrics || gatewayPayload.agent_runtime?.system_metrics || {} + ), version_drift: cloneJson(gatewayPayload.version_drift || {}), }; } @@ -1481,7 +1483,12 @@ function finalizeEdgeGatewayInstallSession(edgeGatewayFixture, session) { edgeGatewayFixture.gateways.find( (gateway) => Number(gateway.department_id) === Number(session.department_id || 1) && - String(gateway.label || "").trim().toLowerCase() === String(session.label || "").trim().toLowerCase() + String(gateway.label || "") + .trim() + .toLowerCase() === + String(session.label || "") + .trim() + .toLowerCase() ) || edgeGatewayFixture.gateways[edgeGatewayFixture.gateways.length - 1] || null; @@ -1504,7 +1511,14 @@ function advanceEdgeGatewayInstallSession(edgeGatewayFixture, claimTokenId) { } session.poll_count = Number(session.poll_count || 0) + 1; - const steps = ["VERIFY_TOKEN", "INSTALL_PACKAGES", "DOWNLOAD_ARTIFACTS", "WRITE_CONFIG", "START_STACK", "WAIT_FOR_CLAIM"]; + const steps = [ + "VERIFY_TOKEN", + "INSTALL_PACKAGES", + "DOWNLOAD_ARTIFACTS", + "WRITE_CONFIG", + "START_STACK", + "WAIT_FOR_CLAIM", + ]; const failureConfig = session.failure && typeof session.failure === "object" ? session.failure @@ -1532,9 +1546,7 @@ function advanceEdgeGatewayInstallSession(edgeGatewayFixture, claimTokenId) { if (session.poll_count >= failurePoll) { session.status = "FAILED"; session.step = failureStep; - session.message = String( - failureConfig.message || "truckwash-edge-gateway-stack.service failed during startup." - ); + session.message = String(failureConfig.message || "truckwash-edge-gateway-stack.service failed during startup."); session.terminal = true; session.last_error = session.message; session.diagnostics = Array.isArray(failureConfig.diagnostics) @@ -1542,7 +1554,8 @@ function advanceEdgeGatewayInstallSession(edgeGatewayFixture, claimTokenId) { : [ { name: "systemctl status", - output: "Job for truckwash-edge-gateway-stack.service failed because the control process exited with error code.", + output: + "Job for truckwash-edge-gateway-stack.service failed because the control process exited with error code.", }, ]; pushEdgeGatewayInstallSessionEvent(session, session.status, session.step, session.message); @@ -3170,8 +3183,7 @@ async function handleEdgeGatewayRoute({ route, request, parsedUrl, pathname, met const edgeGatewayDeletePattern = /\/(?:modules\/)?edge-gateways\/(\d+)$/; const edgeGatewayCutoverPattern = /\/(?:modules\/edge-gateways\/departments\/(\d+)\/cutover|departments\/(\d+)\/gateway-cutover)$/; - const edgeGatewayUnsupportedPattern = - /\/(?:modules\/)?edge-gateways\/\d+\/(?:update-jobs|uninstall)(?:\/.*)?$/; + const edgeGatewayUnsupportedPattern = /\/(?:modules\/)?edge-gateways\/\d+\/(?:update-jobs|uninstall)(?:\/.*)?$/; const edgeGatewayShellPattern = /\/(?:modules\/)?edge-gateways\/\d+\/shell-sessions(?:\/.*)?$/; const buildConfigEntries = () => [ { variable: "enabled", value: edgeGatewayFixture.config.enabled }, @@ -3189,7 +3201,12 @@ async function handleEdgeGatewayRoute({ route, request, parsedUrl, pathname, met const variable = String(body.variable || ""); if (variable === "enabled") { - edgeGatewayFixture.config.enabled = !(body.value === false || body.value === "false" || body.value === 0 || body.value === "0"); + edgeGatewayFixture.config.enabled = !( + body.value === false || + body.value === "false" || + body.value === 0 || + body.value === "0" + ); } else if (variable === "default_release_channel") { edgeGatewayFixture.config.default_release_channel = String(body.value || "stable"); } else if (variable === "default_update_window") { @@ -3283,7 +3300,8 @@ async function handleEdgeGatewayRoute({ route, request, parsedUrl, pathname, met const gatewayId = extractMatchId(edgeGatewayStreamSessionPattern); const gateway = settleEdgeGatewayWork(edgeGatewayFixture, gatewayId); const body = request.postDataJSON?.() || {}; - const scopes = Array.isArray(body.scopes) && body.scopes.length ? body.scopes : ["overview", "tasks", "logs", "statistics"]; + const scopes = + Array.isArray(body.scopes) && body.scopes.length ? body.scopes : ["overview", "tasks", "logs", "statistics"]; await route.fulfill( gateway ? json( @@ -3832,7 +3850,12 @@ async function handleEdgeGatewayRoute({ route, request, parsedUrl, pathname, met ...edgeGatewayFixture.shellSessionsByGatewayId[gatewayId], ]; gateway.audit_logs = [ - { id: Date.now(), created_at: "2026-04-09 09:15:01", action: "GATEWAY_SHELL_SESSION_CREATED", actor_type: "USER" }, + { + id: Date.now(), + created_at: "2026-04-09 09:15:01", + action: "GATEWAY_SHELL_SESSION_CREATED", + actor_type: "USER", + }, ...(gateway.audit_logs || []), ]; diff --git a/tests/unit/edge-gateway-workspace.spec.js b/tests/unit/edge-gateway-workspace.spec.js index 35444876..3153ae47 100644 --- a/tests/unit/edge-gateway-workspace.spec.js +++ b/tests/unit/edge-gateway-workspace.spec.js @@ -30,7 +30,10 @@ const navigationSource = readFileSync( "utf8" ); const configurationNavigationSource = readFileSync( - join(process.cwd(), "src/views/dashboards/superUserDashboard/configuration/SuperUserDashboardConfigurationNavigation.vue"), + join( + process.cwd(), + "src/views/dashboards/superUserDashboard/configuration/SuperUserDashboardConfigurationNavigation.vue" + ), "utf8" ); @@ -65,7 +68,7 @@ describe("edge gateway workspace contract", () => { it("mounts a module workspace and a safe-subset department workspace", () => { expect(edgeGatewaysPageSource).toContain('data-testid="edge-gateway-module-config"'); - expect(edgeGatewaysPageSource).toContain('gateway-module-disabled-state'); + expect(edgeGatewaysPageSource).toContain("gateway-module-disabled-state"); expect(edgeGatewaysPageSource).toContain(':route-driven="true"'); expect(edgeGatewaysPageSource).toContain(':allow-destructive="true"'); expect(departmentGatewaysPageSource).toContain(':route-driven="false"');