|
@@ -331,18 +331,17 @@ describe('RoutesPage 集成测试', () => {
|
|
|
// 验证模态框显示
|
|
// 验证模态框显示
|
|
|
expect(screen.getByRole('heading', { name: '创建路线' })).toBeInTheDocument();
|
|
expect(screen.getByRole('heading', { name: '创建路线' })).toBeInTheDocument();
|
|
|
|
|
|
|
|
- // 验证表单字段存在
|
|
|
|
|
- expect(screen.getByLabelText(/路线名称/i)).toBeInTheDocument();
|
|
|
|
|
- expect(screen.getByLabelText(/出发地/i)).toBeInTheDocument();
|
|
|
|
|
- expect(screen.getByLabelText(/目的地/i)).toBeInTheDocument();
|
|
|
|
|
- expect(screen.getByLabelText(/上车点/i)).toBeInTheDocument();
|
|
|
|
|
- expect(screen.getByLabelText(/下车点/i)).toBeInTheDocument();
|
|
|
|
|
- expect(screen.getByLabelText(/出发时间/i)).toBeInTheDocument();
|
|
|
|
|
- expect(screen.getByLabelText(/车型/i)).toBeInTheDocument();
|
|
|
|
|
- expect(screen.getByLabelText(/价格/i)).toBeInTheDocument();
|
|
|
|
|
- expect(screen.getByLabelText(/座位数/i)).toBeInTheDocument();
|
|
|
|
|
- expect(screen.getByLabelText(/可用座位数/i)).toBeInTheDocument();
|
|
|
|
|
- expect(screen.getByLabelText(/关联活动/i)).toBeInTheDocument();
|
|
|
|
|
|
|
+ // 验证表单字段存在 - 使用data-testid
|
|
|
|
|
+ expect(screen.getByTestId('route-name-input')).toBeInTheDocument();
|
|
|
|
|
+ expect(screen.getByTestId('start-point-input')).toBeInTheDocument();
|
|
|
|
|
+ expect(screen.getByTestId('end-point-input')).toBeInTheDocument();
|
|
|
|
|
+ expect(screen.getByTestId('pickup-point-input')).toBeInTheDocument();
|
|
|
|
|
+ expect(screen.getByTestId('dropoff-point-input')).toBeInTheDocument();
|
|
|
|
|
+ expect(screen.getByTestId('departure-time-input')).toBeInTheDocument();
|
|
|
|
|
+ expect(screen.getByTestId('price-input')).toBeInTheDocument();
|
|
|
|
|
+ expect(screen.getByTestId('seat-count-input')).toBeInTheDocument();
|
|
|
|
|
+ expect(screen.getByTestId('available-seats-input')).toBeInTheDocument();
|
|
|
|
|
+ expect(screen.getByTestId('activity-select')).toBeInTheDocument();
|
|
|
});
|
|
});
|
|
|
|
|
|
|
|
it('应该处理启用/禁用路线操作', async () => {
|
|
it('应该处理启用/禁用路线操作', async () => {
|
|
@@ -403,6 +402,15 @@ describe('RoutesPage 集成测试', () => {
|
|
|
|
|
|
|
|
it('应该处理车型筛选', async () => {
|
|
it('应该处理车型筛选', async () => {
|
|
|
const user = userEvent.setup();
|
|
const user = userEvent.setup();
|
|
|
|
|
+
|
|
|
|
|
+ // 在测试前模拟缺失的 Pointer Events API
|
|
|
|
|
+ if (!Element.prototype.hasPointerCapture) {
|
|
|
|
|
+ Element.prototype.hasPointerCapture = vi.fn(() => false);
|
|
|
|
|
+ }
|
|
|
|
|
+ if (!Element.prototype.releasePointerCapture) {
|
|
|
|
|
+ Element.prototype.releasePointerCapture = vi.fn();
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
render(
|
|
render(
|
|
|
<TestWrapper>
|
|
<TestWrapper>
|
|
|
<RoutesPage />
|
|
<RoutesPage />
|
|
@@ -413,10 +421,13 @@ describe('RoutesPage 集成测试', () => {
|
|
|
expect(screen.getByText('北京到上海路线')).toBeInTheDocument();
|
|
expect(screen.getByText('北京到上海路线')).toBeInTheDocument();
|
|
|
});
|
|
});
|
|
|
|
|
|
|
|
- // 验证车型筛选器存在,但不直接点击避免事件错误
|
|
|
|
|
- const vehicleTypeFilter = screen.getByRole('combobox');
|
|
|
|
|
|
|
+ // 验证车型筛选器存在 - 使用data-testid更精确
|
|
|
|
|
+ const vehicleTypeFilter = screen.getByTestId('route-vehicle-type-filter');
|
|
|
expect(vehicleTypeFilter).toBeInTheDocument();
|
|
expect(vehicleTypeFilter).toBeInTheDocument();
|
|
|
|
|
|
|
|
|
|
+ // 点击Select来展开选项
|
|
|
|
|
+ await user.click(vehicleTypeFilter);
|
|
|
|
|
+
|
|
|
// 验证筛选选项存在
|
|
// 验证筛选选项存在
|
|
|
expect(screen.getByText('大巴')).toBeInTheDocument();
|
|
expect(screen.getByText('大巴')).toBeInTheDocument();
|
|
|
expect(screen.getByText('中巴')).toBeInTheDocument();
|
|
expect(screen.getByText('中巴')).toBeInTheDocument();
|