summaryrefslogtreecommitdiffhomepage
path: root/scripts/text-file-live.test.ts
diff options
context:
space:
mode:
authorAdam Malczewski <[email protected]>2026-10-24 18:47:01 +0900
committerAdam Malczewski <[email protected]>2026-10-24 18:47:01 +0900
commitb666d77df8cf4da6ae40fb5637268926f02cc44d (patch)
tree4208ec0f5f1ef2cf1a9cd9710a442ce10a5f0c61 /scripts/text-file-live.test.ts
parent48cdc3d19a319981a8a4128be98db3c283f81790 (diff)
downloaddispatch-web-b666d77df8cf4da6ae40fb5637268926f02cc44d.tar.gz
dispatch-web-b666d77df8cf4da6ae40fb5637268926f02cc44d.zip
test: run frontend verification natively under Bun
Make Bun the explicit Vitest runtime. Detect cyclic tool input before slow native pretty serialization, preserve shared references, and use native abort signals in the live jsdom probe. 2587 tests repeatedly green and2 real HTTP/UI tests pass; Bun-run typecheck, lint and production build pass without NODE_OPTIONS.
Diffstat (limited to 'scripts/text-file-live.test.ts')
-rw-r--r--scripts/text-file-live.test.ts20
1 files changed, 3 insertions, 17 deletions
diff --git a/scripts/text-file-live.test.ts b/scripts/text-file-live.test.ts
index 18d1cb6..3305616 100644
--- a/scripts/text-file-live.test.ts
+++ b/scripts/text-file-live.test.ts
@@ -2,24 +2,10 @@ import { type ChildProcess, spawn } from "node:child_process";
import { rm, writeFile } from "node:fs/promises";
import { resolve as resolvePath } from "node:path";
import { createInterface } from "node:readline";
-import { transferableAbortController } from "node:util";
import { fireEvent, render, screen } from "@testing-library/svelte";
import { afterAll, beforeAll, describe, expect, it } from "vitest";
import { createTextFileClient, Markdown } from "../src/features/markdown";
-// Bridge only the outer fetch edge's jsdom signal to Node's native signal.
-const networkFetch: typeof fetch = async (input, init) => {
- const controller = transferableAbortController();
- const abort = () => controller.abort();
- init?.signal?.addEventListener("abort", abort, { once: true });
- if (init?.signal?.aborted) controller.abort();
- try {
- return await fetch(input, { ...init, signal: controller.signal });
- } finally {
- init?.signal?.removeEventListener("abort", abort);
- }
-};
-
interface Fixture {
url: string;
path: string;
@@ -30,7 +16,7 @@ interface Fixture {
// Opt-in real cross-repo UI/network probe. Owns an ephemeral loopback server and
// temporary files only; never connects to or restarts the deployed application.
-// TEXT_FILE_LIVE_PROBE=1 bunx vitest run scripts/text-file-live.test.ts
+// bun run test:text-file-live
// The backend must be installed and typechecked first (workspace public dists).
describe.skipIf(process.env.TEXT_FILE_LIVE_PROBE !== "1")("live saved-file chat display", () => {
let child: ChildProcess;
@@ -86,7 +72,7 @@ describe.skipIf(process.env.TEXT_FILE_LIVE_PROBE !== "1")("live saved-file chat
const saved = Array.from({ length: 20 }, (_, i) => `## Saved step ${i + 1}`).join("\n");
await writeFile(fixture.path, saved);
const reply = "I saved the implementation plan.\n\n[Plan](text-file:plan%20100%25.md)";
- const client = createTextFileClient(fixture.url, fixture.conversationId, networkFetch);
+ const client = createTextFileClient(fixture.url, fixture.conversationId, fetch);
let view = render(Markdown, { text: reply, textFiles: client });
try {
await screen.findByRole("heading", { name: "Saved step 1" });
@@ -115,7 +101,7 @@ describe.skipIf(process.env.TEXT_FILE_LIVE_PROBE !== "1")("live saved-file chat
});
it("does not read the same local path for an authoritative remote conversation", async () => {
- const client = createTextFileClient(fixture.url, fixture.remoteConversationId, networkFetch);
+ const client = createTextFileClient(fixture.url, fixture.remoteConversationId, fetch);
const view = render(Markdown, {
text: `[Remote](text-file:${encodeURI(fixture.path)})`,
textFiles: client,