Improve readability in edge gateway tests and helper functions through consistent formatting adjustments
This commit is contained in:
@@ -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 || []),
|
||||
];
|
||||
|
||||
|
||||
Reference in New Issue
Block a user