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:
75
tests/integration/media/teams/team-logo-management.test.ts
Normal file
75
tests/integration/media/teams/team-logo-management.test.ts
Normal file
@@ -0,0 +1,75 @@
|
||||
import { describe, it, expect, beforeEach } from 'vitest';
|
||||
import { MediaTestContext } from '../MediaTestContext';
|
||||
import { InMemoryTeamRepository } from '@adapters/racing/persistence/inmemory/InMemoryTeamRepository';
|
||||
import { InMemoryTeamMembershipRepository } from '@adapters/racing/persistence/inmemory/InMemoryTeamMembershipRepository';
|
||||
import { Team } from '@core/racing/domain/entities/Team';
|
||||
import { MediaReference } from '@core/domain/media/MediaReference';
|
||||
|
||||
describe('Team Logo Management', () => {
|
||||
let ctx: MediaTestContext;
|
||||
let teamRepository: InMemoryTeamRepository;
|
||||
let membershipRepository: InMemoryTeamMembershipRepository;
|
||||
|
||||
beforeEach(() => {
|
||||
ctx = MediaTestContext.create();
|
||||
ctx.reset();
|
||||
teamRepository = new InMemoryTeamRepository(ctx.logger);
|
||||
membershipRepository = new InMemoryTeamMembershipRepository(ctx.logger);
|
||||
});
|
||||
|
||||
it('should upload and set a team logo', async () => {
|
||||
// Given: A team exists
|
||||
const team = Team.create({
|
||||
id: 'team-1',
|
||||
name: 'Test Team',
|
||||
tag: 'TST',
|
||||
description: 'Test Description',
|
||||
ownerId: 'owner-1',
|
||||
leagues: [],
|
||||
});
|
||||
await teamRepository.create(team);
|
||||
|
||||
// When: A logo is uploaded
|
||||
const uploadResult = await ctx.mediaStorage.uploadMedia(
|
||||
Buffer.from('logo content'),
|
||||
{ filename: 'logo.png', mimeType: 'image/png' }
|
||||
);
|
||||
expect(uploadResult.success).toBe(true);
|
||||
const mediaId = 'media-1'; // In real use case, this comes from repository save
|
||||
|
||||
// And: The team is updated with the new logo reference
|
||||
const updatedTeam = team.update({
|
||||
logoRef: MediaReference.createUploaded(mediaId)
|
||||
});
|
||||
await teamRepository.update(updatedTeam);
|
||||
|
||||
// Then: The team should have the correct logo reference
|
||||
const savedTeam = await teamRepository.findById('team-1');
|
||||
expect(savedTeam?.logoRef.type).toBe('uploaded');
|
||||
expect(savedTeam?.logoRef.mediaId).toBe(mediaId);
|
||||
});
|
||||
|
||||
it('should retrieve team logos (simulated via repository)', async () => {
|
||||
const team1 = Team.create({
|
||||
id: 'team-1',
|
||||
name: 'Team 1',
|
||||
tag: 'T1',
|
||||
description: 'Desc 1',
|
||||
ownerId: 'owner-1',
|
||||
leagues: ['league-1'],
|
||||
});
|
||||
const team2 = Team.create({
|
||||
id: 'team-2',
|
||||
name: 'Team 2',
|
||||
tag: 'T2',
|
||||
description: 'Desc 2',
|
||||
ownerId: 'owner-2',
|
||||
leagues: ['league-1'],
|
||||
});
|
||||
await teamRepository.create(team1);
|
||||
await teamRepository.create(team2);
|
||||
|
||||
const leagueTeams = await teamRepository.findByLeagueId('league-1');
|
||||
expect(leagueTeams).toHaveLength(2);
|
||||
});
|
||||
});
|
||||
Reference in New Issue
Block a user