/** * 触发器管理页面 E2E 测试。 * * 验证点: * - 4 个 Tab(全部、业务、AI、ETL) * - 统一视图数据展示 * - 业务 Tab 编辑功能存在 */ import { test, expect } from '@playwright/test'; import { injectAuth, mockAllApis } from './helpers'; test.describe('触发器管理页面', () => { test.beforeEach(async ({ page }) => { await injectAuth(page); await mockAllApis(page); await page.goto('/triggers'); // 等待页面标题渲染 await expect(page.locator('text=触发器管理').first()).toBeVisible(); }); test('4 个 Tab 均可见', async ({ page }) => { await expect(page.locator('[role="tab"]', { hasText: '全部' })).toBeVisible(); await expect(page.locator('[role="tab"]', { hasText: '业务' })).toBeVisible(); await expect(page.locator('[role="tab"]', { hasText: 'AI' })).toBeVisible(); await expect(page.locator('[role="tab"]', { hasText: 'ETL' })).toBeVisible(); }); test('默认显示"全部"Tab', async ({ page }) => { const allTab = page.locator('[role="tab"]', { hasText: '全部' }); await expect(allTab).toHaveAttribute('aria-selected', 'true'); }); test('统一视图表格展示数据', async ({ page }) => { // "全部"Tab 的统一视图表格应展示 mock 数据 // 等待表格渲染 await expect(page.locator('table').first()).toBeVisible(); // 验证 mock 数据中的触发器名称 await expect(page.locator('text=测试触发器')).toBeVisible(); // 验证类型标签 await expect(page.locator('text=业务')).toBeVisible(); }); test('切换到业务 Tab 并验证编辑按钮', async ({ page }) => { const bizTab = page.locator('[role="tab"]', { hasText: '业务' }); await bizTab.click(); await expect(bizTab).toHaveAttribute('aria-selected', 'true'); await expect(page).toHaveURL(/\?tab=biz/); // 等待业务触发器表格加载 await expect(page.locator('table').first()).toBeVisible(); // 验证编辑按钮存在(mock 数据中 status=enabled,编辑按钮应可用) const editBtn = page.locator('button', { hasText: '编辑' }).first(); await expect(editBtn).toBeVisible(); }); test('切换到 AI Tab', async ({ page }) => { const aiTab = page.locator('[role="tab"]', { hasText: 'AI' }); await aiTab.click(); await expect(aiTab).toHaveAttribute('aria-selected', 'true'); await expect(page).toHaveURL(/\?tab=ai/); }); test('切换到 ETL Tab', async ({ page }) => { const etlTab = page.locator('[role="tab"]', { hasText: 'ETL' }); await etlTab.click(); await expect(etlTab).toHaveAttribute('aria-selected', 'true'); await expect(page).toHaveURL(/\?tab=etl/); // 等待 ETL 调度表格加载 await expect(page.locator('table').first()).toBeVisible(); }); test('通过 URL 直接访问 biz Tab', async ({ page }) => { await page.goto('/triggers?tab=biz'); const bizTab = page.locator('[role="tab"]', { hasText: '业务' }); await expect(bizTab).toHaveAttribute('aria-selected', 'true'); }); test('通过 URL 直接访问 ai Tab', async ({ page }) => { await page.goto('/triggers?tab=ai'); const aiTab = page.locator('[role="tab"]', { hasText: 'AI' }); await expect(aiTab).toHaveAttribute('aria-selected', 'true'); }); });