feat: expand intelligent investigation workspace
This commit is contained in:
@@ -1,7 +1,32 @@
|
||||
import { afterEach, describe, expect, it, vi } from "vitest";
|
||||
import { createAgentApiClient } from "./client";
|
||||
import { AgentResponseFinishedError, createAgentApiClient } from "./client";
|
||||
|
||||
describe("Agent prompt suggestions", () => {
|
||||
it("probes public readiness without loading identity or project credentials", async () => {
|
||||
const getAccessToken = vi.fn(async () => "private-token");
|
||||
const getProjectId = vi.fn(async () => "project");
|
||||
const fetcher = vi.fn().mockResolvedValueOnce(Response.json({ ok: true, ready: true }))
|
||||
.mockResolvedValueOnce(Response.json({ ok: true, ready: false }));
|
||||
vi.stubGlobal("fetch", fetcher);
|
||||
const client = createAgentApiClient("https://agent.local/prefix", { getAccessToken, getProjectId });
|
||||
const signal = new AbortController().signal;
|
||||
await expect(client.getHealth(signal)).resolves.toBeUndefined();
|
||||
expect(fetcher).toHaveBeenCalledWith("https://agent.local/prefix/health", { signal, cache: "no-store" });
|
||||
expect(getAccessToken).not.toHaveBeenCalled();
|
||||
expect(getProjectId).not.toHaveBeenCalled();
|
||||
await expect(client.getHealth(signal)).rejects.toThrow("尚未就绪");
|
||||
});
|
||||
it("distinguishes a proven pre-admission idle response from ambiguous input conflicts", async () => {
|
||||
const fetchMock = vi.fn()
|
||||
.mockResolvedValueOnce(Response.json({ code: "RESPONSE_FINISHED", message: "finished" }, { status: 409 }))
|
||||
.mockResolvedValueOnce(Response.json({ message: "unknown conflict" }, { status: 409 }));
|
||||
vi.stubGlobal("fetch", fetchMock);
|
||||
const client = createAgentApiClient("http://agent.local");
|
||||
await expect(client.submitResponseInput("s", "next", "queue", `msg_${"1".repeat(32)}`)).rejects.toBeInstanceOf(AgentResponseFinishedError);
|
||||
const uncertain = client.submitResponseInput("s", "next", "queue", `msg_${"2".repeat(32)}`);
|
||||
await expect(uncertain).rejects.not.toBeInstanceOf(AgentResponseFinishedError);
|
||||
expect(fetchMock).toHaveBeenCalledTimes(2);
|
||||
});
|
||||
it("uses owned topic endpoints and retains full-text hits from another topic", async () => {
|
||||
const topic = { id: "topic-a", name: "城南压力问题", createdAt: "2026-10-22T01:00:00Z", updatedAt: "2026-10-22T01:00:00Z" };
|
||||
const fetchMock = vi.fn()
|
||||
|
||||
Reference in New Issue
Block a user