feat: add main features
Agents for developpement added + frontend add + backend added. Git viewer created + agent and template creator + layout and project creator
This commit is contained in:
62
frontend/src/adapters/agent.test.ts
Normal file
62
frontend/src/adapters/agent.test.ts
Normal file
@ -0,0 +1,62 @@
|
||||
/**
|
||||
* Contract tests for `TauriAgentGateway`: they assert the exact `invoke()`
|
||||
* payload shape, which the mock gateway (used by feature tests) does NOT
|
||||
* exercise. This guards the class of "works in mock, broken in the real app"
|
||||
* bugs — e.g. forgetting to nest `projectId` inside the command's `request` DTO.
|
||||
*/
|
||||
|
||||
import { describe, it, expect, vi, beforeEach } from "vitest";
|
||||
|
||||
const invoke = vi.fn();
|
||||
vi.mock("@tauri-apps/api/core", () => ({
|
||||
invoke: (...args: unknown[]) => invoke(...args),
|
||||
Channel: class {
|
||||
onmessage: ((c: number[]) => void) | null = null;
|
||||
},
|
||||
}));
|
||||
|
||||
import { TauriAgentGateway } from "./agent";
|
||||
|
||||
describe("TauriAgentGateway invoke payloads", () => {
|
||||
beforeEach(() => invoke.mockReset().mockResolvedValue({}));
|
||||
|
||||
it("create_agent nests projectId inside the request DTO", async () => {
|
||||
await new TauriAgentGateway().createAgent("proj-1", {
|
||||
name: "Backend",
|
||||
profileId: "prof-9",
|
||||
});
|
||||
expect(invoke).toHaveBeenCalledWith("create_agent", {
|
||||
request: {
|
||||
projectId: "proj-1",
|
||||
name: "Backend",
|
||||
profileId: "prof-9",
|
||||
initialContent: null,
|
||||
},
|
||||
});
|
||||
});
|
||||
|
||||
it("update_agent_context wraps fields in the request DTO", async () => {
|
||||
await new TauriAgentGateway().updateContext("proj-1", "agent-2", "# ctx");
|
||||
expect(invoke).toHaveBeenCalledWith("update_agent_context", {
|
||||
request: { projectId: "proj-1", agentId: "agent-2", content: "# ctx" },
|
||||
});
|
||||
});
|
||||
|
||||
it("list_agents / read / delete pass top-level args (no request wrapper)", async () => {
|
||||
const gw = new TauriAgentGateway();
|
||||
await gw.listAgents("p");
|
||||
expect(invoke).toHaveBeenCalledWith("list_agents", { projectId: "p" });
|
||||
|
||||
await gw.readContext("p", "a");
|
||||
expect(invoke).toHaveBeenCalledWith("read_agent_context", {
|
||||
projectId: "p",
|
||||
agentId: "a",
|
||||
});
|
||||
|
||||
await gw.deleteAgent("p", "a");
|
||||
expect(invoke).toHaveBeenCalledWith("delete_agent", {
|
||||
projectId: "p",
|
||||
agentId: "a",
|
||||
});
|
||||
});
|
||||
});
|
||||
Reference in New Issue
Block a user