feat(timeline): add compact + event variants to LetterCard
The event variant adds the .lcard.ev marker for letters living inside a contained event card; the compact variant tightens the row (py-1, text-xs title) and drops the redundant date chip when the title already embeds the date. suppressTagChip lets a caller that already conveys the topic hide the per-letter root-tag chip. Plain Datum letters are unchanged. Refs #850
This commit is contained in:
@@ -127,3 +127,46 @@ describe('LetterCard', () => {
|
||||
expect(chip?.textContent).toContain('Familie');
|
||||
});
|
||||
});
|
||||
|
||||
describe('LetterCard — event-cluster variants (#850, REQ-002)', () => {
|
||||
it('carries the .lcard.ev class in the event variant (REQ-002)', () => {
|
||||
render(LetterCard, { entry: makeEntry(), variant: 'event' });
|
||||
expect(document.querySelector('a.lcard.ev')).not.toBeNull();
|
||||
});
|
||||
|
||||
it('is a plain card with no .ev marker by default (REQ-006)', () => {
|
||||
render(LetterCard, { entry: makeEntry() });
|
||||
expect(document.querySelector('a.ev')).toBeNull();
|
||||
});
|
||||
|
||||
it('suppresses the per-letter tag chip when asked, even with a root tag', () => {
|
||||
render(LetterCard, {
|
||||
entry: makeEntry({ rootTagName: 'Krieg', rootTagColor: 'sienna' }),
|
||||
suppressTagChip: true
|
||||
});
|
||||
expect(document.querySelector('[data-testid="tag-chip"]')).toBeNull();
|
||||
});
|
||||
|
||||
it('still shows the per-letter tag chip when not suppressed', () => {
|
||||
render(LetterCard, { entry: makeEntry({ rootTagName: 'Krieg', rootTagColor: 'sienna' }) });
|
||||
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 });
|
||||
expect(document.querySelector('[data-testid="letter-date"]')).toBeNull();
|
||||
expect(document.body.textContent).toContain('Karl Raddatz'); // sender still shown
|
||||
});
|
||||
|
||||
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();
|
||||
});
|
||||
|
||||
it('renders the compact variant on a single tighter row (#850)', () => {
|
||||
render(LetterCard, { entry: makeEntry(), compact: true });
|
||||
expect(document.querySelector('a.lcard.compact')).not.toBeNull();
|
||||
});
|
||||
});
|
||||
|
||||
Reference in New Issue
Block a user