| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302 |
- /**
- * ================================================================
- * 场景:统一审核中心 E2E 测试
- * ================================================================
- * 用户故事:管理员在统一审核中心查看和处理所有待审核事项,
- * 包括文章审核、服务商审核、管家审核、提现审核等。
- *
- * 流程步骤:
- * 1. 管理员登录后台
- * 2. 进入统一审核中心
- * 3. 查看待审核事项列表
- * 4. 审核不同类型的事项
- * 5. 查看审核记录
- *
- * 关键里程碑:
- * - [Milestone-1] 审核中心页面加载成功
- * - [Milestone-2] 待审核事项列表加载正常
- * - [Milestone-3] 审核操作成功
- * - [Milestone-4] 审核记录可查询
- *
- * 运行:npx playwright test tests/e2e/unified-audit-center.spec.js
- * ================================================================
- */
- const { test, expect } = require('@playwright/test');
- test.describe('【场景流程】统一审核中心', () => {
- test.beforeEach(async ({ page }) => {
- // 管理员登录(admin 后台)
- await page.goto('http://cfc.iwintrue.com/admin/login');
- await page.waitForLoadState('networkidle');
- const adminPhone = '13701366188';
- const phoneInput = page.locator('input[placeholder="请输入手机号"]');
- await phoneInput.fill(adminPhone);
- await page.locator('.login-btn, button:has-text("登录")').click();
- await page.waitForTimeout(1500);
- // 验证登录成功
- try {
- await page.waitForSelector('.admin-tab, .admin-menu, .admin-layout', { timeout: 10000 });
- } catch (e) {
- if (await page.url().includes('/login')) {
- await page.goto('http://cfc.iwintrue.com/admin/review-center');
- await page.waitForLoadState('networkidle');
- }
- }
- });
- /**
- * 场景1:审核中心页面加载
- * 角色:管理员
- * 触发条件:进入统一审核中心
- * 校验:页面加载成功,tab 切换到待审核
- */
- test('[场景1] 审核中心页面加载 — 期望 tab 切换到待审核', async ({ page }) => {
- await page.goto('http://cfc.iwintrue.com/admin/review-center');
- await page.waitForLoadState('networkidle');
- // 验证页面标题
- const title = page.locator('.el-card__header, .tab-header, h2:has-text("审核中心")');
- expect(await title.isVisible()).toBeTruthy();
- // 验证默认选中"待审核" tab
- const pendingTab = page.locator('.nav-item.active, .el-tab-pane.is-active, text="待审核"');
- expect(await pendingTab.isVisible()).toBeTruthy();
- });
- /**
- * 场景2:待审核事项列表加载
- * 角色:管理员
- * 触发条件:进入待审核 tab
- * 校验:列表加载正常数据
- */
- test('[场景2] 待审核事项列表 — 期望加载正常', async ({ page }) => {
- await page.goto('http://cfc.iwintrue.com/admin/review-center');
- await page.waitForLoadState('networkidle');
- // 切换到待审核 tab
- const pendingTab = page.locator('.nav-item:has-text("待审核"), .tab-item:has-text("待审核")');
- await pendingTab.click();
- await page.waitForTimeout(1000);
- // 验证列表加载
- const rows = page.locator('.el-table__row, .review-item');
- const rowCount = await rows.count();
- expect(rowCount).toBeGreaterThanOrEqual(0);
- // 验证列数
- if (rowCount > 0) {
- const firstRow = rows.first();
- const cells = firstRow.locator('.el-table__cell, .review-cell');
- expect(await cells.count()).toBeGreaterThanOrEqual(5);
- }
- });
- /**
- * 场景3:审核文章
- * 角色:管理员
- * 触发条件:选择待审核文章,点击通过
- * 校验:审核成功,状态变为已发布
- */
- test('[场景3] 审核文章 — 期望通过成功', async ({ page }) => {
- await page.goto('http://cfc.iwintrue.com/admin/review-center');
- await page.waitForLoadState('networkidle');
- // 切换到文章审核 tab
- const articleTab = page.locator('.nav-item:has-text("文章审核"), .tab-item:has-text("文章")');
- await articleTab.click();
- await page.waitForTimeout(1000);
- // 查找待审核文章
- const pendingArticles = page.locator('.el-table__row:has-text("待审核")');
- const articleCount = await pendingArticles.count();
- if (articleCount > 0) {
- // 点击通过按钮
- const approveBtn = pendingArticles.first().locator('button:has-text("通过")');
- await approveBtn.click();
- await page.waitForTimeout(500);
- // 提交
- const submitBtn = page.locator('.el-dialog__footer button:has-text("确定"), button.el-button--primary');
- await submitBtn.click();
- await page.waitForTimeout(1000);
- // 验证提示
- const successTip = page.locator('.toast-success, text="审核通过"');
- expect(await successTip.isVisible().catch(() => false)).toBeTruthy();
- } else {
- // 无待审核文章,跳过
- expect(true).toBeTruthy();
- }
- });
- /**
- * 场景4:审核服务商
- * 角色:管理员
- * 触发条件:选择待审核服务商,点击通过
- * 校验:审核成功,状态变为已入驻
- */
- test('[场景4] 审核服务商 — 期望通过成功', async ({ page }) => {
- await page.goto('http://cfc.iwintrue.com/admin/review-center');
- await page.waitForLoadState('networkidle');
- // 切换到服务商审核 tab
- const vendorTab = page.locator('.nav-item:has-text("服务商审核"), .tab-item:has-text("服务商")');
- await vendorTab.click();
- await page.waitForTimeout(1000);
- // 查找待审核服务商
- const pendingVendors = page.locator('.el-table__row:has-text("待审核")');
- const vendorCount = await pendingVendors.count();
- if (vendorCount > 0) {
- // 点击通过按钮
- const approveBtn = pendingVendors.first().locator('button:has-text("通过")');
- await approveBtn.click();
- await page.waitForTimeout(500);
- // 提交
- const submitBtn = page.locator('.el-dialog__footer button:has-text("确定"), button.el-button--primary');
- await submitBtn.click();
- await page.waitForTimeout(1000);
- // 验证提示
- const successTip = page.locator('.toast-success, text="审核通过"');
- expect(await successTip.isVisible().catch(() => false)).toBeTruthy();
- } else {
- // 无待审核服务商,跳过
- expect(true).toBeTruthy();
- }
- });
- /**
- * 场景5:审核提现申请
- * 角色:管理员
- * 触发条件:选择待审核提现,点击通过
- * 校验:审核成功,状态变为已打款
- */
- test('[场景5] 审核提现申请 — 期望通过成功', async ({ page }) => {
- await page.goto('http://cfc.iwintrue.com/admin/review-center');
- await page.waitForLoadState('networkidle');
- // 切换到提现审核 tab
- const withdrawTab = page.locator('.nav-item:has-text("提现审核"), .tab-item:has-text("提现")');
- await withdrawTab.click();
- await page.waitForTimeout(1000);
- // 查找待审核提现
- const pendingWithdraws = page.locator('.el-table__row:has-text("待审核")');
- const withdrawCount = await pendingWithdraws.count();
- if (withdrawCount > 0) {
- // 点击通过按钮
- const approveBtn = pendingWithdraws.first().locator('button:has-text("通过")');
- await approveBtn.click();
- await page.waitForTimeout(500);
- // 提交
- const submitBtn = page.locator('.el-dialog__footer button:has-text("确定"), button.el-button--primary');
- await submitBtn.click();
- await page.waitForTimeout(1000);
- // 验证提示
- const successTip = page.locator('.toast-success, text="审核通过"');
- expect(await successTip.isVisible().catch(() => false)).toBeTruthy();
- } else {
- // 无待审核提现,跳过
- expect(true).toBeTruthy();
- }
- });
- /**
- * 场景6:审核管家申请
- * 角色:管理员
- * 触发条件:选择待审核管家,点击通过
- * 校验:审核成功,状态变为已开通
- */
- test('[场景6] 审核管家申请 — 期望通过成功', async ({ page }) => {
- await page.goto('http://cfc.iwintrue.com/admin/review-center');
- await page.waitForLoadState('networkidle');
- // 切换到管家审核 tab
- const butlerTab = page.locator('.nav-item:has-text("管家审核"), .tab-item:has-text("管家")');
- await butlerTab.click();
- await page.waitForTimeout(1000);
- // 查找待审核管家
- const pendingButlers = page.locator('.el-table__row:has-text("待审核")');
- const butlerCount = await pendingButlers.count();
- if (butlerCount > 0) {
- // 点击通过按钮
- const approveBtn = pendingButlers.first().locator('button:has-text("通过")');
- await approveBtn.click();
- await page.waitForTimeout(500);
- // 提交
- const submitBtn = page.locator('.el-dialog__footer button:has-text("确定"), button.el-button--primary');
- await submitBtn.click();
- await page.waitForTimeout(1000);
- // 验证提示
- const successTip = page.locator('.toast-success, text="审核通过"');
- expect(await successTip.isVisible().catch(() => false)).toBeTruthy();
- } else {
- // 无待审核管家,跳过
- expect(true).toBeTruthy();
- }
- });
- /**
- * 场景7:查看审核记录
- * 角色:管理员
- * 触发条件:切换到审核记录 tab
- * 校验:记录加载正常
- */
- test('[场景7] 查看审核记录 — 期望加载正常', async ({ page }) => {
- await page.goto('http://cfc.iwintrue.com/admin/review-center');
- await page.waitForLoadState('networkidle');
- // 切换到审核记录 tab
- const recordTab = page.locator('.nav-item:has-text("审核记录"), .tab-item:has-text("记录")');
- await recordTab.click();
- await page.waitForTimeout(1000);
- // 验证记录加载
- const records = page.locator('.el-table__row, .review-record');
- const recordCount = await records.count();
- expect(recordCount).toBeGreaterThanOrEqual(0);
- // 验证记录包含关键字段(类型/操作人/时间/状态)
- if (recordCount > 0) {
- const firstRecord = records.first();
- const cells = firstRecord.locator('.el-table__cell');
- expect(await cells.count()).toBeGreaterThanOrEqual(5);
- }
- });
- /**
- * 场景8:审核中心统计概览
- * 角色:管理员
- * 触发条件:进入审核中心首页
- * 校验:统计数据加载正常
- */
- test('[场景8] 审核中心统计概览 — 期望数据加载', async ({ page }) => {
- await page.goto('http://cfc.iwintrue.com/admin/review-center');
- await page.waitForLoadState('networkidle');
- // 验证统计卡片加载
- const statCards = page.locator('.stat-card, .summary-card, .overview-card');
- const cardCount = await statCards.count();
- expect(cardCount).toBeGreaterThanOrEqual(3);
- // 验证各类型待审核数量
- const pendingCount = page.locator('.pending-count, .review-count');
- expect(await pendingCount.isVisible()).toBeTruthy();
- });
- });
|