Просмотр исходного кода

完善测试用例:新增指导师功能、小游戏模块、任务模板管理等API和Web测试用例

Sisyphus 6 месяцев назад
Родитель
Сommit
e596a681ae
2 измененных файлов с 259 добавлено и 32 удалено
  1. 10 0
      docs/系统测试/README.md
  2. 249 32
      docs/系统测试/test-cases.js

+ 10 - 0
docs/系统测试/README.md

@@ -105,6 +105,12 @@ open test-reports/test-report-*.html
 | STREAK-001 | 首页显示连续完成任务天数 | ✅ |
 | STREAK-002 | 火苗图标+天数组合显示 | ✅ |
 | STREAK-003 | 连续打卡中断自动重置 | ✅ |
+| GUIDE-001 | 首次登录角色选择 | ✅ |
+| GUIDE-002 | 指导师信息录入(身份证、性别、照片、证书号) | ✅ |
+| GUIDE-003 | 指导师查看关联家庭列表 | ✅ |
+| GUIDE-004 | 指导师审核家庭任务 | ✅ |
+| GUIDE-006 | 分享码绑定家庭 | ✅ |
+| GUIDE-009 | 指导师调整家庭成员任务 | ✅ |
 
 ### P1 级需求(重要)
 
@@ -118,6 +124,9 @@ open test-reports/test-report-*.html
 - FOCUS-001 ~ FOCUS-008
 - DAN-001 ~ DAN-015
 - THEME-001
+- GUIDE-005(批量审核)、GUIDE-007(发送咨询)、GUIDE-008(回复咨询)、GUIDE-010(删除任务)
+- GAME-001 ~ GAME-009(小游戏模块:舒尔特方格、猜数字、数独)
+- TEMPLATE-001 ~ TEMPLATE-004(任务模板管理)
 
 ### P2 级需求(一般)
 
@@ -129,6 +138,7 @@ open test-reports/test-report-*.html
 - THEME-002 ~ THEME-006
 - EXPORT-001 ~ EXPORT-003
 - REPORT-005
+- TEMPLATE-005(启用/禁用模板)
 
 ## 需求变更同步
 

+ 249 - 32
docs/系统测试/test-cases.js

@@ -552,12 +552,158 @@ class API_010_TestCase extends ApiTestCase {
       
       console.log(`[${this.id}] 家庭信息数据:`, JSON.stringify(response.data, null, 2));
       
-      const passed = response.status === 200;
-      this.logResult(passed);
-    } catch (error) {
-      this.logResult(false, error);
-    }
+const passed = response.status === 200;
+    this.logResult(passed);
+  } catch (error) {
+    this.logResult(false, error);
+  }
+ }
+}
+
+/**
+* API-011: 指导师首次登录角色选择
+*/
+class API_011_TestCase extends ApiTestCase {
+ constructor() {
+  super('API-011', '指导师首次登录角色选择', 'P0', '/api/auth/role-select', 'POST');
+ }
+
+ async run() {
+  try {
+   this.requestData = { userId: 1, role: 'teacher' };
+   const response = await this.sendRequest(this.requestData);
+   this.logResult(response.status === 200);
+  } catch (error) {
+   this.logResult(false, error);
+  }
+ }
+}
+
+/**
+* API-012: 指导师信息录入
+*/
+class API_012_TestCase extends ApiTestCase {
+ constructor() {
+  super('API-012', '指导师信息录入', 'P0', '/api/user/profile', 'PUT');
+ }
+
+ async run() {
+  try {
+   this.requestData = {
+    idCard: '110101199001011234',
+    gender: 'male',
+    teacherPhoto: 'https://example.com/photo.jpg',
+    teacherNo: 'TEACHER20260001',
+    certificateImage: 'https://example.com/cert.jpg'
+   };
+   const response = await this.sendRequest(this.requestData);
+   this.logResult(response.status === 200);
+  } catch (error) {
+   this.logResult(false, error);
+  }
+ }
+}
+
+/**
+* API-013: 指导师查看关联家庭
+*/
+class API_013_TestCase extends ApiTestCase {
+ constructor() {
+  super('API-013', '指导师查看关联家庭列表', 'P0', '/api/guide/families', 'GET');
+ }
+
+ async run() {
+  try {
+   this.requestData = { teacherId: 1 };
+   const response = await this.sendRequest(this.requestData);
+   this.logResult(response.status === 200);
+  } catch (error) {
+   this.logResult(false, error);
+  }
+ }
+}
+
+/**
+* API-014: 指导师审核任务
+*/
+class API_014_TestCase extends ApiTestCase {
+ constructor() {
+  super('API-014', '指导师审核家庭任务', 'P0', '/api/guide/tasks/1/review', 'POST');
+ }
+
+ async run() {
+  try {
+   this.requestData = { taskId: 1, approved: true, comment: '审核通过' };
+   const response = await this.sendRequest(this.requestData);
+   this.logResult(response.status === 200);
+  } catch (error) {
+   this.logResult(false, error);
   }
+ }
+}
+
+/**
+* API-015: 小游戏-舒尔特方格
+*/
+class API_015_TestCase extends ApiTestCase {
+ constructor() {
+  super('API-015', '舒尔特方格开始游戏', 'P1', '/api/mini-games/schulte/start', 'POST');
+ }
+
+ async run() {
+  try {
+   this.requestData = { childId: 2, gridSize: 5 };
+   const response = await this.sendRequest(this.requestData);
+   this.logResult(response.status === 200);
+  } catch (error) {
+   this.logResult(false, error);
+  }
+ }
+}
+
+/**
+* API-016: 小游戏-猜数字(1a2b)
+*/
+class API_016_TestCase extends ApiTestCase {
+ constructor() {
+  super('API-016', '猜数字(1a2b)开始游戏', 'P1', '/api/mini-games/1a2b/start', 'POST');
+ }
+
+ async run() {
+  try {
+   this.requestData = { childId: 2 };
+   const response = await this.sendRequest(this.requestData);
+   this.logResult(response.status === 200);
+  } catch (error) {
+   this.logResult(false, error);
+  }
+ }
+}
+
+/**
+* API-017: 任务模板创建
+*/
+class API_017_TestCase extends ApiTestCase {
+ constructor() {
+  super('API-017', '创建任务模板', 'P1', '/api/task-templates', 'POST');
+ }
+
+ async run() {
+  try {
+   this.requestData = {
+    title: '每日阅读',
+    description: '阅读30分钟课外书籍',
+    category: 'study',
+    points: 3,
+    duration: 30,
+    completeTypes: ['checkin', 'text']
+   };
+   const response = await this.sendRequest(this.requestData);
+   this.logResult(response.status === 200);
+  } catch (error) {
+   this.logResult(false, error);
+  }
+ }
 }
 
 // ============================================================================
@@ -818,11 +964,71 @@ class WEB_007_TestCase extends WebTestCase {
       await this.click(streetBtn.uid);
       await this.screenshot('02_street_stats');
       
-      this.logResult(true);
-    } catch (error) {
-      this.logResult(false, error);
-    }
+this.logResult(true);
+  } catch (error) {
+    this.logResult(false, error);
+  }
+ }
+}
+
+/**
+* WEB-008: 指导师审核家庭任务
+*/
+class WEB_008_TestCase extends WebTestCase {
+ constructor() {
+  super('WEB-008', '指导师审核家庭任务', 'P0');
+ }
+
+ async run() {
+  try {
+   await this.setup();
+   await this.loginTeacher();
+
+   // 1. 进入待审核任务
+   const pendingTasks = await this.waitForElement('待审核任务');
+   await this.click(pendingTasks.uid);
+   await this.screenshot('01_pending_tasks');
+
+   // 2. 审核通过
+   const approveBtn = await this.waitForElement('通过');
+   await this.click(approveBtn.uid);
+   await this.screenshot('02_approved');
+
+   this.logResult(true);
+  } catch (error) {
+   this.logResult(false, error);
   }
+ }
+}
+
+/**
+* WEB-009: 指导师查看家庭任务详情
+*/
+class WEB_009_TestCase extends WebTestCase {
+ constructor() {
+  super('WEB-009', '指导师查看家庭任务详情', 'P1');
+ }
+
+ async run() {
+  try {
+   await this.setup();
+   await this.loginTeacher();
+
+   // 1. 进入我的家庭
+   const myFamilies = await this.waitForElement('我的家庭');
+   await this.click(myFamilies.uid);
+   await this.screenshot('01_family_list');
+
+   // 2. 查看详情
+   const detailBtn = await this.waitForElement('查看详情');
+   await this.click(detailBtn.uid);
+   await this.screenshot('02_family_tasks');
+
+   this.logResult(true);
+  } catch (error) {
+   this.logResult(false, error);
+  }
+ }
 }
 
 // ============================================================================
@@ -998,30 +1204,41 @@ module.exports = {
   TestSuite,
   TEST_CONFIG,
   
-  // API测试用例(小程序端)
-  apiTestCases: {
-    API_001_TestCase,
-    API_002_TestCase,
-    API_003_TestCase,
-    API_004_TestCase,
-    API_005_TestCase,
-    API_006_TestCase,
-    API_007_TestCase,
-    API_008_TestCase,
-    API_009_TestCase,
-    API_010_TestCase
-  },
+// API测试用例(小程序端)
+ apiTestCases: {
+  API_001_TestCase,
+  API_002_TestCase,
+  API_003_TestCase,
+  API_004_TestCase,
+  API_005_TestCase,
+  API_006_TestCase,
+  API_007_TestCase,
+  API_008_TestCase,
+  API_009_TestCase,
+  API_010_TestCase,
+  // 新增模块测试用例
+  API_011_TestCase, // 指导师角色选择
+  API_012_TestCase, // 指导师信息录入
+  API_013_TestCase, // 指导师查看关联家庭
+  API_014_TestCase, // 指导师审核任务
+  API_015_TestCase, // 小游戏-舒尔特方格
+  API_016_TestCase, // 小游戏-猜数字
+  API_017_TestCase  // 任务模板创建
+ },
   
-  // Web浏览器测试用例(管理后台)
-  webTestCases: {
-    WEB_001_TestCase,
-    WEB_002_TestCase,
-    WEB_003_TestCase,
-    WEB_004_TestCase,
-    WEB_005_TestCase,
-    WEB_006_TestCase,
-    WEB_007_TestCase
-  }
+// Web浏览器测试用例(管理后台)
+ webTestCases: {
+  WEB_001_TestCase,
+  WEB_002_TestCase,
+  WEB_003_TestCase,
+  WEB_004_TestCase,
+  WEB_005_TestCase,
+  WEB_006_TestCase,
+  WEB_007_TestCase,
+  // 新增指导师测试用例
+  WEB_008_TestCase, // 指导师审核家庭任务
+  WEB_009_TestCase  // 指导师查看家庭任务详情
+ }
 };
 
 // ============================================================================