|
|
@@ -961,286 +961,4 @@ test.describe('订单人员关联测试', () => {
|
|
|
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();
|
|
|
- });
|
|
|
- });
|
|
|
});
|