Forráskód Böngészése

test:fix admin routes in E2E tests to use http://cfc.iwintrue.com/admin/login

Sisyphus Agent 2 hónapja
szülő
commit
ad4c51b7bd

+ 5 - 6
tests/e2e/admin-butler-review.spec.js

@@ -36,13 +36,12 @@ const { test, expect } = require('@playwright/test');
 test.describe('【场景流程】管家审核流程', () => {
 
   test.beforeEach(async ({ page }) => {
-    // 管理员登录
-    await page.goto('/#/pages/login/admin');
+    // 管理员登录(admin 后台)
+    await page.goto('http://cfc.iwintrue.com/admin/login');
     await page.waitForLoadState('networkidle');
 
     const adminPhone = '13701366188';  // 已验证的管理员账号
-    const phoneInput = page.locator('input[placeholder="手机号"]');
-    await page.waitForTimeout(1000);
+    const phoneInput = page.locator('input[placeholder="请输入手机号"]');
     await phoneInput.fill(adminPhone);
 
     await page.locator('.login-btn, button:has-text("登录")').click();
@@ -53,8 +52,8 @@ test.describe('【场景流程】管家审核流程', () => {
       await page.waitForSelector('.admin-tab, .admin-menu, .admin-layout', { timeout: 10000 });
     } catch (e) {
       // 跳过重复登录
-      if (await page.url().includes('?login=verify')) {
-        await page.goto('/#/pages/admin/butler-review');
+      if (await page.url().includes('/login')) {
+        await page.goto('http://cfc.iwintrue.com/admin/butler-review');
         await page.waitForLoadState('networkidle');
       }
     }

+ 86 - 0
tests/e2e/family-earnings-flow.spec.js

@@ -157,4 +157,90 @@ test.describe('【场景流程】家庭收益管理流程', () => {
     const records = page.locator('.record-item, .earnings-record');
     expect(await records.first().isVisible().catch(() => false)).toBeTruthy();
   });
+
+  /**
+   * 场景5:管理员视角 — 家庭收益管理
+   * 角色:管理员
+   * 触发条件:进入后台家庭收益管理页面
+   * 校验:查看家庭列表和收益记录
+   */
+  test('[场景5] 管理员管理家庭收益', async ({ page }) => {
+    // 管理员登录(admin 后台)
+    await page.goto('http://cfc.iwintrue.com/admin/login');
+    await page.waitForTimeout(1000);
+
+    const adminPhone = '13701366188';
+    await page.locator('input[placeholder="请输入手机号"]').fill(adminPhone);
+    await page.locator('button:has-text("登录")').click();
+    await page.waitForTimeout(2000);
+
+    // 进入家庭收益管理
+    await page.goto('http://cfc.iwintrue.com/admin/family-earnings');
+    await page.waitForLoadState('networkidle');
+
+    // 验证家庭列表加载
+    const familyRows = page.locator('.el-table__row, .family-row');
+    expect(await familyRows.count()).toBeGreaterThanOrEqual(0);
+
+    // 点击查看详情
+    if (await familyRows.count() > 0) {
+      const firstRow = familyRows.first();
+      const viewBtn = firstRow.locator('button:has-text("查看")');
+      await viewBtn.click();
+      await page.waitForTimeout(500);
+
+      // 验证概览数据加载
+      const summaryData = page.locator('.summary-card, .earnings-summary');
+      expect(await summaryData.isVisible()).toBeTruthy();
+
+      // 查看收益记录
+      const recordTab = page.locator('.tab-item:has-text("收益记录")');
+      await recordTab.click();
+      await page.waitForTimeout(500);
+
+      const recordRows = page.locator('.el-table__row, .record-row');
+      expect(await recordRows.count()).toBeGreaterThanOrEqual(0);
+    }
+  });
+
+  /**
+   * 场景6:提现申请审核流程
+   * 角色:管理员
+   * 触发条件:进入后台提现审核页面
+   * 校验:能查看待审核记录并操作
+   */
+  test('[场景6] 提现申请审核', async ({ page }) => {
+    // 管理员登录(admin 后台)
+    await page.goto('http://cfc.iwintrue.com/admin/login');
+    await page.locator('input[placeholder="请输入手机号"]').fill('13701366188');
+    await page.locator('button:has-text("登录")').click();
+    await page.waitForTimeout(2000);
+
+    // 进入提现审核
+    await page.goto('http://cfc.iwintrue.com/admin/family-earnings/withdraw');
+    await page.waitForLoadState('networkidle');
+
+    // 验证待审核记录加载
+    const withdrawRows = page.locator('.el-table__row, .withdraw-row');
+    const rowCount = await withdrawRows.count();
+
+    if (rowCount > 0) {
+      // 审核通过第一条
+      const approveBtn = withdrawRows.first().locator('button:has-text("通过")');
+      await approveBtn.click();
+      await page.waitForTimeout(500);
+
+      // 提交
+      const submitBtn = page.locator('.confirm-btn, .el-button--primary');
+      await submitBtn.click();
+      await page.waitForTimeout(1000);
+
+      // 验证提示
+      const successTip = page.locator('.modal-success, .toast-success');
+      expect(await successTip.isVisible().catch(() => false)).toBeTruthy();
+    } else {
+      // 无待审核记录,跳过
+      expect(true).toBeTruthy();
+    }
+  });
 });