merge: update Tours branch with current Places filters

This commit is contained in:
elmocito
2026-10-05 01:50:47 +02:00
63 changed files with 1008 additions and 183 deletions
@@ -17,7 +17,7 @@ import { openLeg } from '../../../helpers/legAlternatives'
import { RT_ALT_BAR_LIFT } from '../../../../src/mobile/screens/trip/roadtrip/useMRtAlternatives'
import { corePoiCategories, pluginPoiCategories } from '../../../../src/components/Map/usePoiCategories'
// FE-MOB-MAPAREA-001 to FE-MOB-MAPAREA-045
// FE-MOB-MAPAREA-001 to FE-MOB-MAPAREA-049
//
// The stage's pins come out of the trip store rather than the planner's map list, so the
// stage fixtures seed the store and leave `mapPlaces` to stand for what the plan tab shows.
@@ -183,7 +183,7 @@ beforeEach(() => {
moved: false, toggle: vi.fn(), searchArea: vi.fn(), onViewportChange: vi.fn(),
}
useSettingsStore.setState(s => ({ settings: { ...s.settings, map_poi_pill_enabled: true } }))
seedStore(useTripStore, { places: [], placesFilter: 'all', placesCategoryFilter: new Set<string>() })
seedStore(useTripStore, { places: [], placesFilter: 'all', placesCategoryFilter: new Set<string>(), placesRatingFilter: 'all' })
})
describe('MMapArea', () => {
@@ -952,3 +952,41 @@ describe('MMapArea and a booked night at the edge of the stage', () => {
expect(mocks.poi.toggle).toHaveBeenCalledWith('plugin:trail-finder/trailheads')
})
})
describe('MMapArea — places filter', () => {
it('FE-MOB-MAPAREA-046: the plan map offers the places filter, and a tap opens its sheet', () => {
const { shell } = renderArea({ trTab: 'plan' })
const pill = screen.getByTestId('places-filter-pill')
expect(pill).toHaveAccessibleName('Filters')
// It opens a sheet: a dialog to announce, not an on/off state.
expect(pill).toHaveAttribute('aria-haspopup', 'dialog')
expect(pill).not.toHaveAttribute('aria-pressed')
act(() => { pill.click() })
expect(shell.openSheet).toHaveBeenCalledWith('placesFilter')
})
it('FE-MOB-MAPAREA-047: the pill lights up and counts the filters narrowing the pins', () => {
seedStore(useTripStore, { placesFilter: 'unplanned', placesRatingFilter: 4 })
renderArea({ trTab: 'plan' })
const pill = screen.getByTestId('places-filter-pill')
expect(pill).toHaveClass('text-accent')
expect(pill).not.toHaveAttribute('aria-pressed')
expect(pill).toHaveAttribute('aria-haspopup', 'dialog')
expect(pill).toHaveAccessibleName('Filters (2)')
expect(screen.getByText('2')).toHaveAttribute('aria-hidden', 'true')
})
it('FE-MOB-MAPAREA-049: a road trip keeps the places filter on its plan map, Dawarich or not', () => {
// The stack used to stand down in road-trip mode unless Dawarich had a pill in
// it; the plan map still shows the trip's places there, so its filter stays.
renderArea({ trTab: 'plan' }, { roadtripActive: true, dawarichEnabled: false })
expect(screen.getByTestId('places-filter-pill')).toBeInTheDocument()
})
it('FE-MOB-MAPAREA-048: the stage draws its own pins, so it has no places filter, and neither has a covered map', () => {
renderArea({ trTab: 'roadtrip', mapFront: true })
expect(screen.queryByTestId('places-filter-pill')).not.toBeInTheDocument()
renderArea({ view: 'plan', mapFront: false })
expect(screen.queryByTestId('places-filter-pill')).not.toBeInTheDocument()
})
})
@@ -1,16 +1,17 @@
import { afterEach, beforeEach, describe, expect, it, vi } from 'vitest'
import { act, fireEvent, render, screen, waitFor } from '../../../helpers/render'
import { act, fireEvent, render, screen, waitFor, within } from '../../../helpers/render'
import { buildPlanner, buildShell } from '../../../helpers/mobileTrip'
import MPlacesBrowser from '../../../../src/mobile/screens/trip/places/MPlacesBrowser'
import { collectionsApi } from '../../../../src/api/collections'
import type { CollectionListResponse } from '@trek/shared'
import { toursApi } from '../../../../src/api/client'
import type { CollectionListResponse, TourListItem } from '@trek/shared'
import { useAddonStore } from '../../../../src/store/addonStore'
import { useTripStore } from '../../../../src/store/tripStore'
import { resetAllStores, seedStore } from '../../../helpers/store'
import type { MTripShellApi, TripPlanner } from '../../../../src/mobile/screens/trip/MTripShell'
import type { AssignmentsMap, Category, Day, Place } from '../../../../src/types'
// FE-MOB-PBROW-001 to FE-MOB-PBROW-031
// FE-MOB-PBROW-001 to FE-MOB-PBROW-036
const CATEGORIES = [
{ id: 1, name: 'Sights', color: '#123456', icon: 'landmark' },
@@ -125,11 +126,11 @@ describe('MPlacesBrowser', () => {
expect(screen.queryByText('Louvre')).not.toBeInTheDocument()
})
it('FE-MOB-PBROW-007: hides the tracks chip and falls back to all when the last track is gone', () => {
seedStore(useTripStore, { placesFilter: 'tracks' })
// The fall back to "all" once the last track is gone lives in useTripPlanner
// (FE-TP-HOOK-177), which stays mounted while this browser is not.
it('FE-MOB-PBROW-007: hides the tracks chip when no place carries a track', () => {
renderBrowser(makePlanner({ places: [LOUVRE, EIFFEL] } as Partial<TripPlanner>))
expect(screen.queryByRole('button', { name: 'places.filterTracks' })).not.toBeInTheDocument()
expect(useTripStore.getState().placesFilter).toBe('all')
expect(screen.getByText('places.count:2')).toBeInTheDocument()
})
@@ -153,7 +154,7 @@ describe('MPlacesBrowser', () => {
it('FE-MOB-PBROW-010: the category panel toggles the shared filter set and badges its size', () => {
renderBrowser()
const catBtn = screen.getByRole('button', { name: 'places.allCategories' })
const catBtn = screen.getByRole('button', { name: 'places.filters' })
expect(catBtn).toHaveAttribute('aria-expanded', 'false')
fireEvent.click(catBtn)
expect(catBtn).toHaveAttribute('aria-expanded', 'true')
@@ -169,10 +170,63 @@ describe('MPlacesBrowser', () => {
expect(useTripStore.getState().placesCategoryFilter.size).toBe(0)
})
it('FE-MOB-PBROW-032: the panel rating floor narrows the list, badges the button and lands in the store', () => {
const planner = makePlanner({
places: [{ ...LOUVRE, rating_avg: 4.5 }, { ...EIFFEL, rating_avg: 3 }, SEINE],
} as Partial<TripPlanner>)
renderBrowser(planner)
const panelBtn = screen.getByRole('button', { name: 'places.filters' })
fireEvent.click(panelBtn)
const floors = screen.getByRole('group', { name: 'Filter by rating' })
fireEvent.click(within(floors).getByRole('button', { name: '4+' }))
expect(useTripStore.getState().placesRatingFilter).toBe(4)
expect(within(floors).getByRole('button', { name: '4+' })).toHaveAttribute('aria-pressed', 'true')
expect(screen.getByText('Louvre')).toBeInTheDocument()
expect(screen.queryByText('Eiffel Tower')).not.toBeInTheDocument()
expect(screen.queryByText('Seine Track')).not.toBeInTheDocument()
expect(panelBtn).toHaveTextContent('1')
fireEvent.click(within(floors).getByRole('button', { name: 'All' }))
expect(useTripStore.getState().placesRatingFilter).toBe('all')
expect(screen.getByText('Seine Track')).toBeInTheDocument()
})
it('FE-MOB-PBROW-035: the panel badge counts kinds of filter, like the map badge', () => {
renderBrowser()
const panelBtn = screen.getByRole('button', { name: 'places.filters' })
fireEvent.click(panelBtn)
fireEvent.click(screen.getByRole('checkbox', { name: 'Sights' }))
fireEvent.click(screen.getByRole('checkbox', { name: 'Food' }))
// Two categories are one kind of filter.
expect(panelBtn).toHaveTextContent('1')
fireEvent.click(within(screen.getByRole('group', { name: 'Filter by rating' })).getByRole('button', { name: '4+' }))
expect(panelBtn).toHaveTextContent('2')
// The pool has its own chips in plain sight, so the panel badge leaves it out.
fireEvent.click(screen.getByRole('button', { name: 'places.unplanned' }))
expect(panelBtn).toHaveTextContent('2')
})
it('FE-MOB-PBROW-036: a new rating floor starts a fresh selection, as a new pool does', () => {
renderBrowser()
fireEvent.click(screen.getByRole('button', { name: 'common.select' }))
fireEvent.click(row('Louvre'))
expect(screen.getByText('places.selectionCount:1')).toBeInTheDocument()
fireEvent.click(screen.getByRole('button', { name: 'places.filters' }))
fireEvent.click(within(screen.getByRole('group', { name: 'Filter by rating' })).getByRole('button', { name: '1+' }))
expect(screen.queryByText('places.selectionCount:1')).not.toBeInTheDocument()
})
it('FE-MOB-PBROW-033: a floor set from the map sheet already thins the list on arrival', () => {
seedStore(useTripStore, { placesRatingFilter: 5 })
renderBrowser(makePlanner({ places: [{ ...LOUVRE, rating_avg: 5 }, EIFFEL] } as Partial<TripPlanner>))
expect(screen.getByText('Louvre')).toBeInTheDocument()
expect(screen.queryByText('Eiffel Tower')).not.toBeInTheDocument()
})
it('FE-MOB-PBROW-011: the uncategorized row filters the places without a category', () => {
renderBrowser()
fireEvent.click(screen.getByRole('button', { name: 'places.allCategories' }))
fireEvent.click(screen.getByRole('checkbox', { name: 'places.noCategory' }))
fireEvent.click(screen.getByRole('button', { name: 'places.filters' }))
fireEvent.click(screen.getByRole('checkbox', { name: 'No Category' }))
expect([...useTripStore.getState().placesCategoryFilter]).toEqual(['uncategorized'])
expect(screen.getByText('Eiffel Tower')).toBeInTheDocument()
expect(screen.queryByText('Louvre')).not.toBeInTheDocument()
@@ -181,8 +235,8 @@ describe('MPlacesBrowser', () => {
it('FE-MOB-PBROW-012: the uncategorized row is dropped when every place has a category', () => {
const planner = makePlanner({ places: [LOUVRE, SEINE] } as Partial<TripPlanner>)
renderBrowser(planner)
fireEvent.click(screen.getByRole('button', { name: 'places.allCategories' }))
expect(screen.queryByRole('checkbox', { name: 'places.noCategory' })).not.toBeInTheDocument()
fireEvent.click(screen.getByRole('button', { name: 'places.filters' }))
expect(screen.queryByRole('checkbox', { name: 'No Category' })).not.toBeInTheDocument()
expect(screen.getByRole('checkbox', { name: 'Food' })).toBeInTheDocument()
})
@@ -308,6 +362,34 @@ describe('MPlacesBrowser', () => {
expect(screen.getByRole('button', { name: 'common.deselectAll' })).toBeInTheDocument()
})
it('keeps Tour-backed Places out of the Places pool and Tours mode browse/attach only', async () => {
const ridge: TourListItem = {
place_id: TOUR.id, name: 'Ridge walk', tour_type: 'hike', distance: 4, elevation_gain: 100,
elevation_loss: 80, duration: null, difficulty: null, wanderer_ref: null, match_confidence: 1,
tour_group_id: null, max_hiking_difficulty: 2, planned: false, caution: false,
}
seedStore(useAddonStore, { addons: [{ id: 'collections', enabled: true }, { id: 'tours', enabled: true }] })
vi.spyOn(toursApi, 'list').mockResolvedValue({ tours: [ridge] })
const planner = makePlanner({
places: [...PLACES, TOUR],
tours: [ridge],
isTourPlace: vi.fn((placeId: number) => placeId === TOUR.id),
})
const { shell } = renderBrowser(planner)
await waitFor(() => expect(screen.getByText('places.count:3')).toBeInTheDocument())
expect(screen.queryByText('Ridge walk')).not.toBeInTheDocument()
expect(toursApi.list).toHaveBeenCalledWith(planner.tripId)
fireEvent.click(screen.getByRole('tab', { name: /^Tours$/i }))
expect(screen.getByRole('option', { name: /Ridge walk/ })).toBeInTheDocument()
expect(screen.queryByText('Louvre')).not.toBeInTheDocument()
expect(screen.queryByRole('button', { name: 'mobileTrip.importPlaces' })).not.toBeInTheDocument()
expect(screen.queryByRole('button', { name: 'common.add' })).not.toBeInTheDocument()
expect(screen.queryByRole('button', { name: 'common.select' })).not.toBeInTheDocument()
expect(screen.getByRole('button', { name: /tours.addToDay|Add to day/i })).toBeInTheDocument()
})
it('FE-MOB-PBROW-020b: a failed bulk delete keeps the selection for a retry', async () => {
const planner = makePlanner()
;(planner.confirmDeletePlaces as ReturnType<typeof vi.fn>).mockRejectedValueOnce(new Error('nope'))
@@ -380,6 +462,13 @@ describe('MPlacesBrowser', () => {
expect(screen.queryByText('places.noneFound')).not.toBeInTheDocument()
})
it('FE-MOB-PBROW-034: an unplanned pool emptied by the rating floor reports no matches, not "all planned"', () => {
seedStore(useTripStore, { placesRatingFilter: 5 })
renderBrowser(makePlanner({ places: [EIFFEL] } as Partial<TripPlanner>), buildShell({ browseFromEdit: true }))
expect(screen.getByText('places.noneFound')).toBeInTheDocument()
expect(screen.queryByText('places.allPlanned')).not.toBeInTheDocument()
})
it('FE-MOB-PBROW-028: a search without hits reports no matches', () => {
renderBrowser()
fireEvent.change(screen.getByPlaceholderText('places.search'), { target: { value: 'zzz' } })
@@ -416,7 +505,7 @@ describe('MPlacesBrowser', () => {
// Narrow to the two categorised places: two visible, two selected — but not
// the same two, so the toolbar must still offer select-all.
fireEvent.click(screen.getByRole('button', { name: 'places.allCategories' }))
fireEvent.click(screen.getByRole('button', { name: 'places.filters' }))
fireEvent.click(screen.getByRole('checkbox', { name: 'Sights' }))
fireEvent.click(screen.getByRole('checkbox', { name: 'Food' }))
@@ -0,0 +1,128 @@
import { beforeEach, describe, expect, it, vi } from 'vitest'
import { fireEvent, render, screen, within } from '../../../helpers/render'
import MPlacesFilterSheet from '../../../../src/mobile/screens/trip/places/MPlacesFilterSheet'
import { useTripStore } from '../../../../src/store/tripStore'
import { resetAllStores, seedStore } from '../../../helpers/store'
import { buildPlace } from '../../../helpers/factories'
import type { Category, Place } from '../../../../src/types'
// FE-MOB-PFSHEET-001 to FE-MOB-PFSHEET-009
const CATEGORIES = [
{ id: 1, name: 'Sights', color: '#123456', icon: 'landmark' },
{ id: 2, name: 'Food', color: '', icon: 'utensils' },
] as unknown as Category[]
const TAGGED = buildPlace({ id: 1, category_id: 1 })
const BARE = buildPlace({ id: 2, category_id: null })
const TRACK = buildPlace({ id: 3, category_id: 2, route_geometry: '[[1,2],[3,4]]' })
function renderSheet({ places = [TAGGED, BARE], categories = CATEGORIES, open = true, toursEnabled = false }: {
places?: Place[]
categories?: Category[]
open?: boolean
toursEnabled?: boolean
} = {}) {
const onClose = vi.fn()
render(<MPlacesFilterSheet open={open} onClose={onClose} places={places} categories={categories} toursEnabled={toursEnabled} />)
return { onClose }
}
const group = (name: string) => screen.getByRole('group', { name })
describe('MPlacesFilterSheet', () => {
beforeEach(() => {
resetAllStores()
})
it('FE-MOB-PFSHEET-001: shows the pool, the rating floors and the categories under one title', async () => {
renderSheet()
const sheet = await screen.findByRole('dialog', { name: 'Filters' })
expect(within(sheet).getByText('Show')).toBeInTheDocument()
expect(within(group('Show')).getAllByRole('button').map(b => b.textContent)).toEqual(['All', 'Unplanned', 'Planned'])
expect(within(group('Filter by rating')).getAllByRole('button').map(b => b.textContent))
.toEqual(['All', '5+', '4+', '3+', '2+', '1+'])
expect(screen.getByRole('checkbox', { name: 'Sights' })).toBeInTheDocument()
expect(screen.getByRole('checkbox', { name: 'Food' })).toBeInTheDocument()
expect(screen.getByRole('checkbox', { name: 'No Category' })).toBeInTheDocument()
})
it('FE-MOB-PFSHEET-002: the tracks pool only shows once a place carries a track', async () => {
renderSheet({ places: [TAGGED, TRACK] })
await screen.findByRole('dialog', { name: 'Filters' })
expect(within(group('Show')).getByRole('button', { name: 'Tracks' })).toBeInTheDocument()
expect(screen.queryByRole('checkbox', { name: 'No Category' })).not.toBeInTheDocument()
})
it('hides Tracks from the map filter while Tours is enabled', async () => {
const tourTrack = buildPlace({ id: 4, route_geometry: '[[5,6],[7,8]]' })
renderSheet({ places: [TAGGED, TRACK, tourTrack], toursEnabled: true })
await screen.findByRole('dialog', { name: 'Filters' })
expect(within(group('Show')).queryByRole('button', { name: 'Tracks' })).not.toBeInTheDocument()
})
it('FE-MOB-PFSHEET-003: picking a pool writes it to the trip store', async () => {
renderSheet()
await screen.findByRole('dialog', { name: 'Filters' })
const show = group('Show')
expect(within(show).getByRole('button', { name: 'All' })).toHaveAttribute('aria-pressed', 'true')
fireEvent.click(within(show).getByRole('button', { name: 'Unplanned' }))
expect(useTripStore.getState().placesFilter).toBe('unplanned')
// The chosen chip says so to a screen reader, and only that one.
expect(within(show).getByRole('button', { name: 'Unplanned' })).toHaveAttribute('aria-pressed', 'true')
expect(within(show).getByRole('button', { name: 'All' })).toHaveAttribute('aria-pressed', 'false')
})
it('FE-MOB-PFSHEET-004: picking a floor writes the rating filter to the trip store', async () => {
renderSheet()
await screen.findByRole('dialog', { name: 'Filters' })
const floors = group('Filter by rating')
fireEvent.click(within(floors).getByRole('button', { name: '3+' }))
expect(useTripStore.getState().placesRatingFilter).toBe(3)
expect(within(floors).getByRole('button', { name: '3+' })).toHaveAttribute('aria-pressed', 'true')
expect(within(floors).getByRole('button', { name: 'All' })).toHaveAttribute('aria-pressed', 'false')
})
it('FE-MOB-PFSHEET-005: categories toggle in and out of the shared set, "no category" included', async () => {
renderSheet()
await screen.findByRole('dialog', { name: 'Filters' })
fireEvent.click(screen.getByRole('checkbox', { name: 'Food' }))
fireEvent.click(screen.getByRole('checkbox', { name: 'No Category' }))
expect([...useTripStore.getState().placesCategoryFilter]).toEqual(['2', 'uncategorized'])
expect(screen.getByRole('checkbox', { name: 'Food' })).toHaveAttribute('aria-checked', 'true')
fireEvent.click(screen.getByRole('checkbox', { name: 'Food' }))
expect([...useTripStore.getState().placesCategoryFilter]).toEqual(['uncategorized'])
})
it('FE-MOB-PFSHEET-006: reset lifts every filter, and stays off while nothing filters', async () => {
seedStore(useTripStore, { placesFilter: 'planned', placesCategoryFilter: new Set(['1']), placesRatingFilter: 5 })
renderSheet()
await screen.findByRole('dialog', { name: 'Filters' })
const reset = screen.getByRole('button', { name: 'Reset' })
expect(reset).toBeEnabled()
fireEvent.click(reset)
const s = useTripStore.getState()
expect(s.placesFilter).toBe('all')
expect(s.placesCategoryFilter.size).toBe(0)
expect(s.placesRatingFilter).toBe('all')
expect(screen.getByRole('button', { name: 'Reset' })).toBeDisabled()
})
it('FE-MOB-PFSHEET-007: without any category to choose, the categories section is left out', async () => {
renderSheet({ places: [TAGGED], categories: [] })
const sheet = await screen.findByRole('dialog', { name: 'Filters' })
expect(within(sheet).queryByText('Categories')).not.toBeInTheDocument()
expect(screen.queryByRole('checkbox')).not.toBeInTheDocument()
})
it('FE-MOB-PFSHEET-008: the close button hands back to the caller', async () => {
const { onClose } = renderSheet()
fireEvent.click(within(await screen.findByRole('dialog', { name: 'Filters' })).getByRole('button', { name: 'Close' }))
expect(onClose).toHaveBeenCalledTimes(1)
})
it('FE-MOB-PFSHEET-009: nothing is rendered while closed', () => {
renderSheet({ open: false })
expect(screen.queryByRole('dialog', { name: 'Filters' })).not.toBeInTheDocument()
})
})
@@ -481,8 +481,8 @@ describe('NoteRow', () => {
expect(screen.getByText('09:30')).toBeInTheDocument()
expect(screen.getByText('Buy museum tickets')).toBeInTheDocument()
// Two separate blocks since #1629: the extra title lines are plain text, the
// detail is rendered Markdown, so they cannot be joined into one string.
// Two separate blocks since #1629: the extra title lines and the detail are
// each rendered Markdown, so they cannot be joined into one string.
expect(screen.getByText('Cash only')).toBeInTheDocument()
expect(screen.getByText('at the kiosk')).toBeInTheDocument()
})
@@ -532,6 +532,17 @@ describe('NoteRow', () => {
fireEvent.click(screen.getByText('Buy museum tickets'))
expect(onEdit).toHaveBeenCalledTimes(1)
})
it('FE-MOB-PLROW-045: extra title lines keep their line breaks and turn a pasted URL into a link (#2576)', () => {
const url = 'https://www.google.com/maps/place/Museum/@48.1371079,11.5753822,17z/data=!3m1!4b1!4m6!3m5!1s0x0'
const { container } = render(<NoteRow {...base} note={note({ text: `Museum
Open at nine
${url}`, time: null })} />)
expect(screen.getByRole('link', { name: url })).toHaveAttribute('href', url)
// remark-breaks turns the kept newline into a <br>; joined with a space it would not be there.
expect(container.querySelector('.collab-note-md br')).not.toBeNull()
})
})
// ── Blur booking codes on the plan row (#2457) ────────────────────────────────
@@ -11,9 +11,9 @@ import { useSettingsStore } from '../../../../src/store/settingsStore'
import { useTripStore } from '../../../../src/store/tripStore'
import { buildPlanner, buildShell } from '../../../helpers/mobileTrip'
import { resetAllStores, seedStore } from '../../../helpers/store'
import { fireEvent, render, screen, waitFor } from '../../../helpers/render'
import { fireEvent, render, screen, waitFor, within } from '../../../helpers/render'
// FE-MOB-SHOST-001 to FE-MOB-SHOST-029 and FE-MOB-SHOST-032 (030 and 031 live in MTripSheets.members.test.tsx)
// FE-MOB-SHOST-001 to FE-MOB-SHOST-029, FE-MOB-SHOST-032 and FE-MOB-SHOST-033 (030 and 031 live in MTripSheets.members.test.tsx)
//
// Every child sheet is stubbed: this file is about the host — which sheet is
// mounted for which shell.sheet id, and how the host's own callbacks wire the
@@ -238,6 +238,18 @@ describe('MTripSheets', () => {
}
})
it('FE-MOB-SHOST-033: the map\'s places filter opens for its own id and closes through the shell', async () => {
const { shell } = renderHost({}, { sheet: { id: 'placesFilter' } })
const sheet = await screen.findByRole('dialog', { name: 'Filters' })
fireEvent.click(within(sheet).getByRole('button', { name: 'Close' }))
expect(shell.closeSheet).toHaveBeenCalledTimes(1)
})
it('FE-MOB-SHOST-033b: no places filter while another sheet is open', () => {
renderHost({}, { sheet: { id: 'day' } })
expect(screen.queryByRole('dialog', { name: 'Filters' })).not.toBeInTheDocument()
})
it('FE-MOB-SHOST-004: hands the note payload to the note sheet and only for that id', () => {
renderHost({}, { sheet: { id: 'note', payload: { dayId: 4 } } })
expect(screen.getByTestId('stub-note')).toHaveAttribute('data-day', '4')
+26
View File
@@ -354,6 +354,32 @@ describe('tripStore', () => {
});
});
describe('places filters', () => {
it('FE-TRIP-PF-001: the rating floor starts at "all" and is shared through the store', () => {
expect(useTripStore.getState().placesRatingFilter).toBe('all');
useTripStore.getState().setPlacesRatingFilter(4);
expect(useTripStore.getState().placesRatingFilter).toBe(4);
});
it('FE-TRIP-PF-002: resetPlacesFilters lifts the pool, the categories and the rating at once', () => {
const s = useTripStore.getState();
s.setPlacesFilter('unplanned');
s.setPlacesCategoryFilter(new Set(['3', 'uncategorized']));
s.setPlacesRatingFilter(5);
useTripStore.getState().resetPlacesFilters();
const after = useTripStore.getState();
expect(after.placesFilter).toBe('all');
expect(after.placesCategoryFilter.size).toBe(0);
expect(after.placesRatingFilter).toBe('all');
});
it('FE-TRIP-PF-003: resetTrip drops the rating floor of the previous trip', () => {
useTripStore.getState().setPlacesRatingFilter(3);
useTripStore.getState().resetTrip();
expect(useTripStore.getState().placesRatingFilter).toBe('all');
});
});
describe('addTag', () => {
it('FE-TRIP-010: addTag creates tag and appends to tags', async () => {
const existingTag = buildTag();