summaryrefslogtreecommitdiff
path: root/frontend/src/lib/round2DashboardIntegration.test.ts
diff options
context:
space:
mode:
authorSomhairle H. Marisol <[email protected]>2026-09-18 18:11:53 +0800
committerSomhairle H. Marisol <[email protected]>2026-09-18 18:11:53 +0800
commit3030ee15a888c5c32bd3cfc889b230b9083514f3 (patch)
tree16cac985df170ff833e3ec65f202c192038501fa /frontend/src/lib/round2DashboardIntegration.test.ts
parentc52a727d11b87d70ec00a7e2569841e6e6abcd9c (diff)
downloadstrategy-lab-3030ee15a888c5c32bd3cfc889b230b9083514f3.tar.gz
[实现方案] round6 守门与验证:token 白名单测试、旅程重排断言、probe 全旅程步进(artifacts/ui-round6)与迁移文档
Diffstat (limited to 'frontend/src/lib/round2DashboardIntegration.test.ts')
-rw-r--r--frontend/src/lib/round2DashboardIntegration.test.ts37
1 files changed, 20 insertions, 17 deletions
diff --git a/frontend/src/lib/round2DashboardIntegration.test.ts b/frontend/src/lib/round2DashboardIntegration.test.ts
index c345ca2..eaa703c 100644
--- a/frontend/src/lib/round2DashboardIntegration.test.ts
+++ b/frontend/src/lib/round2DashboardIntegration.test.ts
@@ -31,28 +31,31 @@ beforeEach(() => {
afterEach(() => cleanup());
-// Leader round2: 登录后默认页 = 指标卡行 + 项目行迷你权益缩略图。
-describe('ProjectsPage dashboard round2 (metric row + row sparkline, real render)', () => {
- it('renders the 4-card metric row with真实聚合 numbers', async () => {
+// round6 旅程重排:首页去 4 张大卡,改为「问候 + 一行指标摘要(小字)
+// + 新建主 CTA + 项目卡列表(名称/状态 badge/迷你 sparkline)」。
+describe('ProjectsPage journey round6 (greeting + metrics summary + project cards)', () => {
+ it('renders a one-line metrics summary, not 4 big cards', async () => {
render(ProjectsPage);
await waitFor(() => expect(vi.mocked(getAIUsage)).toHaveBeenCalled());
- const cards = document.querySelectorAll('[data-testid="metric-card"]');
- await waitFor(() => expect(cards.length).toBe(4));
- const values = [...document.querySelectorAll('[data-testid="metric-value"]')].map((n) => n.textContent!.replace(/\s+/g, ' ').trim());
- expect(values[0]).toBe('2');
- expect(values[1]).toBe('3');
- expect(values[2]).toContain('已完成');
- expect(values[2]).toContain('2');
+ await waitFor(() => expect(document.querySelector('[data-testid="metrics-summary"]')).toBeTruthy());
+ expect(document.querySelectorAll('[data-testid="metric-card"]').length).toBe(0);
+ const summary = document.querySelector('[data-testid="metrics-summary"]')!.textContent!.replace(/\s+/g, ' ');
+ expect(summary).toContain('2 个项目');
+ expect(summary).toContain('3 个数据集');
+ expect(summary).toContain('2 次回测');
+ expect(summary).toContain('AI 请求 2');
});
- it('renders an inline sparkline row cell for projects whose latest run has equity, none for data-less ones', async () => {
+ it('renders project cards with status badge and inline sparkline for equity runs', async () => {
render(ProjectsPage);
await waitFor(() => expect(vi.mocked(listRuns)).toHaveBeenCalled());
- const rows = await waitFor(() => document.querySelectorAll('tbody tr'));
- await waitFor(() => expect(document.querySelector('svg[data-testid="sparkline"]')).toBeTruthy());
- const rowA = [...document.querySelectorAll('tbody tr')].find((r) => r.textContent!.includes('项目A'))!;
- const rowB = [...document.querySelectorAll('tbody tr')].find((r) => r.textContent!.includes('项目B'))!;
- expect(rowA.querySelector('svg[data-testid="sparkline"]'), '项目A has equity → sparkline renders').toBeTruthy();
- expect(rowB.querySelector('svg[data-testid="sparkline"]'), '项目B has no equity → stays empty').toBeNull();
+ await waitFor(() => expect(document.querySelector('[data-testid="sparkline"]')).toBeTruthy());
+ const linkA = document.querySelector('[data-testid="project-link"]');
+ expect(linkA).toBeTruthy();
+ expect(linkA!.textContent).toContain('项目A');
+ // 项目B has a succeeded run without equity → “完成” badge, no sparkline
+ const cardB = [...document.querySelectorAll('[role="listitem"]')].find((n) => n.textContent!.includes('项目B'))!;
+ expect(cardB.querySelector('[data-testid="sparkline"]')).toBeNull();
+ expect(cardB.textContent).toContain('完成');
});
});