Files
Toju/toju-app/src/app/domains/chat/domain/rules/chat-message-image-gallery.rules.spec.ts
T
myxeliumandCursor b13f71d2d3 fix: Bug - Sending files and attachment issues (gallery load and speed)
Route small images through in-memory receive instead of serialized disk
chunk-acks, and improve gallery hydration for local copies and pending
downloads so thumbnails display without minutes-long progress stalls.

Co-authored-by: Cursor <cursoragent@cursor.com>
2026-06-14 13:19:12 +02:00

69 lines
1.7 KiB
TypeScript

import {
describe,
expect,
it
} from 'vitest';
import { buildChatMessageGalleryTiles, resolveChatMessageGalleryTileState } from './chat-message-image-gallery.rules';
describe('buildChatMessageGalleryTiles', () => {
it('marks displayable, hydrating, downloading, and retry tiles from attachment state', () => {
const tiles = buildChatMessageGalleryTiles([
{
id: 'displayable',
filename: 'ready.png',
mime: 'image/png',
isImage: true,
available: true,
objectUrl: 'blob:http://localhost/ready'
},
{
id: 'hydrating',
filename: 'saved.png',
mime: 'image/png',
isImage: true,
available: false,
savedPath: '/appdata/saved.png'
},
{
id: 'partial',
filename: 'partial.png',
mime: 'image/png',
isImage: true,
available: false,
receivedBytes: 128,
size: 512
},
{
id: 'retry',
filename: 'failed.png',
mime: 'image/png',
isImage: true,
available: false,
size: 256
}
]);
expect(tiles.map((tile) => tile.state)).toEqual([
'displayable',
'hydrating',
'downloading',
'retry'
]);
});
it('treats zero-byte pending requests as downloading instead of retry', () => {
const attachment = {
id: 'pending',
filename: 'waiting.png',
mime: 'image/png',
isImage: true,
available: false,
size: 256
};
expect(resolveChatMessageGalleryTileState(attachment)).toBe('retry');
expect(resolveChatMessageGalleryTileState(attachment, { pendingRequest: true })).toBe('downloading');
});
});