Sfoglia il codice sorgente

test(e2e): 继续 order-person 测试修复 - updatePersonWorkStatus 方法

- 修改 updatePersonWorkStatus 使用正确的表格定位方式
- 通过索引选择第二个表格(绑定人员列表)
- 使用列索引定位工作状态选择器

Generated with [Claude Code](https://claude.ai/code)
via [Happy](https://happy.engineering)

Co-Authored-By: Claude <noreply@anthropic.com>
Co-Authored-By: Happy <yesreply@happy.engineering>
yourname 5 giorni fa
parent
commit
ee86e76cfb

+ 25 - 12
web/tests/e2e/pages/admin/order-management.page.ts

@@ -920,24 +920,37 @@ export class OrderManagementPage {
    * @param newStatus 新的工作状态
    */
   async updatePersonWorkStatus(personName: string, newStatus: WorkStatus) {
-    // 找到人员行
-    const personRow = this.page.locator('[role="dialog"]').locator('table tbody tr').filter({ hasText: personName });
+    const dialog = this.page.locator('[role="dialog"]');
+
+    // 找到所有表格,选择第二个表格(绑定人员列表)
+    // 第一个表格是待添加人员列表,第二个是绑定人员列表
+    const allTables = await dialog.locator('table').all();
+    const boundPersonsTable = allTables[1]; // 第二个表格
+
+    // 在该表格中找到包含人员姓名的行
+    const allRows = boundPersonsTable.locator('tbody tr');
+    const targetRow = allRows.filter({ hasText: personName });
+
+    // 工作状态在倒数第二列(最后一列是薪资)
+    const cells = targetRow.locator('td');
+    const cellCount = await cells.count();
+
+    // 工作状态是倒数第二列(索引 cellCount - 2)
+    const workStatusCell = cells.nth(cellCount - 2);
+    const workStatusSelect = workStatusCell.locator('[role="combobox"]');
+
+    await workStatusSelect.click();
 
-    // 点击编辑工作状态按钮
-    const editButton = personRow.getByRole('button', { name: /编辑|修改/ });
-    await editButton.click();
+    // 等待下拉选项显示
     await this.page.waitForTimeout(300);
 
-    // 选择新的工作状态
+    // 使用中文标签选择选项
     const workStatusLabel = WORK_STATUS_LABELS[newStatus];
-    await selectRadixOption(this.page, '工作状态', workStatusLabel);
-
-    // 提交
-    const submitButton = this.page.getByRole('button', { name: /^(更新|保存|确定)$/ });
-    await submitButton.click();
+    const option = this.page.getByRole('option').filter({ hasText: workStatusLabel });
+    await option.click();
 
     await this.page.waitForLoadState('networkidle');
-    await this.page.waitForTimeout(1000);
+    await this.page.waitForTimeout(500);
   }
 
   // ===== 附件管理 =====

+ 7 - 2
web/tests/e2e/specs/admin/order-person.spec.ts

@@ -685,8 +685,13 @@ test.describe('订单人员关联测试', () => {
       await orderManagementPage.submitForm();
       await orderManagementPage.waitForDialogClosed();
       await orderManagementPage.openPersonManagementDialog(testData.orderName);
-      const initialPersonList = await orderManagementPage.getPersonListFromDetail();
-      await orderManagementPage.updatePersonWorkStatus(initialPersonList[0].name, 'pending');
+
+      // 等待订单详情对话框加载完成
+      await page.waitForTimeout(500);
+
+      // 直接使用 createdPersonName,因为我们知道创建订单时添加了这个人员
+      // 跳过 getPersonListFromDetail,直接使用已知的人员名称
+      await orderManagementPage.updatePersonWorkStatus(createdPersonName!, 'pending');
       const successToast = page.locator('[data-sonner-toast][data-type="success"]');
       const hasSuccess = await successToast.count() > 0;
       expect(hasSuccess).toBe(true);