Skip to content

Commit f0772e7

Browse files
committed
test: cover OG text clamping
1 parent 770bb3a commit f0772e7

File tree

1 file changed

+21
-0
lines changed

1 file changed

+21
-0
lines changed

server/og/skillOgSvg.test.ts

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,4 +18,25 @@ describe('skill OG SVG', () => {
1818
expect(svg).toContain('v1.2.3')
1919
expect(svg).toContain('clawdhub.com/jhillock/discord-doctor')
2020
})
21+
22+
it('clips and wraps long descriptions', () => {
23+
const longWord = 'a'.repeat(200)
24+
const svg = buildSkillOgSvg({
25+
markDataUrl: 'data:image/png;base64,AAA=',
26+
title: 'Gurkerlcli',
27+
description: `Prefix ${longWord} suffix`,
28+
ownerLabel: '@pasogott',
29+
versionLabel: 'v0.1.0',
30+
footer: 'clawdhub.com/pasogott/gurkerlcli',
31+
})
32+
33+
expect(svg).toContain('<clipPath id="cardClip">')
34+
expect(svg).toContain('clip-path="url(#cardClip)"')
35+
expect(svg).not.toContain(longWord)
36+
expect(svg).toContain('…')
37+
38+
const descBlock = svg.match(/<text[^>]*font-size="26"[\s\S]*?<\/text>/)?.[0] ?? ''
39+
const descTspans = descBlock.match(/<tspan /g) ?? []
40+
expect(descTspans.length).toBeLessThanOrEqual(3)
41+
})
2142
})

0 commit comments

Comments
 (0)