Skip to content

Commit 7751a03

Browse files
committed
compact comments
1 parent 1691fa1 commit 7751a03

2 files changed

Lines changed: 6 additions & 16 deletions

File tree

src/pages/components/LineSelector.test.tsx

Lines changed: 3 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -3,8 +3,6 @@ import { useAllRoutes } from 'src/hooks/useAllRoutes'
33
import i18n from 'src/locale/allTranslations'
44
import LineSelector from './LineSelector'
55

6-
// Keep the real API client / gtfsService out of the test: LineSelector only
7-
// reads `line` and `suffix` off each route, so a mocked hook is enough.
86
vi.mock('src/hooks/useAllRoutes', () => ({ useAllRoutes: vi.fn() }))
97
const mockUseAllRoutes = vi.mocked(useAllRoutes)
108

@@ -26,7 +24,6 @@ const route = (line: number, suffix = ''): RouteItem => ({
2624
routeKey: `${line}${suffix}-key`,
2725
})
2826

29-
// useAllRoutes already returns routes sorted by line number; mirror that here.
3027
const setRoutes = (routes: RouteItem[], isLoading = false) =>
3128
mockUseAllRoutes.mockReturnValue({ routes, isLoading, error: false })
3229

@@ -80,7 +77,7 @@ describe('LineSelector', () => {
8077
fireEvent.change(screen.getByRole('combobox', { name: LINE_LABEL }), {
8178
target: { value: '42' },
8279
})
83-
expect(setLineNumber).not.toHaveBeenCalled() // debounced, not immediate
80+
expect(setLineNumber).not.toHaveBeenCalled()
8481

8582
act(() => {
8683
vi.advanceTimersByTime(DEBOUNCE_MS)
@@ -92,20 +89,15 @@ describe('LineSelector', () => {
9289
setRoutes([route(1)])
9390
renderSelector()
9491

95-
// `MuiAutocomplete-inputRoot` carries the compact vertical padding that keeps
96-
// this field the same height as the other selectors — its absence was the
97-
// 74px-vs-56px regression. `forcePopupIcon` keeps the dropdown arrow so it
98-
// looks like OperatorSelector / RouteSelector rather than a bare text field.
92+
// `MuiAutocomplete-inputRoot` keeps this field the same height as the other selectors.
9993
expect(
10094
screen.getByRole('combobox', { name: LINE_LABEL }).closest(AUTOCOMPLETE_INPUT_ROOT),
10195
).not.toBeNull()
10296
expect(screen.getByRole('button', { name: OPEN_BUTTON })).toBeInTheDocument()
10397
})
10498

10599
it('tags the clear button with the `clear-indicator` class the e2e helper relies on', () => {
106-
// The `clearInputField` Playwright helper (clearButton.spec.ts) finds the
107-
// clear button by the repo-wide `.clear-indicator` class. MUI's built-in
108-
// clear indicator only renders once the field has a value to clear.
100+
// MUI only renders its clear indicator once the field has a value to clear.
109101
setRoutes([route(5)])
110102
renderSelector({ lineNumber: '5' })
111103

src/pages/components/LineSelector.tsx

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -28,8 +28,7 @@ const LineSelector = ({
2828
setValue(lineNumber ?? '')
2929
}, [])
3030

31-
// Distinct line numbers running for the selected operator + date. `routes` is
32-
// already sorted by line number in useAllRoutes, so a Set preserves that order.
31+
// `routes` is already sorted by line number in useAllRoutes, so a Set preserves that order.
3332
const options = useMemo(() => {
3433
const seen = new Set<string>()
3534
const result: string[] = []
@@ -53,9 +52,8 @@ const LineSelector = ({
5352
disabled={disabled}
5453
loading={isLoading}
5554
options={options}
56-
// Tag MUI's built-in clear button with the repo-wide `clear-indicator`
57-
// class (the same hook VehicleSelector's ClearButton and Selector.scss use)
58-
// so the e2e `clearInputField` helper can find it.
55+
// The e2e `clearInputField` helper finds the clear button by the repo-wide
56+
// `clear-indicator` class, which MUI's built-in one doesn't carry.
5957
slotProps={{ clearIndicator: { className: 'clear-indicator' } }}
6058
inputValue={value}
6159
onInputChange={(_event, newValue, reason) => {

0 commit comments

Comments
 (0)