diff --git a/client/src/components/Planner/PlaceRefreshPill.tsx b/client/src/components/Planner/PlaceRefreshPill.tsx
index 390255b3f..1f4e708e5 100644
--- a/client/src/components/Planner/PlaceRefreshPill.tsx
+++ b/client/src/components/Planner/PlaceRefreshPill.tsx
@@ -10,6 +10,7 @@ import type { RefreshCandidate, RefreshField } from './placeRefresh';
type Translate = (key: string, params?: Record
+
{line}
))} @@ -110,7 +111,7 @@ export function PlaceRefreshPill({ {t('places.refresh.new')} {shown(c.field, c.next, locale, t).map((line) => ( -+
{line}
))} diff --git a/client/src/components/Planner/placeRefresh.test.ts b/client/src/components/Planner/placeRefresh.test.ts index 2a46d7607..584fc4a4a 100644 --- a/client/src/components/Planner/placeRefresh.test.ts +++ b/client/src/components/Planner/placeRefresh.test.ts @@ -1,4 +1,4 @@ -// FE-PLANNER-REFRESH-001 to FE-PLANNER-REFRESH-005 +// FE-PLANNER-REFRESH-001 to FE-PLANNER-REFRESH-007 import { describe, expect, it } from 'vitest'; import { DEFAULT_FORM, type PlaceFormData } from './PlaceFormModal.helpers'; import { refreshCandidates } from './placeRefresh'; @@ -46,6 +46,24 @@ describe('refreshCandidates', () => { expect(refreshCandidates(form({ opening_hours: hours?.next }), { opening_periods: PERIODS })).toEqual([]); }); + it('FE-PLANNER-REFRESH-006: a description comes from the index object or the OSM summary', () => { + const text = 'An Asian restaurant in Evershagen.'; + expect(refreshCandidates(form(), { description: { text, source: 'community' } })).toEqual([ + { field: 'description', current: '', next: text, preselected: true }, + ]); + expect(refreshCandidates(form(), { summary: text, summary_source: 'community' })).toEqual([ + { field: 'description', current: '', next: text, preselected: true }, + ]); + }); + + it('FE-PLANNER-REFRESH-007: the same description under the editor markup is no difference', () => { + const text = 'An Asian restaurant in Evershagen.'; + expect(refreshCandidates(form({ description: `${text}
` }), { summary: text })).toEqual([]); + expect(refreshCandidates(form({ description: 'Our favourite.' }), { summary: text })).toEqual([ + { field: 'description', current: 'Our favourite.', next: text, preselected: false }, + ]); + }); + it('FE-PLANNER-REFRESH-005: what the lookup does not know is never offered, so nothing is emptied', () => { expect(refreshCandidates(form({ phone: '0381 1111', website: 'https://a.example' }), {})).toEqual([]); expect(refreshCandidates(form(), null)).toEqual([]); diff --git a/client/src/components/Planner/placeRefresh.ts b/client/src/components/Planner/placeRefresh.ts index 8510ae4e6..5d20b807f 100644 --- a/client/src/components/Planner/placeRefresh.ts +++ b/client/src/components/Planner/placeRefresh.ts @@ -3,7 +3,7 @@ import type { PlaceFormData } from './PlaceFormModal.helpers'; import { cleanWeek, weekFromPeriods, writeWeek } from './placeHours'; /** The details a saved place can take over from a fresh lookup. */ -const REFRESH_FIELDS = ['website', 'phone', 'email', 'opening_hours'] as const; +const REFRESH_FIELDS = ['description', 'website', 'phone', 'email', 'opening_hours'] as const; export type RefreshField = (typeof REFRESH_FIELDS)[number]; /** One field where the lookup says something else than the place holds now. */ @@ -21,9 +21,22 @@ type Details = Record