fix: 恢复 Cloud Web SPA 运行配置

This commit is contained in:
root
2026-07-11 12:06:57 +02:00
parent 9c91ea0c5c
commit 7939c4ca92
9 changed files with 74 additions and 3 deletions
@@ -7,7 +7,7 @@ import path from "node:path";
import test from "node:test";
import { gzipSync } from "node:zlib";
import { createCloudWebServer, isClientDisconnectError } from "./cloud-web-runtime.mjs";
import { createCloudWebServer, isClientDisconnectError, validateCloudWebRuntimeConfig } from "./cloud-web-runtime.mjs";
test("cloud web classifies Bun client disconnect ECONNRESET as non-fatal", () => {
const error = new Error("aborted");
@@ -16,6 +16,26 @@ test("cloud web classifies Bun client disconnect ECONNRESET as non-fatal", () =>
assert.equal(isClientDisconnectError(new Error("database migration failed")), false);
});
test("cloud web rejects a missing refresh replay capability before listening", async () => {
const restoreEnv = withEnv({
HWLAB_CLOUD_WEB_DISPLAY_TIME_ZONE: "Asia/Shanghai",
HWLAB_CLOUD_WEB_DISPLAY_TIME_LOCALE: "zh-CN",
HWLAB_CLOUD_WEB_DISPLAY_TIME_LABEL: "北京时间",
HWLAB_WORKBENCH_LIVE_KAFKA_SSE_ENABLED: "true",
HWLAB_WORKBENCH_KAFKA_REFRESH_REPLAY_ENABLED: undefined,
HWLAB_WORKBENCH_PROJECTION_REALTIME_ENABLED: "false",
HWLAB_WORKBENCH_KAFKA_DEBUG_REPLAY_ENABLED: "true",
HWLAB_WORKBENCH_RAW_HWLAB_EVENT_WINDOW_ENABLED: "true",
HWLAB_WORKBENCH_RAW_HWLAB_EVENT_WINDOW_MAX_ENTRIES: "200",
HWLAB_WORKBENCH_RAW_HWLAB_EVENT_WINDOW_MAX_RETAINED_BYTES: "1048576"
});
try {
await assert.rejects(validateCloudWebRuntimeConfig(), /HWLAB_WORKBENCH_KAFKA_REFRESH_REPLAY_ENABLED/u);
} finally {
restoreEnv();
}
});
test("cloud web auth requests are proxied once", async () => {
let upstreamRequests = 0;
const upstream = createServer((request, response) => {