|
|
@@ -12,11 +12,9 @@ const TIMEOUTS = {
|
|
|
SHORT: 300,
|
|
|
MEDIUM: 500,
|
|
|
LONG: 1000,
|
|
|
+ VERY_SHORT: 200,
|
|
|
} as const;
|
|
|
|
|
|
-// 用于跟踪已创建的测试数据,便于清理
|
|
|
-const createdTestData: Array<{ name: string; idCard: string }> = [];
|
|
|
-
|
|
|
/**
|
|
|
* 生成唯一的测试数据
|
|
|
*/
|
|
|
@@ -38,7 +36,13 @@ function generateUniqueTestData(suffix: string) {
|
|
|
}
|
|
|
|
|
|
test.describe.serial('残疾人管理 - 备注管理功能', () => {
|
|
|
+ // 测试级别的数据存储,避免可变全局状态
|
|
|
+ let createdTestData: Array<{ name: string; idCard: string }> = [];
|
|
|
+
|
|
|
test.beforeEach(async ({ adminLoginPage, disabilityPersonPage }) => {
|
|
|
+ // 每次测试前重置数据存储
|
|
|
+ createdTestData = [];
|
|
|
+
|
|
|
// 以管理员身份登录后台
|
|
|
await adminLoginPage.goto();
|
|
|
await adminLoginPage.login(testUsers.admin.username, testUsers.admin.password);
|
|
|
@@ -56,7 +60,7 @@ test.describe.serial('残疾人管理 - 备注管理功能', () => {
|
|
|
if (await deleteButton.count() > 0) {
|
|
|
await deleteButton.click();
|
|
|
await page.getByRole('button', { name: '确认' }).click().catch(() => {});
|
|
|
- await page.waitForTimeout(TIMEOUTS.MEDIUM);
|
|
|
+ await page.waitForTimeout(TIMEOUTS.SHORT);
|
|
|
}
|
|
|
} catch (error) {
|
|
|
console.debug(` ⚠ 清理数据失败: ${data.name}`, error);
|
|
|
@@ -69,7 +73,7 @@ test.describe.serial('残疾人管理 - 备注管理功能', () => {
|
|
|
const testData = generateUniqueTestData('简单备注');
|
|
|
createdTestData.push({ name: testData.name, idCard: testData.idCard });
|
|
|
|
|
|
- console.log('\n========== 添加简单备注测试 ==========');
|
|
|
+ console.debug('\n========== 添加简单备注测试 ==========');
|
|
|
|
|
|
// 打开对话框并填写基本信息
|
|
|
await disabilityPersonPage.openCreateDialog();
|
|
|
@@ -88,14 +92,14 @@ test.describe.serial('残疾人管理 - 备注管理功能', () => {
|
|
|
expect(noteList[0]).toContain(noteContent);
|
|
|
console.debug(' ✓ 备注已添加');
|
|
|
|
|
|
- console.log('✅ 添加简单备注测试通过');
|
|
|
+ console.debug('✅ 添加简单备注测试通过');
|
|
|
});
|
|
|
|
|
|
test('应该成功添加长文本备注', async ({ disabilityPersonPage }) => {
|
|
|
const testData = generateUniqueTestData('长文本备注');
|
|
|
createdTestData.push({ name: testData.name, idCard: testData.idCard });
|
|
|
|
|
|
- console.log('\n========== 添加长文本备注测试 ==========');
|
|
|
+ console.debug('\n========== 添加长文本备注测试 ==========');
|
|
|
|
|
|
// 打开对话框并填写基本信息
|
|
|
await disabilityPersonPage.openCreateDialog();
|
|
|
@@ -108,20 +112,21 @@ test.describe.serial('残疾人管理 - 备注管理功能', () => {
|
|
|
const longNote = `这是一条很长的备注内容_${testData.name}`.repeat(10);
|
|
|
await disabilityPersonPage.addNote(longNote);
|
|
|
|
|
|
- // 验证备注出现在列表中
|
|
|
+ // 验证备注出现在列表中 - 验证完整内容和长度
|
|
|
const noteList = await disabilityPersonPage.getNoteList();
|
|
|
expect(noteList).toHaveLength(1);
|
|
|
- expect(noteList[0]).toContain('这是一条很长的备注内容');
|
|
|
+ expect(noteList[0].length).toBe(longNote.length);
|
|
|
+ expect(noteList[0]).toBe(longNote);
|
|
|
console.debug(' ✓ 长文本备注已添加');
|
|
|
|
|
|
- console.log('✅ 添加长文本备注测试通过');
|
|
|
+ console.debug('✅ 添加长文本备注测试通过');
|
|
|
});
|
|
|
|
|
|
test('应该成功编辑备注', async ({ disabilityPersonPage }) => {
|
|
|
const testData = generateUniqueTestData('编辑备注');
|
|
|
createdTestData.push({ name: testData.name, idCard: testData.idCard });
|
|
|
|
|
|
- console.log('\n========== 编辑备注测试 ==========');
|
|
|
+ console.debug('\n========== 编辑备注测试 ==========');
|
|
|
|
|
|
// 打开对话框并填写基本信息
|
|
|
await disabilityPersonPage.openCreateDialog();
|
|
|
@@ -138,20 +143,20 @@ test.describe.serial('残疾人管理 - 备注管理功能', () => {
|
|
|
const updatedNote = `更新后的备注_${testData.name}`;
|
|
|
await disabilityPersonPage.editNote(0, updatedNote);
|
|
|
|
|
|
- // 验证更新后的内容
|
|
|
+ // 验证更新后的内容 - 确保旧文本完全被替换
|
|
|
const noteList = await disabilityPersonPage.getNoteList();
|
|
|
- expect(noteList[0]).toContain(updatedNote);
|
|
|
+ expect(noteList[0]).toBe(updatedNote);
|
|
|
expect(noteList[0]).not.toContain(originalNote);
|
|
|
console.debug(' ✓ 备注已编辑');
|
|
|
|
|
|
- console.log('✅ 编辑备注测试通过');
|
|
|
+ console.debug('✅ 编辑备注测试通过');
|
|
|
});
|
|
|
|
|
|
test('应该成功删除备注', async ({ disabilityPersonPage }) => {
|
|
|
const testData = generateUniqueTestData('删除备注');
|
|
|
createdTestData.push({ name: testData.name, idCard: testData.idCard });
|
|
|
|
|
|
- console.log('\n========== 删除备注测试 ==========');
|
|
|
+ console.debug('\n========== 删除备注测试 ==========');
|
|
|
|
|
|
// 打开对话框并填写基本信息
|
|
|
await disabilityPersonPage.openCreateDialog();
|
|
|
@@ -177,14 +182,14 @@ test.describe.serial('残疾人管理 - 备注管理功能', () => {
|
|
|
expect(noteList).toHaveLength(0);
|
|
|
console.debug(' ✓ 备注已删除');
|
|
|
|
|
|
- console.log('✅ 删除备注测试通过');
|
|
|
+ console.debug('✅ 删除备注测试通过');
|
|
|
});
|
|
|
|
|
|
test('应该支持添加多条备注', async ({ disabilityPersonPage }) => {
|
|
|
const testData = generateUniqueTestData('多条备注');
|
|
|
createdTestData.push({ name: testData.name, idCard: testData.idCard });
|
|
|
|
|
|
- console.log('\n========== 添加多条备注测试 ==========');
|
|
|
+ console.debug('\n========== 添加多条备注测试 ==========');
|
|
|
|
|
|
// 打开对话框并填写基本信息
|
|
|
await disabilityPersonPage.openCreateDialog();
|
|
|
@@ -203,14 +208,14 @@ test.describe.serial('残疾人管理 - 备注管理功能', () => {
|
|
|
expect(noteList).toHaveLength(3);
|
|
|
console.debug(' ✓ 已添加 3 条备注');
|
|
|
|
|
|
- console.log('✅ 添加多条备注测试通过');
|
|
|
+ console.debug('✅ 添加多条备注测试通过');
|
|
|
});
|
|
|
|
|
|
test('应该支持标记特殊需求', async ({ disabilityPersonPage }) => {
|
|
|
const testData = generateUniqueTestData('特殊需求');
|
|
|
createdTestData.push({ name: testData.name, idCard: testData.idCard });
|
|
|
|
|
|
- console.log('\n========== 特殊需求标记测试 ==========');
|
|
|
+ console.debug('\n========== 特殊需求标记测试 ==========');
|
|
|
|
|
|
// 打开对话框并填写基本信息
|
|
|
await disabilityPersonPage.openCreateDialog();
|
|
|
@@ -228,14 +233,14 @@ test.describe.serial('残疾人管理 - 备注管理功能', () => {
|
|
|
expect(isSpecialNeeds).toBe(true);
|
|
|
console.debug(' ✓ 特殊需求已标记');
|
|
|
|
|
|
- console.log('✅ 特殊需求标记测试通过');
|
|
|
+ console.debug('✅ 特殊需求标记测试通过');
|
|
|
});
|
|
|
|
|
|
test('应该限制最多添加10条备注', async ({ disabilityPersonPage }) => {
|
|
|
const testData = generateUniqueTestData('备注限制');
|
|
|
createdTestData.push({ name: testData.name, idCard: testData.idCard });
|
|
|
|
|
|
- console.log('\n========== 备注数量限制测试 ==========');
|
|
|
+ console.debug('\n========== 备注数量限制测试 ==========');
|
|
|
|
|
|
// 打开对话框并填写基本信息
|
|
|
await disabilityPersonPage.openCreateDialog();
|
|
|
@@ -259,14 +264,14 @@ test.describe.serial('残疾人管理 - 备注管理功能', () => {
|
|
|
expect(isDisabled).toBe(true);
|
|
|
console.debug(' ✓ 添加按钮已禁用(达到最大数量)');
|
|
|
|
|
|
- console.log('✅ 备注数量限制测试通过');
|
|
|
+ console.debug('✅ 备注数量限制测试通过');
|
|
|
});
|
|
|
|
|
|
test('完整流程:添加多条备注、编辑、删除', async ({ disabilityPersonPage }) => {
|
|
|
const testData = generateUniqueTestData('完整流程');
|
|
|
createdTestData.push({ name: testData.name, idCard: testData.idCard });
|
|
|
|
|
|
- console.log('\n========== 备注完整流程测试 ==========');
|
|
|
+ console.debug('\n========== 备注完整流程测试 ==========');
|
|
|
|
|
|
// 打开对话框并填写基本信息
|
|
|
await disabilityPersonPage.openCreateDialog();
|
|
|
@@ -299,6 +304,6 @@ test.describe.serial('残疾人管理 - 备注管理功能', () => {
|
|
|
expect(noteList[1]).toContain('第三条备注');
|
|
|
console.debug(' ✓ 最终状态验证通过');
|
|
|
|
|
|
- console.log('✅ 备注完整流程测试通过');
|
|
|
+ console.debug('✅ 备注完整流程测试通过');
|
|
|
});
|
|
|
});
|