fix(timeline): keep a compact letter's date unless the title embeds it
`showDate = !compact || !entry.title` dropped the date chip for ANY titled compact letter. But titles are free-form OCR/import text — a letter titled "Brief an Mutter" lost its month/day entirely, and inside an event card the band frames only the year. The chip now drops only when the formatted date actually appears in the title (e.g. "H-0023 – 6. Juli 1916"), so the row-height win holds where valid and no information is lost otherwise. The spec that asserted the date vanishes for any title is rewritten to the correct contract, plus an inverse test. Fixes review finding #4. Refs #850 Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
This commit is contained in:
@@ -152,14 +152,26 @@ describe('LetterCard — event-cluster variants (#850, REQ-002)', () => {
|
||||
expect(document.querySelector('[data-testid="tag-chip"]')).not.toBeNull();
|
||||
});
|
||||
|
||||
it('drops the redundant date line in the compact variant when a title is present (#850)', () => {
|
||||
// Inside an event card the year already frames the time, and these archive titles
|
||||
// embed the date — so the compact in-card letter omits the date chip.
|
||||
render(LetterCard, { entry: makeEntry({ title: 'H-0023 – 6. Juli 1916' }), compact: true });
|
||||
it('drops the compact date chip only when the title actually embeds the formatted date (#850)', () => {
|
||||
// An archive title like "H-0023 – 6. Juli 1916" already carries the date, so inside an
|
||||
// event card (where the band frames the time) the redundant chip is dropped.
|
||||
const entry = makeEntry({ eventDate: '1916-07-06', precision: 'DAY' });
|
||||
const dateLabel = timelineDateLabel(entry.eventDate, entry.precision, entry.eventDateEnd);
|
||||
render(LetterCard, { entry: { ...entry, title: `H-0023 – ${dateLabel}` }, compact: true });
|
||||
expect(document.querySelector('[data-testid="letter-date"]')).toBeNull();
|
||||
expect(document.body.textContent).toContain('Karl Raddatz'); // sender still shown
|
||||
});
|
||||
|
||||
it('keeps the compact date chip when the title does NOT embed the date (#850, finding #4)', () => {
|
||||
// Titles are free-form OCR text — a titled letter whose title carries no date must keep
|
||||
// its month/day, since inside an event card the band frames only the year.
|
||||
render(LetterCard, {
|
||||
entry: makeEntry({ eventDate: '1916-07-06', precision: 'DAY', title: 'Brief an Mutter' }),
|
||||
compact: true
|
||||
});
|
||||
expect(document.querySelector('[data-testid="letter-date"]')).not.toBeNull();
|
||||
});
|
||||
|
||||
it('keeps the date in the compact variant when the letter has no title (#850)', () => {
|
||||
render(LetterCard, { entry: makeEntry({ title: undefined }), compact: true });
|
||||
expect(document.querySelector('[data-testid="letter-date"]')).not.toBeNull();
|
||||
|
||||
Reference in New Issue
Block a user