integration tests
Some checks failed
CI / lint-typecheck (pull_request) Failing after 4m50s
CI / tests (pull_request) Has been skipped
CI / contract-tests (pull_request) Has been skipped
CI / e2e-tests (pull_request) Has been skipped
CI / comment-pr (pull_request) Has been skipped
CI / commit-types (pull_request) Has been skipped
Some checks failed
CI / lint-typecheck (pull_request) Failing after 4m50s
CI / tests (pull_request) Has been skipped
CI / contract-tests (pull_request) Has been skipped
CI / e2e-tests (pull_request) Has been skipped
CI / comment-pr (pull_request) Has been skipped
CI / commit-types (pull_request) Has been skipped
This commit is contained in:
@@ -0,0 +1,65 @@
|
||||
import { describe, it, expect, beforeEach } from 'vitest';
|
||||
import { MediaTestContext } from '../MediaTestContext';
|
||||
import { InMemoryTrackRepository } from '@adapters/racing/persistence/inmemory/InMemoryTrackRepository';
|
||||
import { Track } from '@core/racing/domain/entities/Track';
|
||||
|
||||
describe('Track Image Management', () => {
|
||||
let ctx: MediaTestContext;
|
||||
let trackRepository: InMemoryTrackRepository;
|
||||
|
||||
beforeEach(() => {
|
||||
ctx = MediaTestContext.create();
|
||||
ctx.reset();
|
||||
trackRepository = new InMemoryTrackRepository(ctx.logger);
|
||||
});
|
||||
|
||||
it('should upload and set a track image', async () => {
|
||||
// Given: A track exists
|
||||
const track = Track.create({
|
||||
id: 'track-1',
|
||||
name: 'Test Track',
|
||||
shortName: 'TST',
|
||||
location: 'Test Location',
|
||||
country: 'Test Country',
|
||||
gameId: 'game-1',
|
||||
category: 'road',
|
||||
});
|
||||
await trackRepository.create(track);
|
||||
|
||||
// When: An image is uploaded
|
||||
const uploadResult = await ctx.mediaStorage.uploadMedia(
|
||||
Buffer.from('image content'),
|
||||
{ filename: 'track.png', mimeType: 'image/png' }
|
||||
);
|
||||
expect(uploadResult.success).toBe(true);
|
||||
const imageUrl = uploadResult.url!;
|
||||
|
||||
// And: The track is updated with the new image URL
|
||||
const updatedTrack = track.update({
|
||||
imageUrl: imageUrl
|
||||
});
|
||||
await trackRepository.update(updatedTrack);
|
||||
|
||||
// Then: The track should have the correct image URL
|
||||
const savedTrack = await trackRepository.findById('track-1');
|
||||
expect(savedTrack?.imageUrl?.value).toBe(imageUrl);
|
||||
});
|
||||
|
||||
it('should retrieve track images (simulated via repository)', async () => {
|
||||
const track = Track.create({
|
||||
id: 'track-1',
|
||||
name: 'Test Track',
|
||||
shortName: 'TST',
|
||||
location: 'Test Location',
|
||||
country: 'Test Country',
|
||||
gameId: 'game-1',
|
||||
category: 'road',
|
||||
imageUrl: 'https://example.com/track.png'
|
||||
});
|
||||
await trackRepository.create(track);
|
||||
|
||||
const found = await trackRepository.findById('track-1');
|
||||
expect(found).not.toBeNull();
|
||||
expect(found?.imageUrl?.value).toBe('https://example.com/track.png');
|
||||
});
|
||||
});
|
||||
Reference in New Issue
Block a user