Files
OmniRoute/tests/unit/muse-spark-response-parser-split.test.ts
Ankit e61b75f007 fix(config): externalize ws for copilot-m365-web executor (#6098, closes #6062)
Externalize ws / bufferutil / utf-8-validate in serverExternalPackages so the copilot-m365-web WebSocket masking path works at runtime (bundling ws → TypeError: b.mask is not a function → 80s chat timeout). Regression guard in next-config.test.ts.

Co-authored-by: diegosouzapw <diegosouza.pw@gmail.com>
2026-07-03 16:36:35 -03:00

34 lines
1.4 KiB
TypeScript

import { test } from "node:test";
import assert from "node:assert/strict";
import { readFileSync } from "node:fs";
import { fileURLToPath } from "node:url";
import { dirname, join } from "node:path";
// Split-guard for the muse-spark-web Meta AI response-parser extraction.
// The pure SSE/JSON parsing + content/reasoning/error extraction lives in
// muse-spark-web/response-parser.ts (no host state/fetch/auth). Host imports it back.
const HERE = dirname(fileURLToPath(import.meta.url));
const EXE = join(HERE, "../../open-sse/executors");
const HOST = join(EXE, "muse-spark-web.ts");
const LEAF = join(EXE, "muse-spark-web/response-parser.ts");
test("leaf hosts the parser and does not import the host", () => {
const src = readFileSync(LEAF, "utf8");
for (const sym of ["parseMetaAiResponseText", "parseMetaSseFrames", "isRecord"]) {
assert.match(src, new RegExp(`export function ${sym}\\b`));
}
assert.doesNotMatch(src, /from "\.\.\/muse-spark-web\.ts"/);
});
test("host imports the parser back from the leaf", () => {
const host = readFileSync(HOST, "utf8");
assert.match(host, /from "\.\/muse-spark-web\/response-parser\.ts"/);
});
test("parseMetaAiResponseText tolerates empty input", async () => {
const { parseMetaAiResponseText } =
await import("../../open-sse/executors/muse-spark-web/response-parser.ts");
const out = parseMetaAiResponseText("", false);
assert.equal(typeof out, "object");
});