fix: stabilize competition results flow
This commit is contained in:
1 parent
3bd3120eb1
commit
a88562b208
20 files changed
+411
-65
No files matched your search
@@ -1,4 +1,8 @@
|
||||
import { ConflictException, ForbiddenException } from '@nestjs/common';
|
||||
import {
|
||||
ConflictException,
|
||||
ForbiddenException,
|
||||
NotFoundException,
|
||||
} from '@nestjs/common';
|
||||
import { Types } from 'mongoose';
|
||||
import { ConnectionService } from '../global/database/connection.service';
|
||||
import { CompetitionQueryService } from './competition-query.service';
|
||||
@@ -55,6 +59,38 @@ describe('CompetitionQueryService', () => {
|
||||
});
|
||||
});
|
||||
|
||||
it('resolves a team view from an explicit team id without a caller identity', async () => {
|
||||
const harness = createHarness();
|
||||
const service = createService(harness);
|
||||
|
||||
const result = await service.getTeamView({
|
||||
communityId: COMMUNITY_ID,
|
||||
matchId: MATCH_ID,
|
||||
teamId: TEAM_A_ID,
|
||||
});
|
||||
|
||||
expect(result).toMatchObject({
|
||||
teamId: TEAM_A_ID.toHexString(),
|
||||
activeSeries: [expect.objectContaining({ seriesId: SERIES_ID })],
|
||||
tournamentCodes: [
|
||||
expect.objectContaining({ code: 'TEAM-A-SECRET-CODE' }),
|
||||
],
|
||||
});
|
||||
expect(JSON.stringify(result)).not.toContain('OPPONENT-SECRET-CODE');
|
||||
});
|
||||
|
||||
it('does not resolve a team view for an unknown team id', async () => {
|
||||
const service = createService(createHarness());
|
||||
|
||||
await expect(
|
||||
service.getTeamView({
|
||||
communityId: COMMUNITY_ID,
|
||||
matchId: MATCH_ID,
|
||||
teamId: new Types.ObjectId('64c000000000000000000098'),
|
||||
}),
|
||||
).rejects.toBeInstanceOf(NotFoundException);
|
||||
});
|
||||
|
||||
it('does not reveal a team view to an authenticated non-participant', async () => {
|
||||
const service = createService(createHarness());
|
||||
|
||||
|
||||
Reference in new issue
Block a user