feat: 使用 Semi AI 组件升级研究助手与研究入口

This commit is contained in:
yuxuanhui
2026-09-10 12:22:26 +08:00
parent 9334b6f651
commit d403008f9b
16 changed files with 974 additions and 174 deletions
+58 -2
View File
@@ -93,7 +93,9 @@ test("model settings, text stream, contextual query, confirmation and preserved
await page.getByRole("button", { name: "切换研究助手" }).click();
const chat = page.getByRole("complementary", { name: "AI 研究助手" });
await chat.getByRole("button", { name: "新会话", exact: true }).click();
await expect(chat.locator(".ai-context")).toContainText("TEST0001");
await expect(chat.locator(".research-ai-reference")).toContainText(
"TEST0001",
);
const input = chat.getByRole("textbox", { name: "发送给研究助手" });
await input.fill("修改当前 Alpha 的备注");
await chat.getByRole("button", { name: "发送", exact: true }).click();
@@ -263,7 +265,7 @@ test("Lark workspace keeps pagination, account details and chat usable at every
await page.getByRole("button", { name: "Alpha 管理", exact: true }).click();
await page.getByRole("button", { name: "用户菜单", exact: true }).click();
await page.getByRole("button", { name: "查看个人信息", exact: true }).click();
await expect(input).toHaveValue("保留聊天草稿");
await expect(input).toHaveText("保留聊天草稿");
await chat.getByRole("button", { name: "收起研究助手" }).click();
await page.getByRole("button", { name: "配置", exact: true }).click();
await expect(
@@ -406,3 +408,57 @@ test("Markdown streams incomplete code, finishes safely and restores history", a
await expect(chat.getByRole("cell", { name: "1.2" })).toBeVisible();
expect(errors).toEqual([]);
});
test("AI composer preserves literal text, IME input and drafts while generating", async ({
page,
}) => {
await login(page);
await configure(page);
await page.getByRole("button", { name: "切换研究助手" }).click();
const chat = page.getByRole("complementary", { name: "AI 研究助手" });
await chat.getByRole("button", { name: "新会话", exact: true }).click();
const input = chat.getByRole("textbox", { name: "发送给研究助手" });
await expect(input.locator("p").first()).toHaveAttribute(
"data-placeholder",
"描述研究问题或要执行的操作…",
);
const sent: string[] = [];
page.on("request", (request) => {
if (
request.method() === "POST" &&
/\/ai\/conversations\/[^/]+\/runs$/.test(request.url())
)
sent.push(request.postDataJSON().message);
});
await chat
.getByRole("button", { name: "查询当前研究对象与已有结果", exact: true })
.click();
await expect(input).toHaveText("查询当前研究对象与已有结果");
expect(sent).toEqual([]);
await input.fill("SLOW <字段>");
await input.dispatchEvent("keydown", {
key: "Enter",
code: "Enter",
isComposing: true,
});
expect(sent).toEqual([]);
await input.press("Shift+Enter");
await input.pressSequentially("next");
await input.press("Enter");
await expect.poll(() => sent).toEqual(["SLOW <字段>\nnext"]);
await expect(chat.getByRole("button", { name: "停止生成" })).toBeVisible();
await input.fill("下一轮 <收益> 假设");
await chat.getByRole("button", { name: "停止生成" }).click();
await expect(chat.locator(".ai-run-state")).toContainText("已停止");
await expect(input).toHaveText("下一轮 <收益> 假设");
await input.fill("a".repeat(20001));
await expect(
chat.getByRole("button", { name: "发送", exact: true }),
).toBeDisabled();
await input.press("Enter");
expect(sent).toHaveLength(1);
await input.fill("");
await expect(
chat.getByRole("button", { name: "发送", exact: true }),
).toBeDisabled();
});