Files
api/services/edge-broker/test/config.test.mjs
T
Jeppe Bundgaard 69eefdd572 Add Edge Broker service and configuration defaults
Introduced the Edge Broker service in the Docker Compose setup, configured to run on port 4300. Updated `.env.example` to include default environment variables for the Edge Broker and adjusted tests to validate the new configuration. Updated visual snapshot tests to reflect related UI changes.
2026-04-14 16:48:41 +02:00

43 lines
1.4 KiB
JavaScript

import test from "node:test";
import assert from "node:assert/strict";
import { existsSync, readFileSync } from "node:fs";
function readExistingSource(relativePath) {
const sourceUrl = new URL(relativePath, import.meta.url);
if (!existsSync(sourceUrl)) {
return "";
}
return readFileSync(sourceUrl, "utf8");
}
function readExistingSources(relativePaths) {
return relativePaths
.map((relativePath) => readExistingSource(relativePath))
.filter(Boolean)
.join("\n");
}
const composeSource = readExistingSources([
"../../../docker-compose.yml",
"../../../docker-compose.prod.yml",
]);
const traefikSource = readExistingSources([
"../../../services/traefik/traefik.yml",
"../../../services/traefik/traefik.prod.yml",
]);
test("traefik does not expose a dedicated public edge broker port", () => {
assert.doesNotMatch(traefikSource, /edge-broker:\s*\n\s*address:\s*":4300"/);
});
test("docker compose exposes the edge broker service on port 4300", () => {
assert.match(composeSource, /\bedge-broker:\b/);
assert.match(composeSource, /edge-broker:\s*\n[\s\S]*?\n\s+ports:\s*\n\s+- "4300:4300"/);
});
test("php services receive broker websocket environment defaults", () => {
assert.match(composeSource, /EDGE_BROKER_URL:\s*\$\{EDGE_BROKER_URL:-http:\/\/edge-broker:4300\}/);
assert.match(composeSource, /EDGE_BROKER_SHARED_SECRET:\s*\$\{EDGE_BROKER_SHARED_SECRET:-truckwash-edge-dev\}/);
});