refactor: unify AI capabilities and workspace integration
This commit is contained in:
@@ -0,0 +1,90 @@
|
||||
import { expect, test } from "@playwright/test";
|
||||
|
||||
for (const renderer of ["future", "toString"]) {
|
||||
test(`unknown renderer ${renderer} preserves history without guessing from the tool name`, async ({
|
||||
page,
|
||||
}) => {
|
||||
const errors: string[] = [];
|
||||
const requests: string[] = [];
|
||||
page.on("pageerror", (error) => errors.push(error.message));
|
||||
page.on("request", (request) => requests.push(request.url()));
|
||||
const call = {
|
||||
id: "historical-call",
|
||||
name: "future_backtest_probe",
|
||||
status: "pending",
|
||||
presentation: {
|
||||
label: "历史业务操作",
|
||||
renderer,
|
||||
effect: "confirm",
|
||||
refresh: [],
|
||||
},
|
||||
preview: {
|
||||
backtest_run: { backtest_run_id: "must-not-fetch" },
|
||||
preserved: "固定输入仍可检查",
|
||||
},
|
||||
result: null,
|
||||
};
|
||||
const run = {
|
||||
id: "historical-run",
|
||||
conversation_id: "historical-conversation",
|
||||
status: "waiting_approval",
|
||||
model: "synthetic",
|
||||
elapsed_ms: 0,
|
||||
usage: {},
|
||||
tools: [call],
|
||||
};
|
||||
await page.route("**/api/v1/ai/settings", (route) =>
|
||||
route.fulfill({
|
||||
json: {
|
||||
base_url: "https://model.test/v1",
|
||||
model: "synthetic",
|
||||
protocol: "chat_completions",
|
||||
configured: true,
|
||||
enabled: true,
|
||||
ready: true,
|
||||
test_results: {},
|
||||
},
|
||||
}),
|
||||
);
|
||||
await page.route("**/api/v1/ai/conversations", (route) =>
|
||||
route.fulfill({
|
||||
json: [{ id: "historical-conversation", title: "历史会话" }],
|
||||
}),
|
||||
);
|
||||
await page.route(
|
||||
"**/api/v1/ai/conversations/historical-conversation",
|
||||
(route) =>
|
||||
route.fulfill({
|
||||
json: {
|
||||
id: "historical-conversation",
|
||||
title: "历史会话",
|
||||
runs: [run],
|
||||
messages: [
|
||||
{
|
||||
id: "historical-message",
|
||||
role: "assistant",
|
||||
parts: [{ type: "data-tool", data: call }],
|
||||
},
|
||||
],
|
||||
},
|
||||
}),
|
||||
);
|
||||
await page.goto("/");
|
||||
await page
|
||||
.getByLabel("密码", { exact: true })
|
||||
.fill("browser-test-password");
|
||||
await page.getByRole("button", { name: "进入工作空间" }).click();
|
||||
await page.getByRole("button", { name: "打开研究助手" }).click();
|
||||
const chat = page.getByRole("complementary", { name: "AI 研究助手" });
|
||||
await expect(chat.getByText("历史业务操作", { exact: true })).toBeVisible();
|
||||
await expect(chat.getByRole("button", { name: "确认执行" })).toBeDisabled();
|
||||
await expect(
|
||||
chat.getByRole("button", { name: "拒绝", exact: true }),
|
||||
).toBeEnabled();
|
||||
await chat.getByText("查看业务记录", { exact: true }).click();
|
||||
await expect(chat.locator("pre")).toContainText("固定输入仍可检查");
|
||||
await expect(chat.locator(".backtest-tool-summary")).toHaveCount(0);
|
||||
expect(requests.some((url) => url.includes("must-not-fetch"))).toBe(false);
|
||||
expect(errors).toEqual([]);
|
||||
});
|
||||
}
|
||||
Reference in New Issue
Block a user