58 lines
2.4 KiB
TypeScript
58 lines
2.4 KiB
TypeScript
import assert from "node:assert/strict";
|
|
import { readFile } from "node:fs/promises";
|
|
import test from "node:test";
|
|
import { fileURLToPath } from "node:url";
|
|
|
|
const repositoryRoot = fileURLToPath(new URL("../../..", import.meta.url));
|
|
const productionFiles = [
|
|
"internal/cloud/kafka-event-bridge.ts",
|
|
"internal/cloud/server-workbench-realtime-http.ts",
|
|
"internal/cloud/server-code-agent-admission-http.ts",
|
|
"internal/cloud/server.ts",
|
|
"web/hwlab-cloud-web/src/config/runtime.ts",
|
|
"web/hwlab-cloud-web/src/api/workbench-events.ts",
|
|
"web/hwlab-cloud-web/src/utils/workbench-stream-transport.ts",
|
|
"web/hwlab-cloud-web/src/utils/workbench-realtime-runtime.ts",
|
|
"web/hwlab-cloud-web/src/stores/workbench.ts",
|
|
"web/hwlab-cloud-web/src/stores/workbench-event-reducer.ts",
|
|
"web/hwlab-cloud-web/src/stores/workbench-realtime-plan.ts"
|
|
];
|
|
const forbiddenArchitectureIdentifiers = [
|
|
"directPublish",
|
|
"liveKafkaSse",
|
|
"kafkaRefreshReplay",
|
|
"transactionalProjector",
|
|
"projectionOutboxRelay",
|
|
"projectionRealtime",
|
|
"startLiveHwlabKafkaEventBridge",
|
|
"handleLiveKafkaWorkbenchRealtimeHttp",
|
|
"handleKafkaRefreshReplayWorkbenchRealtimeHttp",
|
|
"subscribeLiveHwlabEvents",
|
|
"queryHwlabEventRetention",
|
|
"WorkbenchRealtimeCapabilities",
|
|
"workbenchRealtimeCapabilities",
|
|
"workbenchHistoryAuthorityPolicy",
|
|
"workbenchRealtimeTransportEnabled",
|
|
"workbenchRealtimeTraceIdForCapabilities",
|
|
"workbenchProjectionEventStreamPath"
|
|
];
|
|
|
|
test("Workbench production source has one fixed transactional projection architecture", async () => {
|
|
const violations: string[] = [];
|
|
for (const relativePath of productionFiles) {
|
|
const source = await readFile(`${repositoryRoot}/${relativePath}`, "utf8");
|
|
for (const identifier of forbiddenArchitectureIdentifiers) {
|
|
if (source.includes(identifier)) violations.push(`${relativePath}: ${identifier}`);
|
|
}
|
|
}
|
|
assert.deepEqual(violations, []);
|
|
});
|
|
|
|
test("raw hwlab Kafka fixtures remain isolated to the explicit debug path", async () => {
|
|
const fixtureSource = await readFile(`${repositoryRoot}/web/hwlab-cloud-web/src/stores/workbench-live-kafka-event.ts`, "utf8");
|
|
const debugSource = await readFile(`${repositoryRoot}/web/hwlab-cloud-web/src/stores/workbench-isolated-kafka-debug.ts`, "utf8");
|
|
assert.match(fixtureSource, /historical hwlab\.event\.debug\.v1 fixtures/u);
|
|
assert.match(fixtureSource, /never imported by the product Workbench SSE path/u);
|
|
assert.match(debugSource, /workbench-live-kafka-event/u);
|
|
});
|