places: offer a newer description in the refresh pill

The pill compared website, phone, e-mail and hours only, so a description
the community published never showed up on a saved place. It now reads the
index description or the OSM summary, compares it as plain words against
the editor's markup, and shows it clamped to three lines.
This commit is contained in:
Maurice
2026-10-30 22:42:22 +01:00
parent 5822910f40
commit 8d8629516b
3 changed files with 37 additions and 4 deletions
@@ -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: `<p>${text}</p>` }), { 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([]);