/** * Dashboard 页面 E2E 测试。 * * 验证点: * - 4 个区块渲染(OpsPanel、DbHealthCard、AI 运行总览、AI 调度摘要) * - 跳转链接正确(ETL 状态详情、触发器详情、AI 调度详情) */ import { test, expect } from '@playwright/test'; import { injectAuth, mockAllApis } from './helpers'; test.describe('Dashboard 页面', () => { test.beforeEach(async ({ page }) => { await injectAuth(page); await mockAllApis(page); await page.goto('/dashboard'); // 等待页面标题渲染,确认 Dashboard 已加载 await expect(page.locator('text=运行状态').first()).toBeVisible(); }); test('4 个区块均渲染', async ({ page }) => { // 区块 1:OpsPanel 子组件(系统资源信息) // SystemResourceSection 会展示 CPU / 内存 / 磁盘等信息 await expect(page.locator('text=CPU').first()).toBeVisible(); // 区块 2:数据库健康监控(DbHealthCard) await expect(page.locator('text=数据库').first()).toBeVisible(); // 区块 3:AI 运行总览 await expect(page.locator('text=AI 运行总览').first()).toBeVisible(); // 区块 4:AI 调度摘要 await expect(page.locator('text=AI 调度摘要').first()).toBeVisible(); // 验证统计卡片存在 await expect(page.locator('text=今日触发数')).toBeVisible(); await expect(page.locator('text=今日成功率')).toBeVisible(); await expect(page.locator('text=总记录数')).toBeVisible(); }); test('ETL 状态详情跳转到 /etl-tasks?tab=status', async ({ page }) => { const btn = page.locator('button', { hasText: 'ETL 状态详情' }); await expect(btn).toBeVisible(); await btn.click(); await expect(page).toHaveURL(/\/etl-tasks\?tab=status/); }); test('触发器详情跳转到 /triggers?tab=all', async ({ page }) => { const btn = page.locator('button', { hasText: '触发器详情' }); await expect(btn).toBeVisible(); await btn.click(); await expect(page).toHaveURL(/\/triggers\?tab=all/); }); test('AI 调度详情跳转到 /triggers?tab=ai', async ({ page }) => { const btn = page.locator('button', { hasText: 'AI 调度详情' }); await expect(btn).toBeVisible(); await btn.click(); await expect(page).toHaveURL(/\/triggers\?tab=ai/); }); test('AI 调度摘要底部链接跳转到 /triggers?tab=ai', async ({ page }) => { // 卡片底部的 "查看 AI 调度详情" 链接 const link = page.locator('text=查看 AI 调度详情'); await expect(link).toBeVisible(); await link.click(); await expect(page).toHaveURL(/\/triggers\?tab=ai/); }); });