fix(collections): pins on the map show their place's category (#3073)

The server nests a saved place's category, while the markers and the hover
card read the flat fields a trip place carries, so every pin on a
collection's map was the grey default. The map now hands its places on with
the category's colour, icon and name where the markers look for them.
This commit is contained in:
Maurice
2026-11-12 22:02:05 +01:00
parent 10d1a61614
commit f13a0aa6ee
3 changed files with 45 additions and 2 deletions
@@ -12,6 +12,7 @@ import L from 'leaflet';
import { afterAll, afterEach, beforeAll, beforeEach, describe, expect, it, vi } from 'vitest';
import { act, render, waitFor } from '../../../tests/helpers/render';
import { resetAllStores } from '../../../tests/helpers/store';
import { withMarkerCategory } from '../../pages/collections/collectionsModel';
import CollectionMap from './CollectionMap';
vi.mock('../../hooks/useGeolocation', () => ({
@@ -258,3 +259,26 @@ describe('CollectionMap framing', () => {
expect(wrappedIn(map, '[--bottom-nav-h:0px]')).toBe(true);
});
});
describe('CollectionMap pins (#3073)', () => {
const MUSEUM = { id: 4, name: 'Museum', color: '#7c3aed', icon: 'Landmark' };
it('FE-COMP-COLMAP-008: a saved place carries its category where the markers read it', () => {
const pin = withMarkerCategory({ ...place(1, 'Belvedere', 48.1915, 16.3809), category_id: 4, category: MUSEUM });
expect(pin).toMatchObject({ category_name: 'Museum', category_color: '#7c3aed', category_icon: 'Landmark' });
expect(withMarkerCategory(place(2, 'Somewhere', 48.2, 16.37))).toMatchObject({
category_name: null,
category_color: null,
category_icon: null,
});
});
it('FE-COMP-COLMAP-009: the pin of a place with a category wears its colour, not the grey default', async () => {
const { view } = await renderMap([
{ ...place(1, 'Belvedere', 48.1915, 16.3809), category_id: 4, category: MUSEUM },
]);
await waitFor(() => expect(view.container.querySelector('.leaflet-marker-icon')).not.toBeNull());
const html = view.container.querySelector('.leaflet-marker-icon')?.innerHTML ?? '';
expect(html.toLowerCase()).toContain('#7c3aed');
});
});