feat: add project-aware agent workspace
This commit is contained in:
@@ -3,21 +3,12 @@ import { mockAgentApi } from "./support/mock-agent-api";
|
||||
import { TEST_PROJECT_ID } from "./support/mock-scada-api";
|
||||
import { mockWorkbenchContext } from "./support/mock-workbench-context";
|
||||
|
||||
for (const { scope, width } of [
|
||||
{ scope: "project", width: 1440 },
|
||||
{ scope: "personal", width: 1440 },
|
||||
{ scope: "personal", width: 375 }
|
||||
] as const) {
|
||||
test(`authenticated ${scope} chat sends the matching context at ${width}px`, async ({ page }) => {
|
||||
for (const width of [1440, 375] as const) {
|
||||
test(`authenticated chat always sends the current project at ${width}px`, async ({ page }) => {
|
||||
await page.setViewportSize({ width, height: 900 });
|
||||
await mockWorkbenchContext(page);
|
||||
await mockAgentApi(page);
|
||||
if (scope === "personal") {
|
||||
await page.route("**/api/v1/projects?*", (route) => route.fulfill({
|
||||
headers: { "Access-Control-Allow-Origin": "*" },
|
||||
json: { items: [], total: 0, limit: 1000, offset: 0 }
|
||||
}));
|
||||
}
|
||||
// Removing the scope picker must keep the authorized project on every chat request.
|
||||
await page.route("**/runtime-config.js", (route) => route.fulfill({
|
||||
contentType: "application/javascript",
|
||||
body: `globalThis.__TJWATER_CONFIG__ = ${JSON.stringify({
|
||||
@@ -45,7 +36,7 @@ test(`authenticated ${scope} chat sends the matching context at ${width}px`, asy
|
||||
}`
|
||||
}));
|
||||
const streamHeaders: Array<Record<string, string>> = [];
|
||||
const expectedProject = scope === "project" ? TEST_PROJECT_ID : undefined;
|
||||
const expectedProject = TEST_PROJECT_ID;
|
||||
await page.route("**/api/v1/responses", async (route) => {
|
||||
if (route.request().method() !== "POST") {
|
||||
await route.fallback();
|
||||
@@ -70,11 +61,8 @@ test(`authenticated ${scope} chat sends the matching context at ${width}px`, asy
|
||||
await page.goto("/", { waitUntil: "domcontentloaded" });
|
||||
await page.getByRole("button", { name: width < 1024 ? "打开 Agent 面板" : /展开 Agent 助手面板/ }).click();
|
||||
const panel = page.locator('aside[aria-label="Agent 命令面板"]').filter({ visible: true });
|
||||
if (scope === "personal") {
|
||||
await panel.getByRole("button", { name: "选择对话归属" }).click();
|
||||
await page.getByRole("menuitem", { name: "个人会话", exact: true }).click();
|
||||
await expect(panel.getByRole("button", { name: "选择对话归属" })).toHaveText("个人会话");
|
||||
}
|
||||
await expect(panel.getByRole("button", { name: /选择对话归属|选择数据范围/ })).toHaveCount(0);
|
||||
await expect(panel.getByText("项目数据", { exact: true })).toHaveCount(0);
|
||||
await expect(panel.getByRole("button", { name: "选择 Agent 模型" })).toContainText("测试模型");
|
||||
await panel.getByRole("textbox").fill("检查会话项目上下文");
|
||||
await panel.getByRole("button", { name: "发送 Agent 指令" }).click();
|
||||
|
||||
Reference in New Issue
Block a user