refactor: remove live legacy bracket mode

This commit is contained in:
dahyeon committed 2026-07-12 20:05:25 +00:00
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,
IsEnum,
IsInt,
IsIn,
IsOptional,
IsString,
MaxLength,
@@ -17,9 +18,16 @@ import {
ValidationArguments,
ValidationOptions,
} 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';
const LIVE_MATCH_GAME_MODES = [
'pair',
'round-robin',
'double-elimination',
] as const;
type LiveMatchGameMode = Exclude<MatchGameMode, 'bracket'>;
function IsMultipleOf(
multiple: number,
validationOptions?: ValidationOptions,
@@ -99,8 +107,8 @@ export class CreateMatchDto {
gameCount?: number;
@IsOptional()
@IsEnum(MATCH_GAME_MODES)
gameMode?: MatchGameMode;
@IsIn(LIVE_MATCH_GAME_MODES)
gameMode?: LiveMatchGameMode;
@IsOptional()
@IsInt()
@@ -163,8 +171,8 @@ export class UpdateMatchDto {
gameCount?: number;
@IsOptional()
@IsEnum(MATCH_GAME_MODES)
gameMode?: MatchGameMode;
@IsIn(LIVE_MATCH_GAME_MODES)
gameMode?: LiveMatchGameMode;
@IsOptional()
@IsInt()
@@ -59,6 +59,7 @@ describe('presentPublicMatch', () => {
communityId: oid('2').toString(),
competitionId: oid('3').toString(),
title: '내전',
doubleEliminationResetFinalEnabled: false,
scheduledAt: '2026-07-12T10:00:00.000Z',
participants: [
expect.objectContaining({
@@ -20,6 +20,7 @@ interface PublicMatchSource {
gameCount: number;
gameMode: MatchGameMode;
roundRobinMaxRounds?: number;
doubleElimination?: { resetFinalEnabled?: boolean };
hostUserId?: IdLike;
participants: Array<{
userId: IdLike;
@@ -71,10 +72,16 @@ export function presentPublicMatch(
scheduledAt: asIso(source.scheduledAt),
maxParticipants: source.maxParticipants,
gameCount: source.gameCount,
gameMode: source.gameMode,
gameMode: source.gameMode === 'bracket' ? 'pair' : source.gameMode,
...(source.roundRobinMaxRounds === undefined
? {}
: { roundRobinMaxRounds: source.roundRobinMaxRounds }),
...(source.gameMode === 'double-elimination'
? {
doubleEliminationResetFinalEnabled:
source.doubleElimination?.resetFinalEnabled ?? false,
}
: {}),
...(source.hostUserId ? { hostUserId: source.hostUserId.toString() } : {}),
participants: source.participants.map((participant) => ({
userId: participant.userId.toString(),