|
|
@@ -2,112 +2,247 @@ 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'));
|
|
|
|
|
|
-/**
|
|
|
- * 辅助函数:在创建订单对话框中选择残疾人
|
|
|
- * @param page Playwright Page 对象
|
|
|
- * @param personName 要选择的残疾人姓名(可选)
|
|
|
- * @returns 是否成功选择了残疾人
|
|
|
- */
|
|
|
-async function selectDisabledPersonForOrder(
|
|
|
- page: Parameters<typeof test>[0]['prototype'],
|
|
|
- personName?: string
|
|
|
-): Promise<boolean> {
|
|
|
- // 点击"选择残疾人"按钮
|
|
|
- const selectPersonButton = page.getByRole('button', { name: '选择残疾人' });
|
|
|
- await selectPersonButton.click();
|
|
|
+// 存储 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
|
|
|
+ }
|
|
|
+ });
|
|
|
|
|
|
- // 等待残疾人选择对话框出现
|
|
|
- await page.waitForSelector('[role="dialog"]', { state: 'visible', timeout: 5000 });
|
|
|
+ if (!loginResponse.ok()) {
|
|
|
+ console.debug('API 登录失败:', await loginResponse.text());
|
|
|
+ return null;
|
|
|
+ }
|
|
|
|
|
|
- // 等待数据加载
|
|
|
- await page.waitForTimeout(1000);
|
|
|
+ const loginData = await loginResponse.json();
|
|
|
+ return loginData.data?.token || loginData.token || null;
|
|
|
+}
|
|
|
|
|
|
- // 尝试选择残疾人
|
|
|
- let hasData = false;
|
|
|
+// 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 searchInput = page.locator('[role="dialog"] input[placeholder*="搜索"], [role="dialog"] input[placeholder*="姓名"], [role="dialog"] input[type="text"]').first();
|
|
|
- const hasSearch = await searchInput.count() > 0;
|
|
|
-
|
|
|
- if (hasSearch) {
|
|
|
- // 清空搜索框以显示所有数据
|
|
|
- await searchInput.click();
|
|
|
- await searchInput.clear();
|
|
|
- await page.waitForTimeout(500);
|
|
|
+ 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 checkboxSelectors = [
|
|
|
- '[role="dialog"] table tbody input[type="checkbox"]',
|
|
|
- '[role="dialog"] input[type="checkbox"]',
|
|
|
- '[role="dialog"] [role="checkbox"]',
|
|
|
- ];
|
|
|
+ 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;
|
|
|
+ }
|
|
|
+}
|
|
|
|
|
|
- for (const selector of checkboxSelectors) {
|
|
|
- const checkbox = page.locator(selector).first();
|
|
|
- const count = await checkbox.count();
|
|
|
- console.debug(`选择器 "${selector}" 找到 ${count} 个复选框`);
|
|
|
+// 创建测试平台
|
|
|
+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;
|
|
|
|
|
|
- if (count > 0) {
|
|
|
- // 检查复选框是否可见
|
|
|
- const isVisible = await checkbox.isVisible().catch(() => false);
|
|
|
- if (isVisible) {
|
|
|
- await checkbox.check();
|
|
|
- console.debug(`✓ 已选择残疾人(使用选择器: ${selector})`);
|
|
|
- hasData = true;
|
|
|
- break;
|
|
|
- }
|
|
|
- }
|
|
|
- }
|
|
|
+ const timestamp = Date.now();
|
|
|
+ const platformData = {
|
|
|
+ platformName: `测试平台_${timestamp}`,
|
|
|
+ contactPerson: '测试联系人',
|
|
|
+ contactPhone: '13800138000',
|
|
|
+ contactEmail: 'test@example.com'
|
|
|
+ };
|
|
|
|
|
|
- // 如果所有选择器都失败,尝试点击行来选择
|
|
|
- if (!hasData) {
|
|
|
- const tableBody = page.locator('[role="dialog"] table tbody');
|
|
|
- const rowCount = await tableBody.locator('tr').count();
|
|
|
- console.debug(`残疾人选择对话框中行数: ${rowCount}`);
|
|
|
-
|
|
|
- if (rowCount > 0) {
|
|
|
- const firstRow = tableBody.locator('tr').first();
|
|
|
- const noDataText = await firstRow.textContent();
|
|
|
- if (noDataText && noDataText.includes('暂无')) {
|
|
|
- console.debug('残疾人列表为空');
|
|
|
- } else {
|
|
|
- // 尝试点击第一行(某些UI通过点击行来选择)
|
|
|
- await firstRow.click();
|
|
|
- console.debug('✓ 已点击第一行选择残疾人');
|
|
|
- hasData = true;
|
|
|
- }
|
|
|
- }
|
|
|
+ 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('选择残疾人失败,可能没有数据:', error);
|
|
|
- hasData = false;
|
|
|
+ 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'
|
|
|
+ };
|
|
|
|
|
|
- if (hasData) {
|
|
|
- // 有数据时,点击确认按钮关闭选择对话框
|
|
|
- const confirmButton = page.getByRole('button', { name: /^(确定|确认|选择)$/ }).first();
|
|
|
- await confirmButton.click().catch(() => {
|
|
|
- console.debug('没有找到确认按钮,尝试关闭对话框');
|
|
|
- page.keyboard.press('Escape');
|
|
|
+ const createResponse = await request.post('http://localhost:8080/api/v1/company/createCompany', {
|
|
|
+ headers: {
|
|
|
+ 'Authorization': `Bearer ${token}`,
|
|
|
+ 'Content-Type': 'application/json'
|
|
|
+ },
|
|
|
+ data: companyData
|
|
|
});
|
|
|
- } else {
|
|
|
- // 没有数据时,关闭空对话框
|
|
|
- await page.keyboard.press('Escape').catch(() => {
|
|
|
- console.debug('无法关闭对话框,可能已经自动关闭');
|
|
|
+
|
|
|
+ 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;
|
|
|
}
|
|
|
+}
|
|
|
|
|
|
- // 等待选择对话框关闭
|
|
|
- await page.waitForTimeout(500);
|
|
|
+// 全局计数器,确保每个测试生成唯一的数据
|
|
|
+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,
|
|
|
+ };
|
|
|
+}
|
|
|
+
|
|
|
+/**
|
|
|
+ * 辅助函数:在创建订单对话框中选择残疾人(使用 Story 10.9 验证的实现)
|
|
|
+ * @param page Playwright Page 对象
|
|
|
+ * @param personName 要选择的残疾人姓名(可选)
|
|
|
+ * @returns 是否成功选择了残疾人
|
|
|
+ */
|
|
|
+async function selectDisabledPersonInAddDialog(
|
|
|
+ page: Page,
|
|
|
+ personName?: string
|
|
|
+): Promise<boolean> {
|
|
|
+ // 监听控制台消息
|
|
|
+ page.on('console', msg => {
|
|
|
+ console.log('[浏览器控制台]', msg.text());
|
|
|
+ });
|
|
|
|
|
|
- return hasData;
|
|
|
+ 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;
|
|
|
}
|
|
|
|
|
|
/**
|
|
|
@@ -115,24 +250,77 @@ async function selectDisabledPersonForOrder(
|
|
|
* @param orderManagementPage 订单管理 Page Object
|
|
|
* @param page Playwright Page 对象
|
|
|
* @param orderName 订单名称
|
|
|
- * @param personName 残疾人姓名(可选)
|
|
|
* @returns 是否成功创建订单
|
|
|
*/
|
|
|
async function createTestOrder(
|
|
|
orderManagementPage: Parameters<typeof test>[0]['prototype']['orderManagementPage'],
|
|
|
- page: Parameters<typeof test>[0]['prototype']['page'],
|
|
|
- orderName: string,
|
|
|
- personName?: string
|
|
|
+ page: Page,
|
|
|
+ orderName: string
|
|
|
): Promise<boolean> {
|
|
|
// 打开创建对话框
|
|
|
await orderManagementPage.openCreateDialog();
|
|
|
|
|
|
// 填写必填字段
|
|
|
await page.getByLabel(/订单名称|名称/).fill(orderName);
|
|
|
+
|
|
|
+ // 选择平台
|
|
|
+ if (createdPlatformName) {
|
|
|
+ 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('平台选择器未找到,跳过平台选择');
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ // 选择公司
|
|
|
+ if (createdCompanyName) {
|
|
|
+ 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 hasDisabledPerson = await selectDisabledPersonForOrder(page, personName);
|
|
|
+ const hasDisabledPerson = await selectDisabledPersonInAddDialog(page);
|
|
|
|
|
|
if (hasDisabledPerson) {
|
|
|
// 提交表单
|
|
|
@@ -151,65 +339,66 @@ async function createTestOrder(
|
|
|
}
|
|
|
|
|
|
test.describe('订单详情查看测试', () => {
|
|
|
- // 在测试级别创建唯一的测试数据
|
|
|
- let testPersonName: string;
|
|
|
-
|
|
|
- const generateTestPerson = () => {
|
|
|
- const timestamp = Date.now();
|
|
|
- const random = Math.floor(Math.random() * 10000);
|
|
|
- const uniqueId = `order_detail_${timestamp}_${random}`;
|
|
|
- testPersonName = `${uniqueId}_person`;
|
|
|
- return {
|
|
|
- name: testPersonName,
|
|
|
- gender: '男',
|
|
|
- idCard: `42010119900101${String(timestamp).slice(-4)}${random}`,
|
|
|
- disabilityId: `1234567890${timestamp}${random}`,
|
|
|
- disabilityType: '肢体残疾',
|
|
|
- disabilityLevel: '一级',
|
|
|
- phone: `138${String(timestamp).slice(-8).padStart(8, '0')}`,
|
|
|
- idAddress: `湖北省武汉市测试街道`,
|
|
|
- province: '湖北省',
|
|
|
- city: '武汉市',
|
|
|
- };
|
|
|
- };
|
|
|
-
|
|
|
- test.beforeEach(async ({ adminLoginPage, orderManagementPage, disabilityPersonPage }) => {
|
|
|
+ test.beforeEach(async ({ adminLoginPage, orderManagementPage, request }) => {
|
|
|
// 以管理员身份登录后台
|
|
|
await adminLoginPage.goto();
|
|
|
await adminLoginPage.login(testUsers.admin.username, testUsers.admin.password);
|
|
|
await adminLoginPage.expectLoginSuccess();
|
|
|
|
|
|
- // 创建残疾人测试数据(每次生成唯一数据)
|
|
|
- const personData = generateTestPerson();
|
|
|
- await disabilityPersonPage.goto();
|
|
|
- await disabilityPersonPage.openCreateDialog();
|
|
|
- await disabilityPersonPage.fillBasicForm(personData);
|
|
|
- const result = await disabilityPersonPage.submitForm();
|
|
|
- await disabilityPersonPage.waitForDialogClosed();
|
|
|
+ // 使用 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 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,
|
|
|
+ };
|
|
|
|
|
|
- if (result.hasError) {
|
|
|
- console.debug('创建残疾人失败:', result.errorMessage);
|
|
|
+ const createdPerson = await createDisabledPersonViaAPI(request, personData);
|
|
|
+ if (!createdPerson) {
|
|
|
+ console.debug('无法创建残疾人数据,测试可能被跳过');
|
|
|
+ createdPersonName = null;
|
|
|
} else {
|
|
|
- console.debug('✓ 已创建残疾人测试数据:', personData.name);
|
|
|
- // 刷新页面确保数据持久化
|
|
|
- await disabilityPersonPage.page.reload();
|
|
|
- await disabilityPersonPage.page.waitForLoadState('networkidle');
|
|
|
+ createdPersonName = createdPerson.name;
|
|
|
+ console.debug('已创建残疾人:', createdPersonName, 'ID:', createdPerson.id);
|
|
|
}
|
|
|
|
|
|
// 导航到订单管理页面
|
|
|
await orderManagementPage.goto();
|
|
|
});
|
|
|
|
|
|
- // 注意: 以下测试被跳过,原因:依赖 Story 10.9 的"选择残疾人"功能
|
|
|
- // 当前实现中,selectDisabledPersonForOrder 辅助函数无法可靠地选择残疾人
|
|
|
- // Story 10.9 将实现完整的人员关联功能测试,届时可重新启用这些测试
|
|
|
- test.describe.skip('基本订单详情查看', () => {
|
|
|
+ test.describe('基本订单详情查看', () => {
|
|
|
test('应该能打开订单详情对话框', async ({ orderManagementPage, page }) => {
|
|
|
const timestamp = Date.now();
|
|
|
const random = Math.floor(Math.random() * 1000);
|
|
|
const orderName = `detail_open_${timestamp}_${random}`;
|
|
|
|
|
|
- const created = await createTestOrder(orderManagementPage, page, orderName, testPersonName);
|
|
|
+ const created = await createTestOrder(orderManagementPage, page, orderName);
|
|
|
|
|
|
// 验证订单创建成功
|
|
|
expect(created).toBe(true);
|
|
|
@@ -233,7 +422,7 @@ test.describe('订单详情查看测试', () => {
|
|
|
const random = Math.floor(Math.random() * 1000);
|
|
|
const orderName = `detail_name_${timestamp}_${random}`;
|
|
|
|
|
|
- const created = await createTestOrder(orderManagementPage, page, orderName, testPersonName);
|
|
|
+ const created = await createTestOrder(orderManagementPage, page, orderName);
|
|
|
expect(created).toBe(true);
|
|
|
|
|
|
// 打开订单详情
|
|
|
@@ -254,7 +443,7 @@ test.describe('订单详情查看测试', () => {
|
|
|
const random = Math.floor(Math.random() * 1000);
|
|
|
const orderName = `detail_status_${timestamp}_${random}`;
|
|
|
|
|
|
- const created = await createTestOrder(orderManagementPage, page, orderName, testPersonName);
|
|
|
+ const created = await createTestOrder(orderManagementPage, page, orderName);
|
|
|
expect(created).toBe(true);
|
|
|
|
|
|
// 打开订单详情
|
|
|
@@ -279,7 +468,7 @@ test.describe('订单详情查看测试', () => {
|
|
|
const orderName = `detail_date_${timestamp}_${random}`;
|
|
|
const expectedStartDate = '2025-01-15';
|
|
|
|
|
|
- const created = await createTestOrder(orderManagementPage, page, orderName, testPersonName);
|
|
|
+ const created = await createTestOrder(orderManagementPage, page, orderName);
|
|
|
expect(created).toBe(true);
|
|
|
|
|
|
// 打开订单详情
|
|
|
@@ -300,7 +489,7 @@ test.describe('订单详情查看测试', () => {
|
|
|
const random = Math.floor(Math.random() * 1000);
|
|
|
const orderName = `detail_full_${timestamp}_${random}`;
|
|
|
|
|
|
- const created = await createTestOrder(orderManagementPage, page, orderName, testPersonName);
|
|
|
+ const created = await createTestOrder(orderManagementPage, page, orderName);
|
|
|
expect(created).toBe(true);
|
|
|
|
|
|
// 打开订单详情
|
|
|
@@ -324,16 +513,13 @@ test.describe('订单详情查看测试', () => {
|
|
|
});
|
|
|
});
|
|
|
|
|
|
- // 注意: 以下测试被跳过,原因:依赖 Story 10.9 的"选择残疾人"功能
|
|
|
- // 当前实现中,selectDisabledPersonForOrder 辅助函数无法可靠地选择残疾人
|
|
|
- // Story 10.9 将实现完整的人员关联功能测试
|
|
|
- test.describe.skip('订单人员列表查看', () => {
|
|
|
+ test.describe('订单人员列表查看', () => {
|
|
|
test('应该能获取订单详情中的人员列表', async ({ orderManagementPage, page }) => {
|
|
|
const timestamp = Date.now();
|
|
|
const random = Math.floor(Math.random() * 1000);
|
|
|
const orderName = `person_list_${timestamp}_${random}`;
|
|
|
|
|
|
- const created = await createTestOrder(orderManagementPage, page, orderName, testPersonName);
|
|
|
+ const created = await createTestOrder(orderManagementPage, page, orderName);
|
|
|
expect(created).toBe(true);
|
|
|
|
|
|
// 打开订单详情
|
|
|
@@ -362,7 +548,7 @@ test.describe('订单详情查看测试', () => {
|
|
|
const random = Math.floor(Math.random() * 1000);
|
|
|
const orderName = `person_name_${timestamp}_${random}`;
|
|
|
|
|
|
- const created = await createTestOrder(orderManagementPage, page, orderName, testPersonName);
|
|
|
+ const created = await createTestOrder(orderManagementPage, page, orderName);
|
|
|
expect(created).toBe(true);
|
|
|
|
|
|
// 打开订单详情
|
|
|
@@ -389,7 +575,7 @@ test.describe('订单详情查看测试', () => {
|
|
|
const random = Math.floor(Math.random() * 1000);
|
|
|
const orderName = `person_status_${timestamp}_${random}`;
|
|
|
|
|
|
- const created = await createTestOrder(orderManagementPage, page, orderName, testPersonName);
|
|
|
+ const created = await createTestOrder(orderManagementPage, page, orderName);
|
|
|
expect(created).toBe(true);
|
|
|
|
|
|
// 打开订单详情
|
|
|
@@ -417,7 +603,7 @@ test.describe('订单详情查看测试', () => {
|
|
|
const random = Math.floor(Math.random() * 1000);
|
|
|
const orderName = `person_date_${timestamp}_${random}`;
|
|
|
|
|
|
- const created = await createTestOrder(orderManagementPage, page, orderName, testPersonName);
|
|
|
+ const created = await createTestOrder(orderManagementPage, page, orderName);
|
|
|
expect(created).toBe(true);
|
|
|
|
|
|
// 打开订单详情
|
|
|
@@ -441,14 +627,13 @@ test.describe('订单详情查看测试', () => {
|
|
|
});
|
|
|
});
|
|
|
|
|
|
- // 注意: 以下测试被跳过,原因:依赖 Story 10.9 的"选择残疾人"功能
|
|
|
- test.describe.skip('订单附件查看', () => {
|
|
|
+ test.describe('订单附件查看', () => {
|
|
|
test('应该能获取订单详情中的附件列表', async ({ orderManagementPage, page }) => {
|
|
|
const timestamp = Date.now();
|
|
|
const random = Math.floor(Math.random() * 1000);
|
|
|
const orderName = `attachment_list_${timestamp}_${random}`;
|
|
|
|
|
|
- const created = await createTestOrder(orderManagementPage, page, orderName, testPersonName);
|
|
|
+ const created = await createTestOrder(orderManagementPage, page, orderName);
|
|
|
expect(created).toBe(true);
|
|
|
|
|
|
// 打开订单详情
|
|
|
@@ -474,7 +659,7 @@ test.describe('订单详情查看测试', () => {
|
|
|
const random = Math.floor(Math.random() * 1000);
|
|
|
const orderName = `no_attachment_${timestamp}_${random}`;
|
|
|
|
|
|
- const created = await createTestOrder(orderManagementPage, page, orderName, testPersonName);
|
|
|
+ const created = await createTestOrder(orderManagementPage, page, orderName);
|
|
|
expect(created).toBe(true);
|
|
|
|
|
|
// 打开订单详情
|
|
|
@@ -493,14 +678,13 @@ test.describe('订单详情查看测试', () => {
|
|
|
});
|
|
|
});
|
|
|
|
|
|
- // 注意: 以下测试被跳过,原因:依赖 Story 10.9 的"选择残疾人"功能
|
|
|
- test.describe.skip('详情对话框操作', () => {
|
|
|
+ test.describe('详情对话框操作', () => {
|
|
|
test('应该能多次打开和关闭详情对话框', async ({ orderManagementPage, page }) => {
|
|
|
const timestamp = Date.now();
|
|
|
const random = Math.floor(Math.random() * 1000);
|
|
|
const orderName = `multi_close_${timestamp}_${random}`;
|
|
|
|
|
|
- const created = await createTestOrder(orderManagementPage, page, orderName, testPersonName);
|
|
|
+ const created = await createTestOrder(orderManagementPage, page, orderName);
|
|
|
expect(created).toBe(true);
|
|
|
|
|
|
const dialog = page.locator('[role="dialog"]');
|
|
|
@@ -529,7 +713,7 @@ test.describe('订单详情查看测试', () => {
|
|
|
const random = Math.floor(Math.random() * 1000);
|
|
|
const orderName = `after_close_${timestamp}_${random}`;
|
|
|
|
|
|
- const created = await createTestOrder(orderManagementPage, page, orderName, testPersonName);
|
|
|
+ const created = await createTestOrder(orderManagementPage, page, orderName);
|
|
|
expect(created).toBe(true);
|
|
|
|
|
|
// 打开详情
|