test(admin): unit and browser tests for the mail editor fields

Co-authored-by: Cursor <cursoragent@cursor.com>
This commit is contained in:
2026-11-13 14:23:28 +01:00
parent 45017039b2
commit 1ae1a9553f
12 changed files with 1009 additions and 9 deletions

View File

@@ -0,0 +1,32 @@
import { describe, expect, it } from 'vitest'
import { insertImage } from '../../src/components/mail/insertImage'
describe('insertImage (UI-SPEC C4)', () => {
it.each([
[
'markdown',
'https://cdn.example.com/a b(c).png',
'Logo [x]',
'![Logo \\[x\\]](https://cdn.example.com/a%20b%28c%29.png)',
],
[
'html',
'https://cdn.example.com/a"b.png',
'a "b" <c>',
'<img src="https://cdn.example.com/a&quot;b.png" alt="a &quot;b&quot; &lt;c&gt;">',
],
['css', 'https://cdn.example.com/a.png', 'ignored', 'url("https://cdn.example.com/a.png")'],
['text', 'https://cdn.example.com/a.png', 'ignored', 'https://cdn.example.com/a.png'],
] as const)('builds %s snippets with escaping', (language, url, alt, want) => {
expect(insertImage(language, url, alt)).toBe(want)
})
it('handles empty alt and parentheses in markdown URLs', () => {
expect(insertImage('markdown', 'https://cdn.example.com/x(y).png', '')).toBe(
'![](https://cdn.example.com/x%28y%29.png)',
)
expect(insertImage('html', 'https://cdn.example.com/x.png', '')).toBe(
'<img src="https://cdn.example.com/x.png" alt="">',
)
})
})