Improve readability in edge gateway tests and helper functions through consistent formatting adjustments

This commit is contained in:
Jeppe Bundgaard
2026-04-23 09:02:41 +02:00
parent 0f8b0273c1
commit 85f24bdb0c
4 changed files with 43 additions and 18 deletions
+2 -1
View File
@@ -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",
@@ -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);
+35 -12
View File
@@ -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 || []),
];
+5 -2
View File
@@ -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"');