Make the digest read like a newsletter
Each project leads with up to three cards: title, teaser and the cover image as a thumbnail, the rest follows as a compact list. Entries sort by number inside a project instead of jumping, and the project name links to its archive.
This commit is contained in:
@@ -65,8 +65,8 @@ describe('buildMessage', () => {
|
||||
const dump = JSON.stringify(message?.blocks)
|
||||
|
||||
expect(dump).toContain('27.07.2026 bis 03.08.2026')
|
||||
expect(dump).toContain('*Trakk*')
|
||||
expect(dump).toContain('*Orbit*')
|
||||
expect(dump).toContain('|Trakk>*')
|
||||
expect(dump).toContain('|Orbit>*')
|
||||
expect(dump).toContain('TRK-0142')
|
||||
expect(dump).toContain('https://logbuch.nyo.de/trakk/regel-engine')
|
||||
})
|
||||
@@ -83,3 +83,53 @@ describe('buildMessage', () => {
|
||||
expect(JSON.stringify(message)).not.toMatch(/\p{Extended_Pictographic}/u)
|
||||
})
|
||||
})
|
||||
|
||||
describe('Karten', () => {
|
||||
const base = {
|
||||
from: new Date('2026-07-27T06:00:00.000Z'),
|
||||
to: new Date('2026-08-03T06:00:00.000Z'),
|
||||
}
|
||||
|
||||
it('setzt Anreißer und Bild an den Eintrag', () => {
|
||||
const cover = new Map([['c0ffee00-0000-4000-8000-000000000001', {
|
||||
postId: 'c0ffee00-0000-4000-8000-000000000001',
|
||||
mediaId: 'm1',
|
||||
alt: 'Regelmaske mit Bedingung und Aktion',
|
||||
caption: null,
|
||||
width: 1600,
|
||||
height: 900,
|
||||
variants: [{ width: 480, format: 'webp', path: 'trakk/m1/480.webp' }],
|
||||
}]])
|
||||
|
||||
const projects = groupByProject([item({ teaser: 'Tickets reagieren jetzt selbst.' })])
|
||||
const message = buildMessage({ ...base, total: 1, projects }, origin, cover as never)
|
||||
const dump = JSON.stringify(message?.blocks)
|
||||
|
||||
expect(dump).toContain('Tickets reagieren jetzt selbst.')
|
||||
expect(dump).toContain('https://logbuch.nyo.de/api/v1/media/file/trakk/m1/480.webp')
|
||||
expect(dump).toContain('Regelmaske mit Bedingung und Aktion')
|
||||
})
|
||||
|
||||
it('kürzt lange Anreißer', () => {
|
||||
const long = `${'Wort '.repeat(80)}Ende`
|
||||
const projects = groupByProject([item({ teaser: long })])
|
||||
const dump = JSON.stringify(buildMessage({ ...base, total: 1, projects }, origin)?.blocks)
|
||||
|
||||
expect(dump).toContain('...')
|
||||
expect(dump).not.toContain('Ende')
|
||||
})
|
||||
|
||||
it('zeigt höchstens drei Karten je Projekt, der Rest kommt als Liste', () => {
|
||||
const many = Array.from({ length: 5 }, (_, index) => item({
|
||||
id: `c0ffee00-0000-4000-8000-00000000000${index}`,
|
||||
slug: `beitrag-${index}`,
|
||||
number: 140 + index,
|
||||
title: `Beitrag ${index}`,
|
||||
}))
|
||||
|
||||
const message = buildMessage({ ...base, total: 5, projects: groupByProject(many) }, origin)
|
||||
const sections = (message?.blocks ?? []).filter(block => (block as { type: string }).type === 'section')
|
||||
|
||||
expect(sections).toHaveLength(5)
|
||||
})
|
||||
})
|
||||
|
||||
Reference in New Issue
Block a user