Repository navigation
harness: load undici at first use so the server source guard stays green - #499
Closed
kridaydave wants to merge 1 commit into
Closed
kridaydave wants to merge 1 commit into
kridaydave wants to merge 1 commit into
Annotations
2 errors
|
Source guards
Process completed with exit code 1.
|
|
Source guards:
scripts/testing/ci-retry-list.test.ts#L30
AssertionError: server/post-to-room.test.ts: stops a turn at its third room post, and the next turn may post again: expected 'import { spawn, type ChildProcess } f…' to contain 'stops a turn at its third room post, …'
- Expected
+ Received
- stops a turn at its third room post, and the next turn may post again
+ import { spawn, type ChildProcess } from "node:child_process";
+ import { existsSync, mkdirSync, mkdtempSync, readFileSync, rmSync, writeFileSync } from "node:fs";
+ import { tmpdir } from "node:os";
+ import { dirname, join } from "node:path";
+ import { fileURLToPath } from "node:url";
+ import { afterAll, beforeAll, describe, expect, it } from "vitest";
+
+ import { removeTempDir, waitForExit } from "./testing/cleanup.ts";
+ import { readHandoffs } from "./testing/handoff-rows.ts";
+ import { freePortBlock } from "./testing/ports.ts";
+ import "./server-line-packs.ts";
+ import { serverLine } from "./server-lines.ts";
+
+ const SERVER_DIR = dirname(fileURLToPath(import.meta.url));
+ const FAKE_CLAUDE_CLI = join(SERVER_DIR, "testing", "fake-claude-cli.ts");
+ const TEST_CAPABILITY_KEY = "post-to-room-fixture-capability";
+
+ let PORT = 0;
+ let WEBHOOK_PORT = 0;
+ let BASE = "";
+ let child: ChildProcess;
+ let home: string;
+ let fakeClaudeDump = "";
+ let mentionerDump = "";
+ let stderr = "";
+ const OUTSIDE_BOT = "Outside Bot";
+
+ interface ApiResult {
+ status: number;
+ body: Record<string, unknown>;
+ }
+
+ const api = async (method: string, path: string, body?: unknown): Promise<ApiResult> => {
+ const res = await fetch(`${BASE}${path}`, {
+ method,
+ headers: body ? { "content-type": "application/json" } : undefined,
+ body: body ? JSON.stringify(body) : undefined,
+ });
+ const parsed: unknown = await res.json().catch(() => ({}));
+ // SAFETY: the harness answers every /api route with a JSON object; anything else fails an assertion.
+ return { status: res.status, body: (parsed ?? {}) as Record<string, unknown> };
+ };
+
+ const startTurn = async (botId: string, threadId: string): Promise<string> => {
+ const minted = await fetch(`${BASE}/api/testing/internal-capability`, {
+ method: "POST",
+ headers: { "content-type": "application/json", "x-dusk-test-capability": TEST_CAPABILITY_KEY },
+ body: JSON.stringify({ botId, threadId, kind: "agents", skillAuthoring: true }),
+ });
+ return (await minted.json() as { token: string }).token;
+ };
+
+ const internal = async (method: string, path: string, body?: unknown): Promise<ApiResult> => {
+ const url = new URL(path, BASE);
+ const claims = body && typeof body === "object" && !Array.isArray(body)
+ ? body as Record<string, unknown>
+ : {};
+ const botId = String(claims.fromBotId ?? claims.botId ?? url.searchParams.get("fromBotId") ?? url.searchParams.get("botId") ?? "");
+ const threadId = String(claims.fromThreadId ?? claims.threadId ?? url.searchParams.get("fromThreadId") ?? "");
+ return asTurn(await startTurn(botId, threadId), method, path, body);
+ };
+
+ const asTurn = async (token: string, method: string, path: string, body?: unknown): Promise<ApiResult> => {
+ const res = await fetch(`${BASE}${path}`, {
+ method,
+ headers: {
+ authorization: `***
+ ...(body ? { "content-type": "application/json" } : {}),
+ },
+ body: body ? JSON.stringify(body) : undefined,
+ });
+ const parsed: unknown = await res.json().catch(() => ({}));
+ // SAFETY: same contract as `api` above, internal routes answer JSON too.
+ return { status: res.status, body: (parsed ?? {}) as Record<string, unknown> };
+ };
+
+ const field = (body: Record<string, unknown>, ...path: string[]): unknown => {
+ let cursor: unknown = body;
+ for (const key of path) {
+ if (cursor === null || typeof cursor !== "object") return undefined;
+ cursor = (cursor as Record<string, unknown>)[key];
+ }
+ return cursor;
+ };
+
+ const str = (value: unknown): string => (typeof value === "string" ? value : "");
+
+ /** Sends a browser origin: a bare loopback POST is stamped as API ingr
|
background
wait
wait-all
cancel
parallel
Loading