feat: personalize and stream mentor chat
This commit is contained in:
@@ -218,6 +218,18 @@ async function mockApplication(page, authSession = session()) {
|
||||
};
|
||||
} else if (url.pathname === "/api/mentors/setup") {
|
||||
payload = { trade_date: "20260722", mentors: mentorDirectory(authSession.user.role) };
|
||||
} else if (url.pathname === "/api/mentors/chat") {
|
||||
await route.fulfill({
|
||||
status: 200,
|
||||
contentType: "application/x-ndjson; charset=utf-8",
|
||||
body: [
|
||||
JSON.stringify({ type: "delta", content: "## 判断\n先看市场结构。\n\n" }),
|
||||
JSON.stringify({ type: "delta", content: "- 等待确认\n- 控制仓位" }),
|
||||
JSON.stringify({ type: "meta", data_trade_date: "20260722", notice: "" }),
|
||||
JSON.stringify({ type: "done" }),
|
||||
].join("\n"),
|
||||
});
|
||||
return;
|
||||
}
|
||||
else if (url.pathname === "/api/heaven/setup") {
|
||||
await route.fulfill({ status: 503, contentType: "application/json", body: JSON.stringify({ error: "测试环境不加载问天数据" }) });
|
||||
@@ -515,6 +527,30 @@ test("mentor directory exposes evidence filters and private owner metadata", asy
|
||||
await expect(page.locator("#activeMentorEvidence")).toHaveText("公开访谈与多源材料");
|
||||
});
|
||||
|
||||
test("mentor pins, custom order and streamed replies work together", async ({ page }) => {
|
||||
await mockApplication(page, session("admin", true));
|
||||
await page.goto("/index.html");
|
||||
await page.locator('[data-view="mentorView"]').first().click();
|
||||
|
||||
await page.locator('[data-mentor-pin="source-c"]').click();
|
||||
await expect(page.locator("#mentorList [data-mentor-card]").first()).toHaveAttribute("data-mentor-card", "source-c");
|
||||
await page.locator('[data-mentor-pin="source-b"]').click();
|
||||
await expect(page.locator("#mentorList [data-mentor-card]").first()).toHaveAttribute("data-mentor-card", "source-b");
|
||||
|
||||
await page.locator("#mentorSortToggle").click();
|
||||
await page.locator('[data-mentor-target="source-b"][data-mentor-move="down"]').click();
|
||||
await expect(page.locator("#mentorList [data-mentor-card]").first()).toHaveAttribute("data-mentor-card", "source-c");
|
||||
|
||||
await page.locator('[data-mentor-id="source-c"]').click();
|
||||
await page.locator("#mentorQuestion").fill("现在怎么看?");
|
||||
await page.locator("#sendMentorQuestion").click();
|
||||
const answer = page.locator("#mentorMessages .mentor-message.assistant").last();
|
||||
await expect(answer).toContainText("先看市场结构。");
|
||||
await expect(answer.locator(".mentor-answer-list li")).toHaveCount(2);
|
||||
await expect(answer.locator("br")).toHaveCount(0);
|
||||
await expect(page.locator("#mentorMessages .assistant-stream-caret")).toHaveCount(0);
|
||||
});
|
||||
|
||||
test("mobile mentor directory opens as a searchable selector and hides private mentors", async ({ page }) => {
|
||||
await page.setViewportSize({ width: 375, height: 812 });
|
||||
await mockApplication(page, session("user", true));
|
||||
|
||||
Reference in New Issue
Block a user