| 1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798991001011021031041051061071081091101111121131141151161171181191201211221231241251261271281291301311321331341351361371381391401411421431441451461471481491501511521531541551561571581591601611621631641651661671681691701711721731741751761771781791801811821831841851861871881891901911921931941951961971981992002012022032042052062072082092102112122132142152162172182192202212222232242252262272282292302312322332342352362372382392402412422432442452462472482492502512522532542552562572582592602612622632642652662672682692702712722732742752762772782792802812822832842852862872882892902912922932942952962972982993003013023033043053063073083093103113123133143153163173183193203213223233243253263273283293303313323333343353363373383393403413423433443453463473483493503513523533543553563573583593603613623633643653663673683693703713723733743753763773783793803813823833843853863873883893903913923933943953963973983994004014024034044054064074084094104114124134144154164174184194204214224234244254264274284294304314324334344354364374384394404414424434444454464474484494504514524534544554564574584594604614624634644654664674684694704714724734744754764774784794804814824834844854864874884894904914924934944954964974984995005015025035045055065075085095105115125135145155165175185195205215225235245255265275285295305315325335345355365375385395405415425435445455465475485495505515525535545555565575585595605615625635645655665675685695705715725735745755765775785795805815825835845855865875885895905915925935945955965975985996006016026036046056066076086096106116126136146156166176186196206216226236246256266276286296306316326336346356366376386396406416426436446456466476486496506516526536546556566576586596606616626636646656666676686696706716726736746756766776786796806816826836846856866876886896906916926936946956966976986997007017027037047057067077087097107117127137147157167177187197207217227237247257267277287297307317327337347357367377387397407417427437447457467477487497507517527537547557567577587597607617627637647657667677687697707717727737747757767777787797807817827837847857867877887897907917927937947957967977987998008018028038048058068078088098108118128138148158168178188198208218228238248258268278288298308318328338348358368378388398408418428438448458468478488498508518528538548558568578588598608618628638648658668678688698708718728738748758768778788798808818828838848858868878888898908918928938948958968978988999009019029039049059069079089099109119129139149159169179189199209219229239249259269279289299309319329339349359369379389399409419429439449459469479489499509519529539549559569579589599609619629639649659669679689699709719729739749759769779789799809819829839849859869879889899909919929939949959969979989991000100110021003100410051006100710081009101010111012101310141015101610171018101910201021102210231024102510261027102810291030103110321033103410351036103710381039104010411042104310441045104610471048104910501051105210531054105510561057105810591060106110621063106410651066106710681069107010711072107310741075107610771078107910801081108210831084108510861087108810891090109110921093109410951096109710981099110011011102110311041105110611071108110911101111111211131114111511161117111811191120112111221123112411251126112711281129113011311132113311341135113611371138113911401141114211431144114511461147114811491150115111521153115411551156115711581159116011611162116311641165116611671168116911701171117211731174117511761177117811791180118111821183118411851186118711881189119011911192119311941195119611971198119912001201120212031204120512061207120812091210121112121213121412151216121712181219122012211222122312241225122612271228122912301231123212331234123512361237123812391240124112421243124412451246 |
- import { test, expect } from '../../utils/test-setup';
- import { readFileSync } from 'fs';
- import { join, dirname } from 'path';
- import { fileURLToPath } from 'url';
- import type { Page } from '@playwright/test';
- const __filename = fileURLToPath(import.meta.url);
- const __dirname = dirname(__filename);
- const testUsers = JSON.parse(readFileSync(join(__dirname, '../../fixtures/test-users.json'), 'utf-8'));
- // 存储 API 创建的测试数据
- let createdPersonName: string | null = null;
- let createdPlatformName: string | null = null;
- let createdCompanyName: string | null = null;
- // 获取认证 token
- async function getAuthToken(request: Parameters<typeof test>[0]['request']): Promise<string | null> {
- const loginResponse = await request.post('http://localhost:8080/api/v1/auth/login', {
- data: {
- username: testUsers.admin.username,
- password: testUsers.admin.password
- }
- });
- if (!loginResponse.ok()) {
- console.debug('API 登录失败:', await loginResponse.text());
- return null;
- }
- const loginData = await loginResponse.json();
- return loginData.data?.token || loginData.token || null;
- }
- // API 调用辅助函数 - 使用 API 直接创建残疾人数据
- async function createDisabledPersonViaAPI(
- request: Parameters<typeof test>[0]['request'],
- personData: {
- name: string;
- gender: string;
- idCard: string;
- disabilityId: string;
- disabilityType: string;
- disabilityLevel: string;
- idAddress: string;
- phone: string;
- province: string;
- city: string;
- }
- ): Promise<{ id: number; name: string } | null> {
- try {
- const token = await getAuthToken(request);
- if (!token) return null;
- const createResponse = await request.post('http://localhost:8080/api/v1/disability/createDisabledPerson', {
- headers: {
- 'Authorization': `Bearer ${token}`,
- 'Content-Type': 'application/json'
- },
- data: personData
- });
- if (!createResponse.ok()) {
- const errorText = await createResponse.text();
- console.debug('API 创建残疾人失败:', createResponse.status(), errorText);
- return null;
- }
- const result = await createResponse.json();
- console.debug('API 创建残疾人成功:', result.name);
- return { id: result.id, name: result.name };
- } catch (error) {
- console.debug('API 调用出错:', error);
- return null;
- }
- }
- // 创建测试平台
- async function createPlatformViaAPI(
- request: Parameters<typeof test>[0]['request']
- ): Promise<{ id: number; name: string } | null> {
- try {
- const token = await getAuthToken(request);
- if (!token) return null;
- const timestamp = Date.now();
- const platformData = {
- platformName: `测试平台_${timestamp}`,
- contactPerson: '测试联系人',
- contactPhone: '13800138000',
- contactEmail: 'test@example.com'
- };
- const createResponse = await request.post('http://localhost:8080/api/v1/platform/createPlatform', {
- headers: {
- 'Authorization': `Bearer ${token}`,
- 'Content-Type': 'application/json'
- },
- data: platformData
- });
- if (!createResponse.ok()) {
- const errorText = await createResponse.text();
- console.debug('API 创建平台失败:', createResponse.status(), errorText);
- return null;
- }
- const result = await createResponse.json();
- console.debug('API 创建平台成功:', result.id, result.platformName);
- return { id: result.id, name: result.platformName };
- } catch (error) {
- console.debug('创建平台 API 调用出错:', error);
- return null;
- }
- }
- // 创建测试公司
- async function createCompanyViaAPI(
- request: Parameters<typeof test>[0]['request'],
- platformId: number
- ): Promise<{ id: number; name: string } | null> {
- try {
- const token = await getAuthToken(request);
- if (!token) return null;
- const timestamp = Date.now();
- const companyName = `测试公司_${timestamp}`;
- const companyData = {
- companyName: companyName,
- platformId: platformId,
- contactPerson: '测试联系人',
- contactPhone: '13900139000',
- contactEmail: 'company@example.com'
- };
- const createResponse = await request.post('http://localhost:8080/api/v1/company/createCompany', {
- headers: {
- 'Authorization': `Bearer ${token}`,
- 'Content-Type': 'application/json'
- },
- data: companyData
- });
- if (!createResponse.ok()) {
- const errorText = await createResponse.text();
- console.debug('API 创建公司失败:', createResponse.status(), errorText);
- return null;
- }
- const createResult = await createResponse.json();
- if (!createResult.success) {
- console.debug('API 创建公司返回 success=false');
- return null;
- }
- // 创建成功后,通过平台ID查询公司列表来获取公司ID
- const listResponse = await request.get(`http://localhost:8080/api/v1/company/getCompaniesByPlatform/${platformId}`, {
- headers: {
- 'Authorization': `Bearer ${token}`
- }
- });
- if (!listResponse.ok()) {
- console.debug('API 获取公司列表失败');
- return null;
- }
- const companies = await listResponse.json();
- const createdCompany = companies.find((c: any) => c.companyName === companyName);
- if (createdCompany) {
- console.debug('API 创建公司成功:', createdCompany.id, createdCompany.companyName);
- return { id: createdCompany.id, name: createdCompany.companyName };
- }
- console.debug('未找到创建的公司');
- return null;
- } catch (error) {
- console.debug('创建公司 API 调用出错:', error);
- return null;
- }
- }
- async function selectDisabledPersonInAddDialog(
- page: Page,
- personName?: string
- ): Promise<boolean> {
- // 监听控制台消息
- page.on('console', msg => {
- console.log('[浏览器控制台]', msg.text());
- });
- const selectPersonButton = page.getByRole('button', { name: '选择残疾人' });
- await selectPersonButton.click();
- // 检查测试标志是否设置
- const testFlag = await page.evaluate(() => (window as any).__PLAYWRIGHT_TEST__);
- console.log('测试标志 __PLAYWRIGHT_TEST__:', testFlag);
- // 使用唯一的 test ID 精确定位残疾人选择对话框
- const dialog = page.getByTestId('disabled-person-selector-dialog');
- // 测试环境:组件会自动选中第一个残疾人并确认,只需等待对话框关闭
- console.log('等待残疾人选择器对话框自动关闭...');
- // 等待对话框消失(自动选择后会关闭)
- await dialog.waitFor({ state: 'hidden', timeout: 10000 });
- console.log('残疾人选择器对话框已关闭');
- // 等待一下让状态同步
- await page.waitForTimeout(500);
- return true;
- }
- // 全局计数器,确保每个测试生成唯一的数据
- let testDataCounter = 0;
- function generateUniqueTestData() {
- const timestamp = Date.now();
- const counter = ++testDataCounter;
- const random = Math.floor(Math.random() * 10000);
- // 生成18位身份证号:110101(地区码6位) + 19900101(出生日期8位) + XXX(顺序码3位) + X(校验码1位)
- // 使用计数器和随机数作为顺序码,确保唯一性
- const sequenceCode = String(counter).padStart(2, '0') + String(random).slice(0, 1);
- const idCard = '110101' + '19900101' + sequenceCode + '1'; // 6+8+3+1=18位
- return {
- orderName: '测试订单_' + timestamp + '_' + counter + '_' + random,
- personName: '测试残疾人_' + timestamp + '_' + counter + '_' + random,
- // 18位身份证号
- idCard,
- phone: '138' + String(counter).padStart(4, '0') + String(random).padStart(4, '0'),
- gender: '男',
- disabilityType: '视力残疾',
- disabilityLevel: '一级',
- disabilityId: '残疾证' + sequenceCode + String(timestamp).slice(-6),
- idAddress: '北京市东城区测试地址' + timestamp + '_' + counter,
- province: '北京市',
- city: '北京市',
- hireDate: '2025-01-15',
- salary: 5000,
- };
- }
- // 等待订单行出现在表格中
- async function waitForOrderRow(page: Page, orderName: string, timeout = 15000) {
- const startTime = Date.now();
- while (Date.now() - startTime < timeout) {
- const table = page.locator('table');
- const orderRow = table.locator('tbody tr').filter({ hasText: orderName });
- const count = await orderRow.count();
- if (count > 0) {
- console.debug('找到订单行:', orderName);
- return true;
- }
- await page.waitForTimeout(500);
- }
- console.debug('等待订单行超时:', orderName);
- return false;
- }
- test.describe('订单人员关联测试', () => {
- test.beforeAll(async ({}) => {
- // 注意:beforeAll 中无法访问 page,所以通过 playwright.config.ts 的 initScripts 设置
- // 这里只是文档说明
- });
- test.beforeEach(async ({ adminLoginPage, orderManagementPage, request, page }) => {
- // 登录
- await adminLoginPage.goto();
- await adminLoginPage.login(testUsers.admin.username, testUsers.admin.password);
- await adminLoginPage.expectLoginSuccess();
- await orderManagementPage.goto();
- // 使用 API 创建平台和公司测试数据
- const createdPlatform = await createPlatformViaAPI(request);
- if (!createdPlatform) {
- console.debug('无法创建平台数据,测试可能被跳过');
- createdPlatformName = null;
- } else {
- createdPlatformName = createdPlatform.name;
- }
- if (createdPlatform) {
- const createdCompany = await createCompanyViaAPI(request, createdPlatform.id);
- if (!createdCompany) {
- console.debug('无法创建公司数据,测试可能被跳过');
- createdCompanyName = null;
- } else {
- createdCompanyName = createdCompany.name;
- }
- }
- // 使用 API 创建残疾人测试数据
- const timestamp = Date.now();
- const random = Math.floor(Math.random() * 10000);
- const personName = `测试残疾人_${timestamp}_${random}`;
- const personData = {
- name: personName,
- gender: '男',
- idCard: `110101199001011${String(random).padStart(4, '0')}`,
- disabilityId: `CJZ${timestamp}${random}`,
- disabilityType: '视力残疾',
- disabilityLevel: '一级',
- idAddress: '北京市东城区测试地址',
- phone: `138${String(random).padStart(8, '0')}`,
- province: '北京市',
- city: '北京市'
- };
- const createdPerson = await createDisabledPersonViaAPI(request, personData);
- if (!createdPerson) {
- console.debug('无法创建残疾人数据,测试可能被跳过');
- createdPersonName = null;
- } else {
- createdPersonName = createdPerson.name;
- console.debug('已创建残疾人:', createdPersonName, 'ID:', createdPerson.id);
- }
- });
- test.describe('添加人员到订单', () => {
- test('应该能打开订单人员管理对话框', async ({ orderManagementPage }) => {
- if (!createdPersonName || !createdPlatformName || !createdCompanyName) {
- test.skip(true, '缺少测试数据(残疾人、平台或公司)');
- return;
- }
- const testData = generateUniqueTestData();
- await orderManagementPage.openCreateDialog();
- await orderManagementPage.page.getByLabel(/订单名称|名称/).fill(testData.orderName);
- // 选择平台
- const platformTrigger = orderManagementPage.page.locator('[data-testid="platform-selector-create"]');
- if (await platformTrigger.count() > 0) {
- await platformTrigger.click();
- await orderManagementPage.page.waitForTimeout(800);
- const allOptions = orderManagementPage.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 orderManagementPage.page.waitForTimeout(200);
- } else {
- console.debug('平台选择器未找到,跳过平台选择');
- }
- // 选择公司
- const companyTrigger = orderManagementPage.page.locator('[data-testid="company-selector-create"]');
- if (await companyTrigger.count() > 0) {
- await companyTrigger.click();
- await orderManagementPage.page.waitForTimeout(800);
- const allCompanyOptions = orderManagementPage.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 orderManagementPage.page.waitForTimeout(200);
- } else {
- console.debug('公司选择器未找到,跳过公司选择');
- }
- await orderManagementPage.page.getByLabel(/预计开始日期|开始日期/).fill('2025-01-15');
- const hasPerson = await selectDisabledPersonInAddDialog(orderManagementPage.page, createdPersonName);
- if (!hasPerson) {
- await orderManagementPage.cancelDialog();
- test.skip(true, '没有可用的残疾人数据');
- return;
- }
- // 等待残疾人选择对话框关闭,检查是否显示了已选人员
- // 状态更新是异步的,需要等待更长时间
- await orderManagementPage.page.waitForTimeout(2000);
- // 尝试多种方式定位徽章
- const selectedPersonsBadges = orderManagementPage.page.locator('[class*="badge"]').filter({ hasText: createdPersonName });
- const badgeCount = await selectedPersonsBadges.count();
- console.debug('已选人员徽章数量:', badgeCount);
- // 如果徽章数量为 0,尝试检查文本内容
- if (badgeCount === 0) {
- const allText = await orderManagementPage.page.locator('.w-full.overflow-y-auto').textContent();
- console.debug('对话框内容包含姓名:', allText?.includes(createdPersonName));
- }
- // 检查提交按钮是否存在且可点击
- const submitButton = orderManagementPage.page.getByRole('button', { name: /^(创建|更新|保存)$/ });
- const submitButtonCount = await submitButton.count();
- console.debug('提交按钮数量:', submitButtonCount);
- if (submitButtonCount === 0) {
- console.debug('提交按钮未找到,尝试查找所有按钮');
- const allButtons = orderManagementPage.page.locator('button').all();
- console.debug('页面按钮总数:', await orderManagementPage.page.locator('button').count());
- }
- await orderManagementPage.submitForm();
- await orderManagementPage.waitForDialogClosed();
- // 检查是否有错误或成功 Toast
- await orderManagementPage.page.waitForTimeout(1000);
- const errorToast = orderManagementPage.page.locator('[data-sonner-toast][data-type="error"]');
- const successToast = orderManagementPage.page.locator('[data-sonner-toast][data-type="success"]');
- const hasError = await errorToast.count() > 0;
- const hasSuccess = await successToast.count() > 0;
- if (hasError) {
- const errorMsg = await errorToast.first().textContent();
- console.debug('表单提交错误:', errorMsg);
- test.skip(true, '订单创建失败: ' + errorMsg);
- return;
- }
- if (!hasSuccess) {
- console.debug('没有成功 Toast,订单可能未创建');
- } else {
- const successMsg = await successToast.first().textContent();
- console.debug('订单创建成功:', successMsg);
- }
- // 等待订单行出现在表格中
- const orderFound = await waitForOrderRow(orderManagementPage.page, testData.orderName);
- if (!orderFound) {
- test.skip(true, '订单未创建成功,无法继续测试');
- return;
- }
- // 第一个测试只验证订单创建成功,人员管理功能在其他测试中验证
- // 订单列表中没有"人员"按钮,需要先打开订单详情
- });
- 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);
- // 使用 first() 因为有两个"添加人员"按钮(卡片中+底部)
- const addButton = page.getByRole('button', { name: /添加人员|新增人员/ }).first();
- await addButton.click();
- await page.waitForTimeout(300);
- // 等待残疾人选择对话框打开
- const dialog = page.getByTestId('disabled-person-selector-dialog');
- await dialog.waitFor({ state: 'visible', timeout: 5000 });
- // 等待自动选择完成(通过检查待添加人员数量)
- // 使用 test-id 检查待添加人员列表
- const pendingPersonsDebug = page.getByTestId('pending-persons-debug');
- await pendingPersonsDebug.waitFor({ state: 'attached', timeout: 10000 });
- // 检查待添加人员数量
- const pendingData = await pendingPersonsDebug.textContent();
- console.log('待添加人员数据:', pendingData);
- // 关闭残疾人选择对话框
- await page.keyboard.press('Escape');
- await dialog.waitFor({ state: 'hidden', timeout: 5000 });
- // 点击"确认添加"按钮批量添加人员
- const confirmButton = page.getByTestId('confirm-add-persons-button');
- await confirmButton.click();
- // 等待成功 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.openDetailDialog(testData.orderName);
- const personList = await orderManagementPage.getPersonListFromDetail();
- expect(personList.length).toBeGreaterThan(0);
- await orderManagementPage.closeDetailDialog();
- });
- });
- test.describe('管理工作状态', () => {
- test('应该能修改人员工作状态:未就业 → 待就业', async ({ orderManagementPage, page, request }) => {
- if (!createdPlatformName || !createdCompanyName) {
- test.skip(true, '缺少测试数据(平台或公司)');
- return;
- }
- // 为此测试创建唯一的残疾人数据
- const testData = generateUniqueTestData();
- const personData = {
- name: testData.personName,
- gender: testData.gender,
- idCard: testData.idCard,
- disabilityId: testData.disabilityId,
- disabilityType: testData.disabilityType,
- disabilityLevel: testData.disabilityLevel,
- idAddress: testData.idAddress,
- phone: testData.phone,
- province: testData.province,
- city: testData.city,
- };
- const createdPerson = await createDisabledPersonViaAPI(request, personData);
- if (!createdPerson) {
- test.skip(true, '无法创建残疾人数据');
- return;
- }
- console.debug('已创建残疾人:', createdPerson.name, 'ID:', createdPerson.id);
- 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, createdPerson.name);
- if (!hasPerson) {
- await orderManagementPage.cancelDialog();
- test.skip(true, '没有可用的残疾人数据');
- return;
- }
- await orderManagementPage.submitForm();
- await orderManagementPage.waitForDialogClosed();
- await orderManagementPage.openPersonManagementDialog(testData.orderName);
- // 等待订单详情对话框加载完成
- await page.waitForTimeout(500);
- // 监听网络响应以捕获 400 错误的详细信息
- const apiResponses: any[] = [];
- page.on('response', async (response) => {
- if (response.status() === 400) {
- const url = response.url();
- const contentType = response.headers()['content-type'];
- if (contentType && contentType.includes('application/json')) {
- try {
- const body = await response.json();
- apiResponses.push({ url, status: response.status(), body });
- console.debug('API 400 错误详情:', JSON.stringify(body, null, 2));
- } catch (e) {
- const text = await response.text();
- apiResponses.push({ url, status: response.status(), body: text });
- console.debug('API 400 错误详情:', text);
- }
- }
- }
- });
- // 获取实际绑定的人员列表,使用第一个人员的名称
- const personList = await orderManagementPage.getPersonListFromDetail();
- await orderManagementPage.updatePersonWorkStatus(personList[0].name, 'pre_working');
- // 如果有 400 错误,打印详细信息
- if (apiResponses.length > 0) {
- console.debug('捕获到的 API 错误:', JSON.stringify(apiResponses, null, 2));
- }
- 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, request }) => {
- if (!createdPlatformName || !createdCompanyName) {
- test.skip(true, '缺少测试数据(平台或公司)');
- return;
- }
- // 为此测试创建唯一的残疾人数据
- const testData = generateUniqueTestData();
- const personData = {
- name: testData.personName,
- gender: testData.gender,
- idCard: testData.idCard,
- disabilityId: testData.disabilityId,
- disabilityType: testData.disabilityType,
- disabilityLevel: testData.disabilityLevel,
- idAddress: testData.idAddress,
- phone: testData.phone,
- province: testData.province,
- city: testData.city,
- };
- const createdPerson = await createDisabledPersonViaAPI(request, personData);
- if (!createdPerson) {
- test.skip(true, '无法创建残疾人数据');
- return;
- }
- console.debug('已创建残疾人:', createdPerson.name, 'ID:', createdPerson.id);
- 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, createdPerson.name);
- 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();
- await orderManagementPage.updatePersonWorkStatus(personList[0].name, 'working');
- 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, request }) => {
- if (!createdPlatformName || !createdCompanyName) {
- test.skip(true, '缺少测试数据(平台或公司)');
- return;
- }
- // 为此测试创建唯一的残疾人数据
- const testData = generateUniqueTestData();
- const personData = {
- name: testData.personName,
- gender: testData.gender,
- idCard: testData.idCard,
- disabilityId: testData.disabilityId,
- disabilityType: testData.disabilityType,
- disabilityLevel: testData.disabilityLevel,
- idAddress: testData.idAddress,
- phone: testData.phone,
- province: testData.province,
- city: testData.city,
- };
- const createdPerson = await createDisabledPersonViaAPI(request, personData);
- if (!createdPerson) {
- test.skip(true, '无法创建残疾人数据');
- return;
- }
- console.debug('已创建残疾人:', createdPerson.name, 'ID:', createdPerson.id);
- 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, createdPerson.name);
- 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();
- await orderManagementPage.updatePersonWorkStatus(personList[0].name, 'resigned');
- 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 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();
- });
- });
- });
|