Patch local chat realtime and align Caddy

This commit is contained in:
kris
2026-04-10 22:12:58 +08:00
parent a084688e35
commit 1b0f126d4f
8 changed files with 144 additions and 17 deletions

View File

@@ -0,0 +1,37 @@
import test from "node:test";
import assert from "node:assert/strict";
import { readFile } from "node:fs/promises";
async function readSource(path: string) {
return readFile(new URL(path, import.meta.url), "utf8");
}
test("events route enriches message events with a lightweight project chat payload", async () => {
const source = await readSource("../src/app/api/v1/events/route.ts");
assert.match(
source,
/projectMessagesPayload:\s*buildProjectMessagesRealtimePayload\(state,\s*String\(payload\.projectId \?\? ""\)\)/,
"expected realtime event route to include a lightweight project chat payload for message events",
);
});
test("ProjectDetailActivity applies lightweight realtime chat payloads before scheduling reloads", async () => {
const source = await readSource("../android/app/src/main/java/com/hyzq/boss/ProjectDetailActivity.java");
assert.match(
source,
/if \(tryApplyRealtimeMessagesPatch\(event\)\) \{\s*return;\s*\}/,
"expected chat page to try a local realtime message patch before falling back to debounced reloads",
);
assert.match(
source,
/JSONObject projectMessagesPayload = event\.payload\.optJSONObject\("projectMessagesPayload"\);/,
"expected chat page to read the lightweight message payload from realtime events",
);
assert.match(
source,
/renderLoadedProjectSnapshot\(new ProjectSnapshot\(projectMessagesPayload,\s*null,\s*null\)\);/,
"expected chat page to render the local realtime payload without forcing a network request",
);
});

View File

@@ -0,0 +1,28 @@
import test from "node:test";
import assert from "node:assert/strict";
import { readFile } from "node:fs/promises";
test("deployment Caddyfile keeps boss and gptpluscontrol routes in a single site definition", async () => {
const source = await readFile(new URL("../deployment/Caddyfile", import.meta.url), "utf8");
assert.match(
source,
/boss\.hyzq\.net\s*\{/,
"expected deployment Caddyfile to define the main boss.hyzq.net site",
);
assert.match(
source,
/handle \/gptpluscontrol\/\* \{\s*reverse_proxy 127\.0\.0\.1:18081\s*\}/s,
"expected deployment Caddyfile to preserve the GPT Plus Control route under the boss domain",
);
assert.match(
source,
/reverse_proxy 127\.0\.0\.1:3000/,
"expected deployment Caddyfile to continue proxying boss-web to port 3000",
);
assert.equal(
(source.match(/boss\.hyzq\.net\s*\{/g) ?? []).length,
1,
"expected deployment Caddyfile to avoid duplicate boss.hyzq.net site definitions",
);
});