ajout d'image

This commit is contained in:
2026-05-26 18:48:25 +02:00
parent e8db166ee5
commit 663234d5c8
8 changed files with 226 additions and 1 deletions
@@ -470,6 +470,37 @@ describe('IssueDetail — existing issue', () => {
});
});
describe('onDescriptionPaste', () => {
afterEach(() => vi.unstubAllGlobals());
it('inserts image markdown into issue.description', async () => {
vi.stubGlobal('FileReader', class {
readonly result = 'data:image/png;base64,xyz';
onload: ((e: any) => void) | null = null;
readAsDataURL(_file: File) {
Promise.resolve().then(() => this.onload?.({ target: { result: this.result } }));
}
});
(component as any).issue.description = 'existing';
const ta = document.createElement('textarea');
ta.value = 'existing';
ta.selectionStart = 0;
ta.selectionEnd = 0;
const file = new File([''], 'img.png', { type: 'image/png' });
const event = {
clipboardData: { items: [{ type: 'image/png', getAsFile: () => file }] },
preventDefault: vi.fn(),
target: ta,
} as unknown as ClipboardEvent;
(component as any).onDescriptionPaste(event);
await Promise.resolve();
expect((component as any).issue.description).toContain('![image](data:image/png;base64,xyz)');
});
});
describe('descriptionHtml', () => {
it('returns a truthy SafeHtml for markdown input', () => {
(component as any).issue.description = '# Title\n**bold**';