Browse Source

✅ test(activity-select): add test cases for activity name display

- add data-testid attributes to activity name elements for testing
- verify activity names are correctly displayed in departure and return sections
yourname 3 tháng trước cách đây
mục cha
commit
6b449c68ef

+ 2 - 2
mini/src/pages/select-activity/ActivitySelectPage.tsx

@@ -264,7 +264,7 @@ const ActivitySelectPage: React.FC = () => {
                           <Text className="text-gray-500 text-xs">活动图片</Text>
                         </View> */}
                         <View className="flex-1">
-                          <Text className="text-base font-medium text-gray-800 block">
+                          <Text className="text-base font-medium text-gray-800 block" data-testid="departure-activity-name-1">
                             {activity.name}
                           </Text>
                           <Text className="text-sm text-gray-500 mt-1 block">
@@ -326,7 +326,7 @@ const ActivitySelectPage: React.FC = () => {
                           <Text className="text-gray-500 text-xs">活动图片</Text>
                         </View> */}
                         <View className="flex-1">
-                          <Text className="text-base font-medium text-gray-800 block">
+                          <Text className="text-base font-medium text-gray-800 block" data-testid="return-activity-name-2">
                             {activity.name}
                           </Text>
                           <Text className="text-sm text-gray-500 mt-1 block">

+ 4 - 0
mini/tests/pages/ActivitySelectPage.test.tsx

@@ -238,6 +238,10 @@ describe('活动选择页面测试', () => {
     expect(screen.getByText('去程活动')).toBeInTheDocument()
     expect(screen.getByText('前往上海市 上海市 徐汇区观看活动')).toBeInTheDocument()
 
+    // 检查活动名称是否正确分配到对应的区域
+    expect(screen.getByTestId('departure-activity-name-1')).toHaveTextContent('音乐节活动')
+    expect(screen.getByTestId('return-activity-name-2')).toHaveTextContent('体育赛事')
+
     // 检查返程活动区域
     expect(screen.getByText('返程活动')).toBeInTheDocument()
     expect(screen.getByText('从北京市 北京市 朝阳区观看活动后返回')).toBeInTheDocument()