Skip to content

Commit 080ae8b

Browse files
committed
timeout test
1 parent c3870e1 commit 080ae8b

1 file changed

Lines changed: 7 additions & 15 deletions

File tree

apps/sim/lib/copilot/vfs/file-reader.test.ts

Lines changed: 7 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,10 @@ vi.mock('@/lib/uploads/contexts/workspace/workspace-file-manager', () => ({
1818
import { readFileRecord } from '@/lib/copilot/vfs/file-reader'
1919

2020
const MAX_IMAGE_READ_BYTES = 5 * 1024 * 1024
21+
const TINY_PNG = Buffer.from(
22+
'iVBORw0KGgoAAAANSUhEUgAAAAEAAAABCAIAAACQd1PeAAAADUlEQVR4nGP4z8AAAAMBAQDJ/pLvAAAAAElFTkSuQmCC',
23+
'base64'
24+
)
2125

2226
async function makeNoisePng(width: number, height: number): Promise<Buffer> {
2327
const sharp = (await import('sharp')).default
@@ -30,27 +34,15 @@ async function makeNoisePng(width: number, height: number): Promise<Buffer> {
3034

3135
describe('readFileRecord', () => {
3236
it('returns small images as attachments without resize note', async () => {
33-
const sharp = (await import('sharp')).default
34-
const smallPng = await sharp({
35-
create: {
36-
width: 200,
37-
height: 200,
38-
channels: 3,
39-
background: { r: 255, g: 0, b: 0 },
40-
},
41-
})
42-
.png()
43-
.toBuffer()
44-
45-
downloadWorkspaceFile.mockResolvedValue(smallPng)
37+
downloadWorkspaceFile.mockResolvedValue(TINY_PNG)
4638

4739
const result = await readFileRecord({
4840
id: 'wf_small',
4941
workspaceId: 'ws_1',
5042
name: 'small.png',
5143
key: 'uploads/small.png',
5244
path: '/api/files/serve/uploads%2Fsmall.png?context=mothership',
53-
size: smallPng.length,
45+
size: TINY_PNG.length,
5446
type: 'image/png',
5547
uploadedBy: 'user_1',
5648
uploadedAt: new Date(),
@@ -61,7 +53,7 @@ describe('readFileRecord', () => {
6153
expect(result?.attachment?.type).toBe('image')
6254
expect(result?.attachment?.source.media_type).toBe('image/png')
6355
expect(result?.content).not.toContain('resized for vision')
64-
expect(Buffer.from(result?.attachment?.source.data ?? '', 'base64')).toEqual(smallPng)
56+
expect(Buffer.from(result?.attachment?.source.data ?? '', 'base64')).toEqual(TINY_PNG)
6557
})
6658

6759
it('downscales oversized images into attachments that fit the read limit', async () => {

0 commit comments

Comments
 (0)