/ src / components / chat / tool-call-bubble.test.ts
tool-call-bubble.test.ts
 1  import { describe, it } from 'node:test'
 2  import assert from 'node:assert/strict'
 3  import { extractMedia } from './tool-call-bubble'
 4  
 5  describe('extractMedia', () => {
 6    it('dedupes browser-* screenshot variants when screenshot-* exists', () => {
 7      const output = [
 8        '![Screenshot](/api/uploads/browser-1772498741525.png)',
 9        '![Screenshot](/api/uploads/screenshot-1772498741526.png)',
10        'Saved to: example_screenshot.png',
11      ].join('\n')
12  
13      const media = extractMedia(output)
14      assert.deepEqual(media.images, ['/api/uploads/screenshot-1772498741526.png'])
15      assert.equal(media.cleanText, 'Saved to: example_screenshot.png')
16    })
17  
18    it('keeps browser-* screenshot when it is the only image artifact', () => {
19      const output = [
20        '![Screenshot](/api/uploads/browser-1772498741525.png)',
21        'Saved to: example_screenshot.png',
22      ].join('\n')
23  
24      const media = extractMedia(output)
25      assert.deepEqual(media.images, ['/api/uploads/browser-1772498741525.png'])
26      assert.equal(media.cleanText, 'Saved to: example_screenshot.png')
27    })
28  })