Przeglądaj źródła

✅ test(orders): 完善订单API集成测试中的路线快照数据

- 为多个测试用例补充完整routeSnapshot字段,包含id、name、pickupPoint等关键信息
- 为不存在的路线测试用例添加虚构的路线快照数据
- 其他测试用例使用测试路线的真实数据填充路线快照,提高测试真实性和准确性
yourname 3 miesięcy temu
rodzic
commit
7ee90135a0

+ 60 - 6
web/tests/integration/server/orders.integration.test.ts

@@ -117,7 +117,16 @@ describe('用户端订单API集成测试', () => {
         passengerCount: 1,
         totalAmount: 100,
         passengerSnapshots: [],
-        routeSnapshot: {}
+        routeSnapshot: {
+          id: 999999,
+          name: '不存在的路线',
+          pickupPoint: '起点',
+          dropoffPoint: '终点',
+          departureTime: new Date(),
+          price: 100,
+          vehicleType: 'CAR',
+          travelMode: 'DRIVING'
+        }
       };
 
       const response = await client.orders.$post({
@@ -143,7 +152,16 @@ describe('用户端订单API集成测试', () => {
         passengerCount: testRoute.availableSeats + 1, // 超过可用座位数
         totalAmount: testRoute.price * (testRoute.availableSeats + 1),
         passengerSnapshots: [],
-        routeSnapshot: {}
+        routeSnapshot: {
+          id: testRoute.id,
+          name: testRoute.name,
+          pickupPoint: testRoute.pickupPoint,
+          dropoffPoint: testRoute.dropoffPoint,
+          departureTime: testRoute.departureTime,
+          price: testRoute.price,
+          vehicleType: testRoute.vehicleType,
+          travelMode: testRoute.travelMode
+        }
       };
 
       const response = await client.orders.$post({
@@ -177,7 +195,16 @@ describe('用户端订单API集成测试', () => {
             phone: '13812345678'
           }
         ],
-        routeSnapshot: {}
+        routeSnapshot: {
+          id: testRoute.id,
+          name: testRoute.name,
+          pickupPoint: testRoute.pickupPoint,
+          dropoffPoint: testRoute.dropoffPoint,
+          departureTime: testRoute.departureTime,
+          price: testRoute.price,
+          vehicleType: testRoute.vehicleType,
+          travelMode: testRoute.travelMode
+        }
       };
 
       const response = await client.orders.$post({
@@ -204,7 +231,16 @@ describe('用户端订单API集成测试', () => {
         passengerCount: 1,
         totalAmount: 100,
         passengerSnapshots: [],
-        routeSnapshot: {}
+        routeSnapshot: {
+          id: testRoute.id,
+          name: testRoute.name,
+          pickupPoint: testRoute.pickupPoint,
+          dropoffPoint: testRoute.dropoffPoint,
+          departureTime: testRoute.departureTime,
+          price: testRoute.price,
+          vehicleType: testRoute.vehicleType,
+          travelMode: testRoute.travelMode
+        }
       };
 
       const response = await client.orders.$post({
@@ -280,7 +316,16 @@ describe('用户端订单API集成测试', () => {
         passengerCount: 1,
         totalAmount: testRoute.price,
         passengerSnapshots: [],
-        routeSnapshot: {}
+        routeSnapshot: {
+          id: testRoute.id,
+          name: testRoute.name,
+          pickupPoint: testRoute.pickupPoint,
+          dropoffPoint: testRoute.dropoffPoint,
+          departureTime: testRoute.departureTime,
+          price: testRoute.price,
+          vehicleType: testRoute.vehicleType,
+          travelMode: testRoute.travelMode
+        }
       };
 
       const response = await client.orders.$post({
@@ -296,7 +341,16 @@ describe('用户端订单API集成测试', () => {
         passengerCount: 1,
         totalAmount: testRoute.price,
         passengerSnapshots: [],
-        routeSnapshot: {}
+        routeSnapshot: {
+          id: testRoute.id,
+          name: testRoute.name,
+          pickupPoint: testRoute.pickupPoint,
+          dropoffPoint: testRoute.dropoffPoint,
+          departureTime: testRoute.departureTime,
+          price: testRoute.price,
+          vehicleType: testRoute.vehicleType,
+          travelMode: testRoute.travelMode
+        }
       };
 
       const response = await client.orders.$post({