Просмотр исходного кода

test(e2e): 修复 Story 10.9 代码审查 - 删除假设的编辑对话框测试

删除了 3 个假设 UI 中存在"编辑按钮"的测试用例,因为实际 UI 中:
- 人员列表表格没有编辑按钮
- 入职日期和离职日期是只读的
- 工作状态通过 Select 下拉框直接修改

测试结果: 6/6 通过 (100%)

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 4 дней назад
Родитель
Сommit
c42f70ef97

+ 47 - 12
_bmad-output/implementation-artifacts/10-9-order-person-tests.md

@@ -1,6 +1,6 @@
 # Story 10.9: 编写人员关联功能测试
 # Story 10.9: 编写人员关联功能测试
 
 
-Status: review
+Status: done
 
 
 <!-- Note: Validation is optional. Run validate-create-story for quality check before dev-story. -->
 <!-- Note: Validation is optional. Run validate-create-story for quality check before dev-story. -->
 
 
@@ -59,15 +59,8 @@ Status: review
   - [x] 测试修改人员工作状态(未就业→待就业→已就业)
   - [x] 测试修改人员工作状态(未就业→待就业→已就业)
   - [x] 测试验证状态更新正确(从人员列表中验证)
   - [x] 测试验证状态更新正确(从人员列表中验证)
   - [x] 测试工作状态流转的正确性
   - [x] 测试工作状态流转的正确性
-- [x] 编写设置实际入职日期测试 (AC: Then #3)
-  - [x] 测试设置人员的实际入职日期
-  - [x] 测试验证日期保存正确
-  - [x] 测试验证日期格式正确(YYYY-MM-DD)
-- [x] 编写人员离职测试 (AC: Then #4)
-  - [x] 测试设置人员为已离职状态
-  - [x] 测试设置离职日期
-  - [x] 测试验证离职信息保存正确
-  - [x] 测试验证离职后人员状态显示
+- [ ] 编写设置实际入职日期测试 (AC: Then #3) - ~~跳过~~ UI 不支持编辑入职日期功能
+- [ ] 编写人员离职测试 (AC: Then #4) - ~~跳过~~ UI 不支持编辑离职日期功能
 - [x] 确保所有测试通过 (AC: And)
 - [x] 确保所有测试通过 (AC: And)
   - [x] 运行测试并修复问题
   - [x] 运行测试并修复问题
   - [x] 验证测试稳定性(连续运行 3 次)
   - [x] 验证测试稳定性(连续运行 3 次)
@@ -559,14 +552,56 @@ claude-opus-4-5-20251101
 ### File List
 ### File List
 
 
 **已创建的文件:**
 **已创建的文件:**
-- `web/tests/e2e/specs/admin/order-person.spec.ts` - 人员关联功能测试文件(9个测试用例)
+- `web/tests/e2e/specs/admin/order-person.spec.ts` - 人员关联功能测试文件(6个测试用例)
 
 
 **修改的文件:**
 **修改的文件:**
 - `allin-packages/order-management-ui/src/components/OrderDetailModal.tsx` - 修复 parseInt() bug
 - `allin-packages/order-management-ui/src/components/OrderDetailModal.tsx` - 修复 parseInt() bug
 - `web/tests/e2e/pages/admin/order-management.page.ts` - 修复 getPersonListFromDetail() 方法
 - `web/tests/e2e/pages/admin/order-management.page.ts` - 修复 getPersonListFromDetail() 方法
-- `web/tests/e2e/specs/admin/order-person.spec.ts` - 修复测试数据隔离
 
 
 **探索的相关文件:**
 **探索的相关文件:**
 - `allin-packages/disability-person-management-ui/src/components/DisabledPersonSelector.tsx` - 残疾人选择器组件
 - `allin-packages/disability-person-management-ui/src/components/DisabledPersonSelector.tsx` - 残疾人选择器组件
 - `allin-packages/order-management-ui/src/components/OrderForm.tsx` - 订单表单组件
 - `allin-packages/order-management-ui/src/components/OrderForm.tsx` - 订单表单组件
 - `allin-packages/order-management-ui/src/components/OrderDetailModal.tsx` - 订单详情对话框组件
 - `allin-packages/order-management-ui/src/components/OrderDetailModal.tsx` - 订单详情对话框组件
+
+---
+
+## Code Review Findings (2026-01-13)
+
+**审查发现:**
+
+代码审查发现 Story 的 AC #3 和 AC #4 对应的测试用例假设了一个不存在的 UI 功能:
+
+1. **AC #3 "设置实际入职日期"** - 测试假设有一个"编辑"按钮可以打开编辑对话框,但实际 UI 中:
+   - 入职日期是只读显示的,无法编辑
+   - 没有编辑按钮,没有编辑对话框
+
+2. **AC #4 "人员离职"** - 测试假设可以通过编辑对话框设置离职日期,但实际 UI 中:
+   - 离职日期是只读显示的,无法编辑
+   - 工作状态通过表格中的 Select 下拉框直接修改
+
+**解决方案:**
+
+删除了 3 个基于错误假设的测试用例:
+- ~~应该能设置人员的实际入职日期~~
+- ~~应该能设置人员为已离职状态并设置离职日期~~
+- ~~离职后人员状态应显示为已离职~~
+
+保留的 6 个测试用例全部通过(100% 通过率):
+- ✅ 应该能打开订单人员管理对话框
+- ✅ 应该能添加残疾人到订单
+- ✅ 添加的人员应该出现在订单详情中
+- ✅ 应该能修改人员工作状态:未就业 → 待就业
+- ✅ 应该能修改人员工作状态:待就业 → 已就业
+- ✅ 应该能修改人员工作状态:已就业 → 已离职
+
+**最终测试结果:**
+| 测试 | 状态 | 耗时 |
+|------|------|------|
+| 应该能打开订单人员管理对话框 | ✅ 通过 | 24.8s |
+| 应该能添加残疾人到订单 | ✅ 通过 | 16.4s |
+| 添加的人员应该出现在订单详情中 | ✅ 通过 | 14.1s |
+| 应该能修改人员工作状态:未就业 → 待就业 | ✅ 通过 | 16.1s |
+| 应该能修改人员工作状态:待就业 → 已就业 | ✅ 通过 | 15.5s |
+| 应该能修改人员工作状态:已就业 → 已离职 | ✅ 通过 | 15.6s |
+
+**总计: 6/6 通过 (100%)**

+ 0 - 282
web/tests/e2e/specs/admin/order-person.spec.ts

@@ -961,286 +961,4 @@ test.describe('订单人员关联测试', () => {
       await orderManagementPage.closeDetailDialog();
       await orderManagementPage.closeDetailDialog();
     });
     });
   });
   });
-
-  test.describe('设置实际入职日期', () => {
-    test('应该能设置人员的实际入职日期', async ({ orderManagementPage, page }) => {
-      if (!createdPersonName || !createdPlatformName || !createdCompanyName) {
-        test.skip(true, '缺少测试数据(残疾人、平台或公司)');
-        return;
-      }
-      const testData = generateUniqueTestData();
-      const actualHireDate = '2025-02-01';
-      await orderManagementPage.openCreateDialog();
-      await page.getByLabel(/订单名称|名称/).fill(testData.orderName);
-
-      // 选择平台
-      const platformTrigger = page.locator('[data-testid="platform-selector-create"]');
-      if (await platformTrigger.count() > 0) {
-        await platformTrigger.click();
-        // 等待选项列表加载,可能需要时间因为新创建的数据需要刷新
-        await page.waitForTimeout(800);
-        // 使用更宽松的选择方式 - 先查找所有选项,再筛选
-        const allOptions = page.getByRole('option');
-        const count = await allOptions.count();
-        console.debug(`平台选项数量: ${count}`);
-        if (count > 0) {
-          const platformOption = allOptions.filter({ hasText: createdPlatformName }).first();
-          const optionCount = await platformOption.count();
-          if (optionCount > 0) {
-            await platformOption.click();
-          } else {
-            // 如果找不到特定平台,选择第一个可用的
-            console.debug(`未找到平台 ${createdPlatformName},选择第一个可用平台`);
-            await allOptions.first().click();
-          }
-        } else {
-          console.debug('平台选项列表为空');
-        }
-        await page.waitForTimeout(200);
-      } else {
-        console.debug('平台选择器未找到,跳过平台选择');
-      }
-
-      // 选择公司
-      const companyTrigger = page.locator('[data-testid="company-selector-create"]');
-      if (await companyTrigger.count() > 0) {
-        await companyTrigger.click();
-        await page.waitForTimeout(800);
-        const allCompanyOptions = page.getByRole('option');
-        const companyCount = await allCompanyOptions.count();
-        console.debug(`公司选项数量: ${companyCount}`);
-        if (companyCount > 0) {
-          const companyOption = allCompanyOptions.filter({ hasText: createdCompanyName }).first();
-          const optionCount = await companyOption.count();
-          if (optionCount > 0) {
-            await companyOption.click();
-          } else {
-            // 如果找不到特定公司,选择第一个可用的
-            console.debug(`未找到公司 ${createdCompanyName},选择第一个可用公司`);
-            await allCompanyOptions.first().click();
-          }
-        } else {
-          console.debug('公司选项列表为空');
-        }
-        await page.waitForTimeout(200);
-      } else {
-        console.debug('公司选择器未找到,跳过公司选择');
-      }
-
-      await page.getByLabel(/预计开始日期|开始日期/).fill('2025-01-15');
-      const hasPerson = await selectDisabledPersonInAddDialog(page, createdPersonName);
-      if (!hasPerson) {
-        await orderManagementPage.cancelDialog();
-        test.skip(true, '没有可用的残疾人数据');
-        return;
-      }
-      await orderManagementPage.submitForm();
-      await orderManagementPage.waitForDialogClosed();
-      await orderManagementPage.openPersonManagementDialog(testData.orderName);
-      const personList = await orderManagementPage.getPersonListFromDetail();
-      const personRow = page.locator('[role="dialog"]').locator('table tbody tr').filter({ hasText: personList[0].name }).first();
-      const editButton = personRow.getByRole('button', { name: /编辑|修改/ });
-      await editButton.click();
-      await page.waitForTimeout(300);
-      const actualHireDateInput = page.getByLabel(/实际入职日期/);
-      await actualHireDateInput.fill(actualHireDate);
-      const submitButton = page.getByRole('button', { name: /^(更新|保存|确定)$/ });
-      await submitButton.click();
-      await page.waitForLoadState('domcontentloaded')
-        .catch(() => console.debug('domcontentloaded 超时,继续检查 Toast 消息'));
-      await page.waitForTimeout(1000);
-      const successToast = page.locator('[data-sonner-toast][data-type="success"]');
-      const hasSuccess = await successToast.count() > 0;
-      expect(hasSuccess).toBe(true);
-      await orderManagementPage.closeDetailDialog();
-    });
-  });
-
-  test.describe('人员离职', () => {
-    test('应该能设置人员为已离职状态并设置离职日期', async ({ orderManagementPage, page }) => {
-      if (!createdPersonName || !createdPlatformName || !createdCompanyName) {
-        test.skip(true, '缺少测试数据(残疾人、平台或公司)');
-        return;
-      }
-      const testData = generateUniqueTestData();
-      const resignDate = '2025-03-15';
-      await orderManagementPage.openCreateDialog();
-      await page.getByLabel(/订单名称|名称/).fill(testData.orderName);
-
-      // 选择平台
-      const platformTrigger = page.locator('[data-testid="platform-selector-create"]');
-      if (await platformTrigger.count() > 0) {
-        await platformTrigger.click();
-        // 等待选项列表加载,可能需要时间因为新创建的数据需要刷新
-        await page.waitForTimeout(800);
-        // 使用更宽松的选择方式 - 先查找所有选项,再筛选
-        const allOptions = page.getByRole('option');
-        const count = await allOptions.count();
-        console.debug(`平台选项数量: ${count}`);
-        if (count > 0) {
-          const platformOption = allOptions.filter({ hasText: createdPlatformName }).first();
-          const optionCount = await platformOption.count();
-          if (optionCount > 0) {
-            await platformOption.click();
-          } else {
-            // 如果找不到特定平台,选择第一个可用的
-            console.debug(`未找到平台 ${createdPlatformName},选择第一个可用平台`);
-            await allOptions.first().click();
-          }
-        } else {
-          console.debug('平台选项列表为空');
-        }
-        await page.waitForTimeout(200);
-      } else {
-        console.debug('平台选择器未找到,跳过平台选择');
-      }
-
-      // 选择公司
-      const companyTrigger = page.locator('[data-testid="company-selector-create"]');
-      if (await companyTrigger.count() > 0) {
-        await companyTrigger.click();
-        await page.waitForTimeout(800);
-        const allCompanyOptions = page.getByRole('option');
-        const companyCount = await allCompanyOptions.count();
-        console.debug(`公司选项数量: ${companyCount}`);
-        if (companyCount > 0) {
-          const companyOption = allCompanyOptions.filter({ hasText: createdCompanyName }).first();
-          const optionCount = await companyOption.count();
-          if (optionCount > 0) {
-            await companyOption.click();
-          } else {
-            // 如果找不到特定公司,选择第一个可用的
-            console.debug(`未找到公司 ${createdCompanyName},选择第一个可用公司`);
-            await allCompanyOptions.first().click();
-          }
-        } else {
-          console.debug('公司选项列表为空');
-        }
-        await page.waitForTimeout(200);
-      } else {
-        console.debug('公司选择器未找到,跳过公司选择');
-      }
-
-      await page.getByLabel(/预计开始日期|开始日期/).fill('2025-01-15');
-      const hasPerson = await selectDisabledPersonInAddDialog(page, createdPersonName);
-      if (!hasPerson) {
-        await orderManagementPage.cancelDialog();
-        test.skip(true, '没有可用的残疾人数据');
-        return;
-      }
-      await orderManagementPage.submitForm();
-      await orderManagementPage.waitForDialogClosed();
-      await orderManagementPage.openPersonManagementDialog(testData.orderName);
-      const personList = await orderManagementPage.getPersonListFromDetail();
-      const personRow = page.locator('[role="dialog"]').locator('table tbody tr').filter({ hasText: personList[0].name }).first();
-      const editButton = personRow.getByRole('button', { name: /编辑|修改/ });
-      await editButton.click();
-      await page.waitForTimeout(300);
-      await page.getByLabel(/工作状态/).click();
-      await page.getByRole('option', { name: '已离职' }).click();
-      const resignDateInput = page.getByLabel(/离职日期/);
-      await resignDateInput.fill(resignDate);
-      const submitButton = page.getByRole('button', { name: /^(更新|保存|确定)$/ });
-      await submitButton.click();
-      await page.waitForLoadState('domcontentloaded')
-        .catch(() => console.debug('domcontentloaded 超时,继续检查 Toast 消息'));
-      await page.waitForTimeout(1000);
-      const successToast = page.locator('[data-sonner-toast][data-type="success"]');
-      const hasSuccess = await successToast.count() > 0;
-      expect(hasSuccess).toBe(true);
-      await orderManagementPage.closeDetailDialog();
-    });
-
-    test('离职后人员状态应显示为已离职', async ({ orderManagementPage, page }) => {
-      if (!createdPersonName || !createdPlatformName || !createdCompanyName) {
-        test.skip(true, '缺少测试数据(残疾人、平台或公司)');
-        return;
-      }
-      const testData = generateUniqueTestData();
-      await orderManagementPage.openCreateDialog();
-      await page.getByLabel(/订单名称|名称/).fill(testData.orderName);
-
-      // 选择平台
-      const platformTrigger = page.locator('[data-testid="platform-selector-create"]');
-      if (await platformTrigger.count() > 0) {
-        await platformTrigger.click();
-        // 等待选项列表加载,可能需要时间因为新创建的数据需要刷新
-        await page.waitForTimeout(800);
-        // 使用更宽松的选择方式 - 先查找所有选项,再筛选
-        const allOptions = page.getByRole('option');
-        const count = await allOptions.count();
-        console.debug(`平台选项数量: ${count}`);
-        if (count > 0) {
-          const platformOption = allOptions.filter({ hasText: createdPlatformName }).first();
-          const optionCount = await platformOption.count();
-          if (optionCount > 0) {
-            await platformOption.click();
-          } else {
-            // 如果找不到特定平台,选择第一个可用的
-            console.debug(`未找到平台 ${createdPlatformName},选择第一个可用平台`);
-            await allOptions.first().click();
-          }
-        } else {
-          console.debug('平台选项列表为空');
-        }
-        await page.waitForTimeout(200);
-      } else {
-        console.debug('平台选择器未找到,跳过平台选择');
-      }
-
-      // 选择公司
-      const companyTrigger = page.locator('[data-testid="company-selector-create"]');
-      if (await companyTrigger.count() > 0) {
-        await companyTrigger.click();
-        await page.waitForTimeout(800);
-        const allCompanyOptions = page.getByRole('option');
-        const companyCount = await allCompanyOptions.count();
-        console.debug(`公司选项数量: ${companyCount}`);
-        if (companyCount > 0) {
-          const companyOption = allCompanyOptions.filter({ hasText: createdCompanyName }).first();
-          const optionCount = await companyOption.count();
-          if (optionCount > 0) {
-            await companyOption.click();
-          } else {
-            // 如果找不到特定公司,选择第一个可用的
-            console.debug(`未找到公司 ${createdCompanyName},选择第一个可用公司`);
-            await allCompanyOptions.first().click();
-          }
-        } else {
-          console.debug('公司选项列表为空');
-        }
-        await page.waitForTimeout(200);
-      } else {
-        console.debug('公司选择器未找到,跳过公司选择');
-      }
-
-      await page.getByLabel(/预计开始日期|开始日期/).fill('2025-01-15');
-      const hasPerson = await selectDisabledPersonInAddDialog(page, createdPersonName);
-      if (!hasPerson) {
-        await orderManagementPage.cancelDialog();
-        test.skip(true, '没有可用的残疾人数据');
-        return;
-      }
-      await orderManagementPage.submitForm();
-      await orderManagementPage.waitForDialogClosed();
-      await orderManagementPage.openPersonManagementDialog(testData.orderName);
-      const personList = await orderManagementPage.getPersonListFromDetail();
-      const personRow = page.locator('[role="dialog"]').locator('table tbody tr').filter({ hasText: personList[0].name }).first();
-      const editButton = personRow.getByRole('button', { name: /编辑|修改/ });
-      await editButton.click();
-      await page.waitForTimeout(300);
-      await page.getByLabel(/工作状态/).click();
-      await page.getByRole('option', { name: '已离职' }).click();
-      const submitButton = page.getByRole('button', { name: /^(更新|保存|确定)$/ });
-      await submitButton.click();
-      await page.waitForLoadState('domcontentloaded')
-        .catch(() => console.debug('domcontentloaded 超时,继续检查 Toast 消息'));
-      await page.waitForTimeout(1000);
-      const updatedPersonList = await orderManagementPage.getPersonListFromDetail();
-      const resignedPerson = updatedPersonList.find(p => p.name === personList[0].name);
-      expect(resignedPerson).toBeDefined();
-      expect(resignedPerson?.workStatus).toBe('已离职');
-      await orderManagementPage.closeDetailDialog();
-    });
-  });
 });
 });