refactor: remove live legacy bracket mode
This commit is contained in:
1 parent
78a2c7cf0d
commit
575cd911cb
4 files changed
+55
-6
No files matched your search
@@ -0,0 +1,33 @@
|
|||||||
|
import 'reflect-metadata';
|
||||||
|
import { plainToInstance } from 'class-transformer';
|
||||||
|
import { validateSync } from 'class-validator';
|
||||||
|
import { CreateMatchDto } from './create-match.dto';
|
||||||
|
|
||||||
|
describe('CreateMatchDto game mode cutover', () => {
|
||||||
|
it('rejects the removed live bracket mode', () => {
|
||||||
|
const dto = plainToInstance(CreateMatchDto, {
|
||||||
|
title: 'legacy bracket',
|
||||||
|
scheduledAt: '2026-07-13T10:00:00.000Z',
|
||||||
|
gameMode: 'bracket',
|
||||||
|
});
|
||||||
|
|
||||||
|
expect(validateSync(dto)).toEqual(
|
||||||
|
expect.arrayContaining([
|
||||||
|
expect.objectContaining({ property: 'gameMode' }),
|
||||||
|
]),
|
||||||
|
);
|
||||||
|
});
|
||||||
|
|
||||||
|
it.each(['pair', 'round-robin', 'double-elimination'] as const)(
|
||||||
|
'accepts the live %s mode',
|
||||||
|
(gameMode) => {
|
||||||
|
const dto = plainToInstance(CreateMatchDto, {
|
||||||
|
title: 'Competition',
|
||||||
|
scheduledAt: '2026-07-13T10:00:00.000Z',
|
||||||
|
gameMode,
|
||||||
|
});
|
||||||
|
|
||||||
|
expect(validateSync(dto)).toEqual([]);
|
||||||
|
},
|
||||||
|
);
|
||||||
|
});
|
||||||
@@ -8,6 +8,7 @@ import {
|
|||||||
IsDate,
|
IsDate,
|
||||||
IsEnum,
|
IsEnum,
|
||||||
IsInt,
|
IsInt,
|
||||||
|
IsIn,
|
||||||
IsOptional,
|
IsOptional,
|
||||||
IsString,
|
IsString,
|
||||||
MaxLength,
|
MaxLength,
|
||||||
@@ -17,9 +18,16 @@ import {
|
|||||||
ValidationArguments,
|
ValidationArguments,
|
||||||
ValidationOptions,
|
ValidationOptions,
|
||||||
} from 'class-validator';
|
} from 'class-validator';
|
||||||
import { MATCH_GAME_MODES, POSITIONS } from '../../global/database/schema';
|
import { POSITIONS } from '../../global/database/schema';
|
||||||
import type { MatchGameMode, Position } from '../../global/database/schema';
|
import type { MatchGameMode, Position } from '../../global/database/schema';
|
||||||
|
|
||||||
|
const LIVE_MATCH_GAME_MODES = [
|
||||||
|
'pair',
|
||||||
|
'round-robin',
|
||||||
|
'double-elimination',
|
||||||
|
] as const;
|
||||||
|
type LiveMatchGameMode = Exclude<MatchGameMode, 'bracket'>;
|
||||||
|
|
||||||
function IsMultipleOf(
|
function IsMultipleOf(
|
||||||
multiple: number,
|
multiple: number,
|
||||||
validationOptions?: ValidationOptions,
|
validationOptions?: ValidationOptions,
|
||||||
@@ -99,8 +107,8 @@ export class CreateMatchDto {
|
|||||||
gameCount?: number;
|
gameCount?: number;
|
||||||
|
|
||||||
@IsOptional()
|
@IsOptional()
|
||||||
@IsEnum(MATCH_GAME_MODES)
|
@IsIn(LIVE_MATCH_GAME_MODES)
|
||||||
gameMode?: MatchGameMode;
|
gameMode?: LiveMatchGameMode;
|
||||||
|
|
||||||
@IsOptional()
|
@IsOptional()
|
||||||
@IsInt()
|
@IsInt()
|
||||||
@@ -163,8 +171,8 @@ export class UpdateMatchDto {
|
|||||||
gameCount?: number;
|
gameCount?: number;
|
||||||
|
|
||||||
@IsOptional()
|
@IsOptional()
|
||||||
@IsEnum(MATCH_GAME_MODES)
|
@IsIn(LIVE_MATCH_GAME_MODES)
|
||||||
gameMode?: MatchGameMode;
|
gameMode?: LiveMatchGameMode;
|
||||||
|
|
||||||
@IsOptional()
|
@IsOptional()
|
||||||
@IsInt()
|
@IsInt()
|
||||||
|
|||||||
@@ -59,6 +59,7 @@ describe('presentPublicMatch', () => {
|
|||||||
communityId: oid('2').toString(),
|
communityId: oid('2').toString(),
|
||||||
competitionId: oid('3').toString(),
|
competitionId: oid('3').toString(),
|
||||||
title: '내전',
|
title: '내전',
|
||||||
|
doubleEliminationResetFinalEnabled: false,
|
||||||
scheduledAt: '2026-07-12T10:00:00.000Z',
|
scheduledAt: '2026-07-12T10:00:00.000Z',
|
||||||
participants: [
|
participants: [
|
||||||
expect.objectContaining({
|
expect.objectContaining({
|
||||||
|
|||||||
@@ -20,6 +20,7 @@ interface PublicMatchSource {
|
|||||||
gameCount: number;
|
gameCount: number;
|
||||||
gameMode: MatchGameMode;
|
gameMode: MatchGameMode;
|
||||||
roundRobinMaxRounds?: number;
|
roundRobinMaxRounds?: number;
|
||||||
|
doubleElimination?: { resetFinalEnabled?: boolean };
|
||||||
hostUserId?: IdLike;
|
hostUserId?: IdLike;
|
||||||
participants: Array<{
|
participants: Array<{
|
||||||
userId: IdLike;
|
userId: IdLike;
|
||||||
@@ -71,10 +72,16 @@ export function presentPublicMatch(
|
|||||||
scheduledAt: asIso(source.scheduledAt),
|
scheduledAt: asIso(source.scheduledAt),
|
||||||
maxParticipants: source.maxParticipants,
|
maxParticipants: source.maxParticipants,
|
||||||
gameCount: source.gameCount,
|
gameCount: source.gameCount,
|
||||||
gameMode: source.gameMode,
|
gameMode: source.gameMode === 'bracket' ? 'pair' : source.gameMode,
|
||||||
...(source.roundRobinMaxRounds === undefined
|
...(source.roundRobinMaxRounds === undefined
|
||||||
? {}
|
? {}
|
||||||
: { roundRobinMaxRounds: source.roundRobinMaxRounds }),
|
: { roundRobinMaxRounds: source.roundRobinMaxRounds }),
|
||||||
|
...(source.gameMode === 'double-elimination'
|
||||||
|
? {
|
||||||
|
doubleEliminationResetFinalEnabled:
|
||||||
|
source.doubleElimination?.resetFinalEnabled ?? false,
|
||||||
|
}
|
||||||
|
: {}),
|
||||||
...(source.hostUserId ? { hostUserId: source.hostUserId.toString() } : {}),
|
...(source.hostUserId ? { hostUserId: source.hostUserId.toString() } : {}),
|
||||||
participants: source.participants.map((participant) => ({
|
participants: source.participants.map((participant) => ({
|
||||||
userId: participant.userId.toString(),
|
userId: participant.userId.toString(),
|
||||||
|
|||||||
Reference in new issue
Block a user