view data fixes
Some checks failed
Contract Testing / contract-tests (pull_request) Failing after 5m51s
Contract Testing / contract-snapshot (pull_request) Has been skipped

This commit is contained in:
2026-01-24 12:14:08 +01:00
parent dde77e717a
commit 046852703f
94 changed files with 1333 additions and 4885 deletions

View File

@@ -1,13 +1,13 @@
import { describe, it, expect } from 'vitest';
import { TrackImageViewDataBuilder } from './TrackImageViewDataBuilder';
import type { MediaBinaryDTO } from '@/lib/types/MediaBinaryDTO';
import type { MediaBinaryDTO } from '@/lib/types/generated/MediaBinaryDTO';
describe('TrackImageViewDataBuilder', () => {
describe('happy paths', () => {
it('should transform MediaBinaryDTO to TrackImageViewData correctly', () => {
const buffer = new Uint8Array([0x89, 0x50, 0x4e, 0x47, 0x0d, 0x0a, 0x1a, 0x0a]);
const mediaDto: MediaBinaryDTO = {
buffer: buffer.buffer,
buffer: buffer.buffer as any,
contentType: 'image/png',
};
@@ -20,7 +20,7 @@ describe('TrackImageViewDataBuilder', () => {
it('should handle JPEG track images', () => {
const buffer = new Uint8Array([0xff, 0xd8, 0xff, 0xe0]);
const mediaDto: MediaBinaryDTO = {
buffer: buffer.buffer,
buffer: buffer.buffer as any,
contentType: 'image/jpeg',
};
@@ -33,7 +33,7 @@ describe('TrackImageViewDataBuilder', () => {
it('should handle WebP track images', () => {
const buffer = new Uint8Array([0x52, 0x49, 0x46, 0x46]);
const mediaDto: MediaBinaryDTO = {
buffer: buffer.buffer,
buffer: buffer.buffer as any,
contentType: 'image/webp',
};
@@ -48,7 +48,7 @@ describe('TrackImageViewDataBuilder', () => {
it('should preserve all DTO fields in the output', () => {
const buffer = new Uint8Array([0x89, 0x50, 0x4e, 0x47]);
const mediaDto: MediaBinaryDTO = {
buffer: buffer.buffer,
buffer: buffer.buffer as any,
contentType: 'image/png',
};
@@ -61,7 +61,7 @@ describe('TrackImageViewDataBuilder', () => {
it('should not modify the input DTO', () => {
const buffer = new Uint8Array([0x89, 0x50, 0x4e, 0x47]);
const mediaDto: MediaBinaryDTO = {
buffer: buffer.buffer,
buffer: buffer.buffer as any,
contentType: 'image/png',
};
@@ -74,7 +74,7 @@ describe('TrackImageViewDataBuilder', () => {
it('should convert buffer to base64 string', () => {
const buffer = new Uint8Array([0x89, 0x50, 0x4e, 0x47, 0x0d, 0x0a, 0x1a, 0x0a]);
const mediaDto: MediaBinaryDTO = {
buffer: buffer.buffer,
buffer: buffer.buffer as any,
contentType: 'image/png',
};
@@ -89,7 +89,7 @@ describe('TrackImageViewDataBuilder', () => {
it('should handle empty buffer', () => {
const buffer = new Uint8Array([]);
const mediaDto: MediaBinaryDTO = {
buffer: buffer.buffer,
buffer: buffer.buffer as any,
contentType: 'image/png',
};
@@ -102,7 +102,7 @@ describe('TrackImageViewDataBuilder', () => {
it('should handle large track images', () => {
const buffer = new Uint8Array(5 * 1024 * 1024); // 5MB
const mediaDto: MediaBinaryDTO = {
buffer: buffer.buffer,
buffer: buffer.buffer as any,
contentType: 'image/jpeg',
};
@@ -115,7 +115,7 @@ describe('TrackImageViewDataBuilder', () => {
it('should handle buffer with all zeros', () => {
const buffer = new Uint8Array([0x00, 0x00, 0x00, 0x00]);
const mediaDto: MediaBinaryDTO = {
buffer: buffer.buffer,
buffer: buffer.buffer as any,
contentType: 'image/png',
};
@@ -128,7 +128,7 @@ describe('TrackImageViewDataBuilder', () => {
it('should handle buffer with all ones', () => {
const buffer = new Uint8Array([0xff, 0xff, 0xff, 0xff]);
const mediaDto: MediaBinaryDTO = {
buffer: buffer.buffer,
buffer: buffer.buffer as any,
contentType: 'image/png',
};
@@ -152,7 +152,7 @@ describe('TrackImageViewDataBuilder', () => {
contentTypes.forEach((contentType) => {
const mediaDto: MediaBinaryDTO = {
buffer: buffer.buffer,
buffer: buffer.buffer as any,
contentType,
};