|
1 | 1 | import { describe, expect, it, vi, beforeEach, afterEach } from 'vitest'; |
2 | | -import { screen, waitFor } from '@testing-library/react'; |
| 2 | +import { screen, waitFor, within } from '@testing-library/react'; |
3 | 3 | import { renderScreen, mockPaginated } from './test-utils.js'; |
4 | 4 | import { HelpWantedIndex } from '../src/screens/HelpWantedIndex.js'; |
5 | 5 | import { AuthProvider } from '../src/hooks/useAuth.js'; |
@@ -78,4 +78,22 @@ describe('HelpWantedIndex', () => { |
78 | 78 | expect(screen.getByLabelText('≤ 5 hrs/week')).toBeInTheDocument(); |
79 | 79 | expect(screen.getByLabelText('≤ 10 hrs/week')).toBeInTheDocument(); |
80 | 80 | }); |
| 81 | + |
| 82 | + it('keeps every filter control inside the one Filters landmark', async () => { |
| 83 | + renderScreen( |
| 84 | + <AuthProvider> |
| 85 | + <HelpWantedIndex /> |
| 86 | + </AuthProvider>, |
| 87 | + { initialEntries: ['/help-wanted'] }, |
| 88 | + ); |
| 89 | + |
| 90 | + const sidebars = await screen.findAllByRole('complementary'); |
| 91 | + expect(sidebars).toHaveLength(1); |
| 92 | + const sidebar = sidebars[0]!; |
| 93 | + expect(sidebar).toHaveAccessibleName('Filters'); |
| 94 | + // Commitment rides inside the same landmark as the tag facets rather |
| 95 | + // than sitting orphaned beside it. |
| 96 | + expect(within(sidebar).getByRole('heading', { name: 'Commitment', level: 2 })).toBeInTheDocument(); |
| 97 | + expect(within(sidebar).getByLabelText('≤ 2 hrs/week')).toBeInTheDocument(); |
| 98 | + }); |
81 | 99 | }); |
0 commit comments