test(35-03): add failing tests for insertImage and colorpicker
- insertImage C4 table expects escaped markdown/html/css/text snippets - ColorPickerField sync cases; stubs return empty until GREEN Co-authored-by: Cursor <cursoragent@cursor.com>
This commit is contained in:
@@ -280,6 +280,54 @@ describe('CodeEditorField loading and fallback', () => {
|
||||
})
|
||||
})
|
||||
|
||||
describe('insertImage', () => {
|
||||
it('escapes markdown, html, css and text snippets per UI-SPEC C4', async () => {
|
||||
const { insertImage } = await import('../../src/components/mail/insertImage')
|
||||
expect(insertImage('markdown', 'https://cdn.example.com/a b.png', 'Logo [x]')).toBe(
|
||||
'![Logo \\[x\\]](https://cdn.example.com/a%20b.png)',
|
||||
)
|
||||
expect(insertImage('html', 'https://cdn.example.com/a"b.png', 'a "b" <c>')).toBe(
|
||||
'<img src="https://cdn.example.com/a"b.png" alt="a "b" <c>">',
|
||||
)
|
||||
expect(insertImage('css', 'https://cdn.example.com/a.png', 'ignored')).toBe(
|
||||
'url("https://cdn.example.com/a.png")',
|
||||
)
|
||||
expect(insertImage('text', 'https://cdn.example.com/a.png', 'ignored')).toBe(
|
||||
'https://cdn.example.com/a.png',
|
||||
)
|
||||
})
|
||||
})
|
||||
|
||||
describe('ColorPickerField', () => {
|
||||
it('syncs a typed #rrggbb into the swatch and keeps the last valid on partial', async () => {
|
||||
const Field = (await import('../../src/components/form/fields/ColorPickerField.vue')).default
|
||||
setBundle(
|
||||
{
|
||||
...mailPreviewBundle,
|
||||
'backend::lang.colorpicker.pick': { other: 'Pick a colour for “:field”' },
|
||||
'backend::lang.colorpicker.not_set': { other: 'Not set' },
|
||||
},
|
||||
'en',
|
||||
)
|
||||
const wrapper = mount(Field, {
|
||||
props: {
|
||||
field: { name: 'body_bg', label: 'Body background', type: 'colorpicker' } as FormField,
|
||||
modelValue: '',
|
||||
controlId: 'f-color',
|
||||
},
|
||||
attachTo: document.body,
|
||||
})
|
||||
const text = wrapper.find<HTMLInputElement>('input[type="text"]')
|
||||
const swatch = wrapper.find<HTMLInputElement>('input[type="color"]')
|
||||
expect(swatch.element.value).toBe('#ffffff')
|
||||
await text.setValue('#D66829')
|
||||
expect(wrapper.emitted('update:modelValue')?.at(-1)).toEqual(['#D66829'])
|
||||
expect(swatch.element.value.toLowerCase()).toBe('#d66829')
|
||||
await text.setValue('#D66')
|
||||
expect(swatch.element.value.toLowerCase()).toBe('#d66829')
|
||||
})
|
||||
})
|
||||
|
||||
// Last in the file: it replaces the editor chunk for the rest of the run.
|
||||
describe('CodeEditorField chunk failure', () => {
|
||||
afterEach(() => {
|
||||
|
||||
Reference in New Issue
Block a user