feat(web): add Agent Studio workspace UI

This commit is contained in:
Wenxin Duan
2026-09-07 17:17:04 +08:00
parent 63ea92b770
commit 145033974e
18 changed files with 647 additions and 2 deletions
+58
View File
@@ -0,0 +1,58 @@
import { render, screen } from "@testing-library/react";
import "@testing-library/jest-dom/vitest";
import userEvent from "@testing-library/user-event";
import { describe, expect, it, vi } from "vitest";
import { App } from "../src/App.js";
import { createInitialHarnessState, type HarnessClientState } from "../src/store/reducer.js";
function makeStore() {
const sendMessage = vi.fn().mockResolvedValue({ runId: "run_1" });
const state: HarnessClientState = {
...createInitialHarnessState(),
sessionId: "ses_test",
connection: "open",
skills: [{
name: "ads-analysis",
description: "分析广告投放指标",
source: "project",
filePath: ".agents/skills/ads-analysis/SKILL.md",
diagnostics: [],
}],
};
return {
getSnapshot: () => state,
subscribe: () => () => undefined,
sendMessage,
cancel: vi.fn().mockResolvedValue({ cancelled: false }),
start: vi.fn().mockResolvedValue(undefined),
getModelConfig: vi.fn().mockResolvedValue({
modelConfig: { configured: true, source: "environment", providerId: "openai", api: "openai-responses", modelId: "gpt-test", supportsImages: true },
}),
};
}
describe("App", () => {
it("renders the three primary work areas", () => {
render(<App store={makeStore()} autoStart={false} modelConfigured />);
expect(screen.getByRole("region", { name: "Skills Catalog" })).toBeVisible();
expect(screen.getByRole("main", { name: "Streaming Chat" })).toBeVisible();
expect(screen.getByRole("region", { name: "Event Timeline" })).toBeVisible();
});
it("fills but does not send the demo prompt", async () => {
const user = userEvent.setup();
const store = makeStore();
render(<App store={store} autoStart={false} modelConfigured />);
await user.click(screen.getByRole("button", { name: "填入演示任务" }));
expect(screen.getByRole<HTMLTextAreaElement>("textbox").value).toContain("demo-account");
expect(store.sendMessage).not.toHaveBeenCalled();
});
it("disables sending and points to settings when the model is missing", () => {
render(<App store={makeStore()} autoStart={false} modelConfigured={false} />);
expect(screen.getByRole("button", { name: "发送消息" })).toBeDisabled();
expect(screen.getByText("请先配置模型连接")).toBeVisible();
});
});