Ver código fonte

✅ test(e2e): update activity management tests and page object

- 修改活动类型选项,将"去程活动"和"返程活动"简化为"去程"和"返程"
- 标准化日期格式,使用ISO 8601格式(T分隔符)
- 增强创建活动流程稳定性:
  - 添加模态框关闭等待逻辑
  - 增加失败时的日志输出
  - 调整等待时间以提高可靠性
yourname 4 meses atrás
pai
commit
2908f8a4a7

+ 7 - 2
tests/e2e/pages/admin/activity-management.page.ts

@@ -68,7 +68,7 @@ export class ActivityManagementPage {
   async createActivity(activityData: {
     name: string;
     description?: string;
-    type: '去程活动' | '返程活动';
+    type: '去程' | '返程';
     startDate: string;
     endDate: string;
   }) {
@@ -91,6 +91,9 @@ export class ActivityManagementPage {
 
     // 提交表单 - 使用模态框中的创建按钮
     await this.page.locator('[role="dialog"]').getByRole('button', { name: '创建活动' }).click();
+
+    // 等待模态框关闭
+    await this.page.waitForSelector('[role="dialog"]', { state: 'hidden', timeout: 10000 });
     await this.page.waitForLoadState('networkidle');
 
     // 等待活动创建结果提示
@@ -103,17 +106,19 @@ export class ActivityManagementPage {
       // 检查是否有错误提示
       const errorVisible = await this.page.locator('text=创建失败').isVisible().catch(() => false);
       if (errorVisible) {
+        console.log('创建活动失败:前端显示创建失败提示');
         return;
       }
 
       // 如果是创建成功,刷新页面
-      await this.page.waitForTimeout(1000);
+      await this.page.waitForTimeout(2000);
       await this.page.reload();
       await this.page.waitForLoadState('networkidle');
       await this.expectToBeVisible();
     } catch (error) {
       // 如果没有提示出现,继续执行
       console.log('创建操作没有显示提示信息,继续执行');
+      await this.page.waitForTimeout(2000);
       await this.page.reload();
       await this.page.waitForLoadState('networkidle');
       await this.expectToBeVisible();

+ 22 - 22
tests/e2e/specs/admin/activities.spec.ts

@@ -59,9 +59,9 @@ test.describe.serial('活动管理 E2E 测试', () => {
     await activityManagementPage.createActivity({
       name: testActivityName,
       description: '这是一个测试活动',
-      type: '去程活动',
-      startDate: '2025-01-01 08:00',
-      endDate: '2025-01-01 18:00'
+      type: '去程',
+      startDate: '2025-01-01T08:00',
+      endDate: '2025-01-01T18:00'
     });
 
     // 验证活动创建成功
@@ -75,9 +75,9 @@ test.describe.serial('活动管理 E2E 测试', () => {
     await activityManagementPage.createActivity({
       name: testActivityName,
       description: '原始描述',
-      type: '去程活动',
-      startDate: '2025-01-01 08:00',
-      endDate: '2025-01-01 18:00'
+      type: '去程',
+      startDate: '2025-01-01T08:00',
+      endDate: '2025-01-01T18:00'
     });
 
     // 编辑活动信息
@@ -85,8 +85,8 @@ test.describe.serial('活动管理 E2E 测试', () => {
       name: `${testActivityName}_更新`,
       description: '更新后的描述',
       type: '返程活动',
-      startDate: '2025-01-02 09:00',
-      endDate: '2025-01-02 19:00'
+      startDate: '2025-01-02T09:00',
+      endDate: '2025-01-02T19:00'
     });
 
     // 验证活动信息已更新
@@ -100,9 +100,9 @@ test.describe.serial('活动管理 E2E 测试', () => {
     await activityManagementPage.createActivity({
       name: testActivityName,
       description: '待删除活动',
-      type: '去程活动',
-      startDate: '2025-01-01 08:00',
-      endDate: '2025-01-01 18:00'
+      type: '去程',
+      startDate: '2025-01-01T08:00',
+      endDate: '2025-01-01T18:00'
     });
 
     // 验证活动存在
@@ -122,9 +122,9 @@ test.describe.serial('活动管理 E2E 测试', () => {
     await activityManagementPage.createActivity({
       name: testActivityName,
       description: '状态测试活动',
-      type: '去程活动',
-      startDate: '2025-01-01 08:00',
-      endDate: '2025-01-01 18:00'
+      type: '去程',
+      startDate: '2025-01-01T08:00',
+      endDate: '2025-01-01T18:00'
     });
 
     // 验证活动存在
@@ -159,9 +159,9 @@ test.describe.serial('活动管理 E2E 测试', () => {
         await activityManagementPage.createActivity({
           name: `分页测试活动_${Date.now()}_${i}`,
           description: `分页测试活动 ${i}`,
-          type: i % 2 === 0 ? '去程活动' : '返程活动',
-          startDate: '2025-01-01 08:00',
-          endDate: '2025-01-01 18:00'
+          type: i % 2 === 0 ? '去程' : '返程',
+          startDate: '2025-01-01T08:00',
+          endDate: '2025-01-01T18:00'
         });
       }
     }
@@ -189,9 +189,9 @@ test.describe.serial('活动管理 E2E 测试', () => {
     await activityManagementPage.createActivity({
       name: testActivityName,
       description: '工作流测试活动',
-      type: '去程活动',
-      startDate: '2025-01-01 08:00',
-      endDate: '2025-01-01 18:00'
+      type: '去程',
+      startDate: '2025-01-01T08:00',
+      endDate: '2025-01-01T18:00'
     });
 
     // 验证活动创建成功
@@ -203,8 +203,8 @@ test.describe.serial('活动管理 E2E 测试', () => {
       name: `${testActivityName}_更新`,
       description: '更新后的工作流活动',
       type: '返程活动',
-      startDate: '2025-01-02 09:00',
-      endDate: '2025-01-02 19:00'
+      startDate: '2025-01-02T09:00',
+      endDate: '2025-01-02T19:00'
     });
 
     // 验证活动信息已更新