feat(timeline): add eventCardConfig accent matrix + DTO test factories

getAccentConfig(entry) maps each EVENT to its glyph (* / † / ⚭ / ★ / ◍), German
redundant-cue label, and accent kind (REQ-007/008/018). test-factories build
TimelineEntryDTO/TimelineDTO mirroring the real wire shape for component specs.

Refs #779
Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
This commit is contained in:
Marcel
2026-06-13 19:26:29 +02:00
parent 607112afc2
commit 6a35e8510b
3 changed files with 125 additions and 0 deletions

View File

@@ -0,0 +1,53 @@
import { describe, it, expect } from 'vitest';
import { getAccentConfig } from './eventCardConfig';
import type { components } from '$lib/generated/api';
type TimelineEntryDTO = components['schemas']['TimelineEntryDTO'];
function event(overrides: Partial<TimelineEntryDTO>): TimelineEntryDTO {
return {
kind: 'EVENT',
precision: 'YEAR',
derived: false,
senderName: '',
receiverName: '',
...overrides
};
}
describe('getAccentConfig', () => {
it('maps a derived birth to the * glyph and "Geburt"', () => {
const cfg = getAccentConfig(event({ derived: true, derivedType: 'BIRTH' }));
expect(cfg.glyph).toBe('*');
expect(cfg.label).toBe('Geburt');
expect(cfg.accent).toBe('derived');
});
it('maps a derived death to the † glyph and "Tod"', () => {
const cfg = getAccentConfig(event({ derived: true, derivedType: 'DEATH' }));
expect(cfg.glyph).toBe('†');
expect(cfg.label).toBe('Tod');
expect(cfg.accent).toBe('derived');
});
it('maps a derived marriage to the ⚭ glyph and "Heirat"', () => {
const cfg = getAccentConfig(event({ derived: true, derivedType: 'MARRIAGE' }));
expect(cfg.glyph).toBe('⚭');
expect(cfg.label).toBe('Heirat');
expect(cfg.accent).toBe('derived');
});
it('maps a HISTORICAL event to the world glyph and "Weltgeschehen"', () => {
const cfg = getAccentConfig(event({ type: 'HISTORICAL' }));
expect(cfg.glyph).toBe('◍');
expect(cfg.label).toBe('Weltgeschehen');
expect(cfg.accent).toBe('historical');
});
it('maps a curated PERSONAL event to the ★ glyph and "Familie"', () => {
const cfg = getAccentConfig(event({ type: 'PERSONAL', eventId: 'e-1' }));
expect(cfg.glyph).toBe('★');
expect(cfg.label).toBe('Familie');
expect(cfg.accent).toBe('curated');
});
});