





























@@ -4,7 +4,7 @@ import os from "node:os";
44import path from "node:path";
55import { setTimeout as sleep } from "node:timers/promises";
66import { afterEach, describe, expect, it, vi } from "vitest";
7-import { startQaLabServer } from "./lab-server.js";
7+import { startQaLabServer, type QaLabServerStartParams } from "./lab-server.js";
8899vi.mock("@openclaw/qa-channel/api.js", async () => await import("../../qa-channel/api.js"));
1010@@ -128,6 +128,13 @@ vi.mock("openclaw/plugin-sdk/proxy-capture", () => ({
128128129129const cleanups: Array<() => Promise<void>> = [];
130130131+async function startQaLabServerForTest(params?: QaLabServerStartParams) {
132+return await startQaLabServer({
133+embeddedGateway: "disabled",
134+ ...params,
135+});
136+}
137+131138afterEach(async () => {
132139captureMock.reset();
133140while (cleanups.length > 0) {
@@ -241,21 +248,22 @@ async function createQaLabRepoRootFixture(params?: {
241248}
242249243250describe("qa-lab server", () => {
244-it("serves bootstrap state and writes a self-check report", async () => {
251+it("serves bootstrap state and message state", async () => {
245252const tempDir = await mkdtemp(path.join(os.tmpdir(), "qa-lab-test-"));
246253cleanups.push(async () => {
247254await rm(tempDir, { recursive: true, force: true });
248255});
249256const outputPath = path.join(tempDir, "self-check.md");
250257const repoRoot = await createQaLabRepoRootFixture();
251258252-const lab = await startQaLabServer({
259+const lab = await startQaLabServerForTest({
253260host: "127.0.0.1",
254261port: 0,
255262 outputPath,
256263 repoRoot,
257264controlUiUrl: "http://127.0.0.1:18789/",
258265controlUiToken: "qa-token",
266+embeddedGateway: "disabled",
259267});
260268cleanups.push(async () => {
261269await lab.stop();
@@ -303,11 +311,7 @@ describe("qa-lab server", () => {
303311};
304312expect(snapshot.messages.some((message) => message.text === "hello from test")).toBe(true);
305313306-const result = await lab.runSelfCheck();
307-expect(result.scenarioResult.status).toBe("pass");
308-const markdown = await readFile(outputPath, "utf8");
309-expect(markdown).toContain("Synthetic Slack-class roundtrip");
310-expect(markdown).toContain("- Status: pass");
314+await expect(readFile(outputPath, "utf8")).rejects.toThrow();
311315});
312316313317it("anchors direct self-check runs under the explicit repo root by default", async () => {
@@ -316,10 +320,11 @@ describe("qa-lab server", () => {
316320await rm(repoRoot, { recursive: true, force: true });
317321});
318322319-const lab = await startQaLabServer({
323+const lab = await startQaLabServerForTest({
320324host: "127.0.0.1",
321325port: 0,
322326 repoRoot,
327+embeddedGateway: "disabled",
323328});
324329cleanups.push(async () => {
325330await lab.stop();
@@ -331,9 +336,10 @@ describe("qa-lab server", () => {
331336});
332337333338it("injects the kickoff task on demand and on startup", async () => {
334-const autoKickoffLab = await startQaLabServer({
339+const autoKickoffLab = await startQaLabServerForTest({
335340host: "127.0.0.1",
336341port: 0,
342+embeddedGateway: "disabled",
337343sendKickoffOnStart: true,
338344});
339345cleanups.push(async () => {
@@ -349,9 +355,10 @@ describe("qa-lab server", () => {
349355true,
350356);
351357352-const manualLab = await startQaLabServer({
358+const manualLab = await startQaLabServerForTest({
353359host: "127.0.0.1",
354360port: 0,
361+embeddedGateway: "disabled",
355362});
356363cleanups.push(async () => {
357364await manualLab.stop();
@@ -402,7 +409,7 @@ describe("qa-lab server", () => {
402409throw new Error("expected upstream address");
403410}
404411405-const lab = await startQaLabServer({
412+const lab = await startQaLabServerForTest({
406413host: "127.0.0.1",
407414port: 0,
408415advertiseHost: "127.0.0.1",
@@ -445,7 +452,7 @@ describe("qa-lab server", () => {
445452"utf8",
446453);
447454448-const lab = await startQaLabServer({
455+const lab = await startQaLabServerForTest({
449456host: "127.0.0.1",
450457port: 0,
451458 uiDistDir,
@@ -473,7 +480,7 @@ describe("qa-lab server", () => {
473480"<!doctype html><html><head><title>Temp QA Lab UI</title></head><body>repo-root-ui</body></html>",
474481});
475482476-const lab = await startQaLabServer({
483+const lab = await startQaLabServerForTest({
477484host: "127.0.0.1",
478485port: 0,
479486 repoRoot,
@@ -530,7 +537,7 @@ describe("qa-lab server", () => {
530537"utf8",
531538);
532539533-const lab = await startQaLabServer({
540+const lab = await startQaLabServerForTest({
534541host: "127.0.0.1",
535542port: 0,
536543 repoRoot,
@@ -579,7 +586,7 @@ describe("qa-lab server", () => {
579586"utf8",
580587);
581588582-const lab = await startQaLabServer({
589+const lab = await startQaLabServerForTest({
583590host: "127.0.0.1",
584591port: 0,
585592 repoRoot,
@@ -597,11 +604,13 @@ describe("qa-lab server", () => {
597604598605await lab.stop();
599606stopped = true;
600-expect(await waitForFileContent(stoppedPath, "terminated")).toBe("terminated");
607+if (process.platform !== "win32") {
608+expect(await waitForFileContent(stoppedPath, "terminated")).toBe("terminated");
609+}
601610});
602611603612it("can disable the embedded echo gateway for real-suite runs", async () => {
604-const lab = await startQaLabServer({
613+const lab = await startQaLabServerForTest({
605614host: "127.0.0.1",
606615port: 0,
607616embeddedGateway: "disabled",
@@ -630,7 +639,7 @@ describe("qa-lab server", () => {
630639});
631640632641it("exposes structured outcomes and can attach control-ui after startup", async () => {
633-const lab = await startQaLabServer({
642+const lab = await startQaLabServerForTest({
634643host: "127.0.0.1",
635644port: 0,
636645embeddedGateway: "disabled",
@@ -776,7 +785,7 @@ describe("qa-lab server", () => {
776785}),
777786});
778787779-const lab = await startQaLabServer({
788+const lab = await startQaLabServerForTest({
780789host: "127.0.0.1",
781790port: 0,
782791});
此内容由惯性聚合(RSS阅读器)自动聚合整理,仅供阅读参考。 原文来自 — 版权归原作者所有。