diff --git a/.gitignore b/.gitignore index c48451e3..a5c55162 100644 --- a/.gitignore +++ b/.gitignore @@ -24,6 +24,7 @@ website/LICENSE *.md !README.md !design-qa.md +!docs/specs/home-banner-production.md !docs/specs/match-status-and-result-presentation.md !docs/ux-audit-2026-11-10/06-ui-improvement-review.md !docs/ux-audit-2026-11-10/07-visual-design-review.md diff --git a/apps/api/src/modules/global/database/schema.ts b/apps/api/src/modules/global/database/schema.ts index 462dd7ac..c30b51c6 100644 --- a/apps/api/src/modules/global/database/schema.ts +++ b/apps/api/src/modules/global/database/schema.ts @@ -1,4 +1,5 @@ import mongoose, { Schema, HydratedDocument } from 'mongoose'; +import type { MatchEventType } from '@lolympus/contracts'; import type { RiotPlatformRoute, RiotRegionalRoute, @@ -38,6 +39,8 @@ export const MATCH_STATUSES: MatchStatus[] = [ 'finished', ]; +export const MATCH_EVENT_TYPES = ['inhouse', 'tournament'] as const satisfies readonly MatchEventType[]; + export type TeamSide = 'blue' | 'red'; export const TEAM_SIDES: TeamSide[] = ['blue', 'red']; @@ -686,6 +689,7 @@ export interface Match extends MongooseTimestamps { competitionId?: mongoose.Types.ObjectId; shortCode?: string; title: string; + eventType?: MatchEventType; description: string; mapId: number; // Riot Match-V5 mapId (11=소환사의 협곡, 12=ARAM 등) status: MatchStatus; @@ -1954,6 +1958,7 @@ export const MatchSchema = new Schema( maxlength: 6, }, title: { type: String, required: true }, + eventType: { type: String, enum: MATCH_EVENT_TYPES, default: 'inhouse' }, description: { type: String, required: false, default: '' }, mapId: { type: Number, required: true, default: 11 }, status: { diff --git a/apps/api/src/modules/match/dto/create-match.dto.spec.ts b/apps/api/src/modules/match/dto/create-match.dto.spec.ts index 21380d22..ed53598d 100644 --- a/apps/api/src/modules/match/dto/create-match.dto.spec.ts +++ b/apps/api/src/modules/match/dto/create-match.dto.spec.ts @@ -79,3 +79,30 @@ describe('Grand final format validation', () => { ]); }); }); + +describe('Match event type validation', () => { + it.each(['inhouse', 'tournament', undefined])( + 'accepts %s in create and update requests', + (eventType) => { + expect( + validateSync( + plainToInstance(CreateMatchDto, { + title: 'Competition', + scheduledAt: '2026-07-13T10:00:00.000Z', + eventType, + }), + ), + ).toEqual([]); + expect(validateSync(plainToInstance(UpdateMatchDto, { eventType }))).toEqual( + [], + ); + }, + ); + + it.each(['double-elimination', null])('rejects %s as an event type', (eventType) => { + const dto = plainToInstance(UpdateMatchDto, { eventType }); + expect(validateSync(dto)).toEqual([ + expect.objectContaining({ property: 'eventType' }), + ]); + }); +}); diff --git a/apps/api/src/modules/match/dto/create-match.dto.ts b/apps/api/src/modules/match/dto/create-match.dto.ts index df2bfb0b..66232053 100644 --- a/apps/api/src/modules/match/dto/create-match.dto.ts +++ b/apps/api/src/modules/match/dto/create-match.dto.ts @@ -1,4 +1,4 @@ -import type { GrandFinalGameCount } from '@lolympus/contracts'; +import type { GrandFinalGameCount, MatchEventType } from '@lolympus/contracts'; import { Type } from 'class-transformer'; import { ArrayMaxSize, @@ -15,11 +15,12 @@ import { MaxLength, Min, MinLength, + ValidateIf, ValidateNested, ValidationArguments, ValidationOptions, } from 'class-validator'; -import { POSITIONS } from '../../global/database/schema'; +import { MATCH_EVENT_TYPES, POSITIONS } from '../../global/database/schema'; import type { MatchGameMode, Position } from '../../global/database/schema'; const LIVE_MATCH_GAME_MODES = [ @@ -83,6 +84,10 @@ export class CreateMatchDto { @MaxLength(128) title!: string; + @ValidateIf((_object, value) => value !== undefined) + @IsIn(MATCH_EVENT_TYPES) + eventType?: MatchEventType; + @IsOptional() @IsString() @MaxLength(2048) @@ -150,6 +155,10 @@ export class UpdateMatchDto { @MaxLength(128) title?: string; + @ValidateIf((_object, value) => value !== undefined) + @IsIn(MATCH_EVENT_TYPES) + eventType?: MatchEventType; + @IsOptional() @IsString() @MaxLength(2048) diff --git a/apps/api/src/modules/match/match-history-result.spec.ts b/apps/api/src/modules/match/match-history-result.spec.ts index f7e91177..2585f98a 100644 --- a/apps/api/src/modules/match/match-history-result.spec.ts +++ b/apps/api/src/modules/match/match-history-result.spec.ts @@ -37,8 +37,11 @@ const finishedMatch = { }; const singleSeries = { status: 'completed', - entries: [{ gameWins: 2 }, { gameWins: 1 }], - outcome: { type: 'played', winnerTeamId: firstId.toString() }, + entries: [ + { teamId: secondId.toString(), gameWins: 2 }, + { teamId: firstId.toString(), gameWins: 1 }, + ], + outcome: { type: 'played', winnerTeamId: secondId.toString() }, }; describe('summarizeMatchHistoryResult', () => { @@ -55,7 +58,9 @@ describe('summarizeMatchHistoryResult', () => { type: 'score', teamAWins: 2, teamBWins: 1, - winnerTeamName: '첫 팀', + teamAName: '둘째 팀', + teamBName: '첫 팀', + winnerTeamName: '둘째 팀', }); expect( summarizeMatchHistoryResult( @@ -91,7 +96,7 @@ describe('summarizeMatchHistoryResult', () => { ).toEqual({ type: 'decision', decision: 'forfeit', - winnerTeamName: '첫 팀', + winnerTeamName: '둘째 팀', }); }); @@ -126,8 +131,8 @@ describe('summarizeMatchHistoryResult', () => { const match = { status: 'finished' as const, teams: [ - { teamIndex: 1, name: '첫 팀', members: [] }, { teamIndex: 2, name: '둘째 팀', members: [] }, + { teamIndex: 1, name: '첫 팀', members: [] }, ], result: { winnerTeamIndex: 2, @@ -152,6 +157,8 @@ describe('summarizeMatchHistoryResult', () => { type: 'score', teamAWins: 0, teamBWins: 1, + teamAName: '첫 팀', + teamBName: '둘째 팀', winnerTeamName: '둘째 팀', }); expect( diff --git a/apps/api/src/modules/match/match-history-result.ts b/apps/api/src/modules/match/match-history-result.ts index 97336e4c..64169547 100644 --- a/apps/api/src/modules/match/match-history-result.ts +++ b/apps/api/src/modules/match/match-history-result.ts @@ -23,7 +23,7 @@ export function summarizeMatchHistoryResult( >; if (!outcome) return; - const teamName = (teamId: string) => { + const teamName = (teamId: string | null) => { const team = competition.teams.find( (item) => String(item.teamId) === teamId, ); @@ -44,6 +44,8 @@ export function summarizeMatchHistoryResult( type: 'score', teamAWins: teamA.gameWins, teamBWins: teamB.gameWins, + teamAName: teamName(teamA.teamId), + teamBName: teamName(teamB.teamId), winnerTeamName, }; } @@ -112,6 +114,8 @@ function summarizeLegacyResult( type: 'score', teamAWins, teamBWins, + teamAName: teamA.name.trim() || `${teamA.teamIndex}팀`, + teamBName: teamB.name.trim() || `${teamB.teamIndex}팀`, winnerTeamName: winner && (winner.name.trim() || `${winner.teamIndex}팀`), }; } diff --git a/apps/api/src/modules/match/match-public.presenter.spec.ts b/apps/api/src/modules/match/match-public.presenter.spec.ts index 59684f0b..eed562b0 100644 --- a/apps/api/src/modules/match/match-public.presenter.spec.ts +++ b/apps/api/src/modules/match/match-public.presenter.spec.ts @@ -75,6 +75,7 @@ describe('presentPublicMatch', () => { communityId: oid('2').toString(), competitionId: oid('3').toString(), title: '내전', + eventType: 'inhouse', doubleEliminationResetFinalEnabled: false, scheduledAt: '2026-07-12T10:00:00.000Z', participants: [ diff --git a/apps/api/src/modules/match/match-public.presenter.ts b/apps/api/src/modules/match/match-public.presenter.ts index 4da03995..df1b80c0 100644 --- a/apps/api/src/modules/match/match-public.presenter.ts +++ b/apps/api/src/modules/match/match-public.presenter.ts @@ -1,4 +1,8 @@ -import type { MatchDetailResponse, MatchTierView } from '@lolympus/contracts'; +import type { + MatchDetailResponse, + MatchEventType, + MatchTierView, +} from '@lolympus/contracts'; import type { MatchGameMode, MatchStatus, @@ -13,6 +17,7 @@ interface PublicMatchSource { competitionId?: IdLike; shortCode?: string; title: string; + eventType?: MatchEventType; description: string; mapId: number; status: MatchStatus; @@ -67,6 +72,7 @@ export function presentPublicMatch( : {}), ...(source.shortCode ? { shortCode: source.shortCode } : {}), title: source.title, + eventType: source.eventType ?? 'inhouse', description: source.description, mapId: source.mapId, status: source.status, diff --git a/apps/api/src/modules/match/match.controller.spec.ts b/apps/api/src/modules/match/match.controller.spec.ts index 9f33969d..7d763291 100644 --- a/apps/api/src/modules/match/match.controller.spec.ts +++ b/apps/api/src/modules/match/match.controller.spec.ts @@ -1,10 +1,12 @@ import 'reflect-metadata'; import { GUARDS_METADATA } from '@nestjs/common/constants'; import mongoose from 'mongoose'; +import { plainToInstance } from 'class-transformer'; import { METADATA_KEY_IS_PUBLIC_ACCESS_ALLOWED } from '../auth/allow-public-access.decorator'; import { ROLES_KEY } from '../auth/roles.decorator'; import { RolesGuard } from '../auth/roles.guard'; import type { UserDocument } from '../global/database/schema'; +import { UpdateMatchDto } from './dto/create-match.dto'; import { MatchController } from './match.controller'; describe('MatchController history summaries', () => { @@ -43,14 +45,40 @@ describe('MatchController history summaries', () => { undefined, 'desc', 'true', + 'tournament', ), ).resolves.toMatchObject({ matches: [{ ...summary, historyResult }] }); + expect(matchService.listPage).toHaveBeenLastCalledWith( + expect.objectContaining({ eventType: 'tournament' }), + ); expect(matchService.getHistoryResults).toHaveBeenCalledWith(communityId, [ match, ]); }); }); +describe('MatchController partial updates', () => { + it('passes only supplied fields when reclassifying a match', async () => { + const communityId = new mongoose.Types.ObjectId(); + const matchId = new mongoose.Types.ObjectId(); + const user = { _id: new mongoose.Types.ObjectId(), communityId }; + const matchService = { + update: jest.fn().mockResolvedValue({ participants: [] }), + serialize: jest.fn(), + }; + const controller = new MatchController(matchService as never); + const body = plainToInstance(UpdateMatchDto, { eventType: 'tournament' }); + + await controller.updateMatch(user as UserDocument, communityId, matchId, body); + + expect(matchService.update).toHaveBeenCalledWith({ + communityId, + matchId, + patch: { eventType: 'tournament' }, + }); + }); +}); + describe('MatchController participant access', () => { function createController() { const joinedMatch = { _id: new mongoose.Types.ObjectId() }; diff --git a/apps/api/src/modules/match/match.controller.ts b/apps/api/src/modules/match/match.controller.ts index 525eb742..2f5ddbef 100644 --- a/apps/api/src/modules/match/match.controller.ts +++ b/apps/api/src/modules/match/match.controller.ts @@ -1,5 +1,6 @@ import type { MatchDetailResponse, + MatchEventType, MatchListResponse, } from '@lolympus/contracts'; import { @@ -23,6 +24,7 @@ import { Roles } from '../auth/roles.decorator'; import { RolesGuard } from '../auth/roles.guard'; import { ParseObjectIdPipe } from '../common/parse-object-id.pipe'; import type { MatchStatus, UserDocument } from '../global/database/schema'; +import { MATCH_EVENT_TYPES } from '../global/database/schema'; import { AddParticipantDto, CreateMatchDto, @@ -51,6 +53,7 @@ export class MatchController { hostUserId: currentUser._id, data: { title: body.title, + eventType: body.eventType, description: body.description ?? '', mapId: body.mapId ?? 11, scheduledAt: body.scheduledAt, @@ -85,10 +88,15 @@ export class MatchController { @Query('scheduledTo') scheduledTo?: string, @Query('sort') sort?: 'asc' | 'desc', @Query('includeResults') includeResults?: string, + @Query('eventType') eventType?: MatchEventType, ): Promise { + if (eventType !== undefined && !MATCH_EVENT_TYPES.includes(eventType)) { + throw new BadRequestException('Invalid eventType.'); + } const result = await this.matchService.listPage({ communityId, status, + eventType, limit: this.toOptionalNumber(limit), page: this.toOptionalNumber(page), offset: this.toOptionalNumber(offset), diff --git a/apps/api/src/modules/match/match.service.spec.ts b/apps/api/src/modules/match/match.service.spec.ts index 0fc4509a..1278cbc0 100644 --- a/apps/api/src/modules/match/match.service.spec.ts +++ b/apps/api/src/modules/match/match.service.spec.ts @@ -280,6 +280,28 @@ describe('MatchService', () => { expect(sort).toHaveBeenCalledWith({ scheduledAt: -1 }); }); + it.each([ + ['inhouse', { $in: ['inhouse', null] }], + ['tournament', 'tournament'], + ] as const)( + 'filters both results and pagination totals for %s events', + async (eventType, expectedEventType) => { + const communityId = new mongoose.Types.ObjectId(); + const scheduledTo = new Date('2026-06-08T12:00:00.000Z'); + const { service, MatchModel } = createServiceWithListModel(); + + await service.listPage({ communityId, scheduledTo, eventType }); + + const expectedFilter = { + communityId, + scheduledAt: { $lt: scheduledTo }, + eventType: expectedEventType, + }; + expect(MatchModel.find).toHaveBeenCalledWith(expectedFilter); + expect(MatchModel.countDocuments).toHaveBeenCalledWith(expectedFilter); + }, + ); + it('uses saved user preferences when joining without explicit positions', async () => { const communityId = new mongoose.Types.ObjectId(); const userId = new mongoose.Types.ObjectId(); @@ -637,6 +659,26 @@ describe('MatchService', () => { expect(match.set).not.toHaveBeenCalled(); }); + it('allows reclassifying a finished match without altering its competition settings', async () => { + const communityId = new mongoose.Types.ObjectId(); + const match = { + communityId, + status: 'finished', + set: jest.fn(), + save: jest.fn().mockResolvedValue(undefined), + }; + const { service } = createService(match); + + await service.update({ + matchId: new mongoose.Types.ObjectId(), + communityId, + patch: { eventType: 'tournament' }, + }); + + expect(match.set).toHaveBeenCalledWith({ eventType: 'tournament' }); + expect(match.save).toHaveBeenCalledTimes(1); + }); + it('rejects game count changes after recruiting', async () => { const communityId = new mongoose.Types.ObjectId(); const match = { diff --git a/apps/api/src/modules/match/match.service.ts b/apps/api/src/modules/match/match.service.ts index 6300c3ca..70e42ccf 100644 --- a/apps/api/src/modules/match/match.service.ts +++ b/apps/api/src/modules/match/match.service.ts @@ -1,4 +1,4 @@ -import type { MatchHistoryResult } from '@lolympus/contracts'; +import type { MatchEventType, MatchHistoryResult } from '@lolympus/contracts'; import { BadRequestException, ConflictException, @@ -57,6 +57,7 @@ interface UpdateMatchParams { interface ListMatchesQuery { communityId: mongoose.Types.ObjectId; status?: MatchStatus; + eventType?: MatchEventType; limit?: number; scheduledFrom?: Date; scheduledTo?: Date; @@ -71,6 +72,7 @@ interface ListMatchesPageQuery extends ListMatchesQuery { interface MatchListFilter { communityId: mongoose.Types.ObjectId; status?: MatchStatus; + eventType?: MatchEventType | { $in: (MatchEventType | null)[] }; scheduledAt?: { $gte?: Date; $lt?: Date; @@ -712,6 +714,11 @@ export class MatchService { communityId: query.communityId, }; if (query.status) filter.status = query.status; + if (query.eventType) { + // MongoDB matches missing fields as well as explicit null values. + filter.eventType = + query.eventType === 'inhouse' ? { $in: ['inhouse', null] } : query.eventType; + } if (query.scheduledFrom || query.scheduledTo) { filter.scheduledAt = {}; if (query.scheduledFrom) filter.scheduledAt.$gte = query.scheduledFrom; diff --git a/apps/web/src/App.tsx b/apps/web/src/App.tsx index fc1cbca2..8220085f 100644 --- a/apps/web/src/App.tsx +++ b/apps/web/src/App.tsx @@ -1,10 +1,19 @@ -import { BrowserRouter, Link, NavLink, Route, Routes } from "react-router"; -import { lazy, Suspense, type ReactNode } from "react"; +import { + BrowserRouter, + Link, + matchPath, + Navigate, + Route, + Routes, + useLocation, + useNavigate, +} from "react-router"; +import { lazy, Suspense, useState, type FormEvent, type ReactNode } from "react"; import { useMsal } from "@azure/msal-react"; -import { LogOut, Moon, Sun } from "lucide-react"; +import { LogOut, Moon, Search, Sun } from "lucide-react"; import DevAuthSwitcher from "./components/DevAuthSwitcher"; import { DEFAULT_COMMUNITY_ID, setTheme, useTheme } from "./config"; -import { useCommunity, useMe } from "./api/hooks"; +import { useCommunity, useMatch, useMe } from "./api/hooks"; import { isMsalConfigured } from "./lib/auth/msal.config"; import AuthCallbackPage from "./pages/AuthCallback"; import HomePage from "./pages/HomePage"; @@ -30,7 +39,7 @@ const MatchFlowsPreview = import.meta.env.DEV : null; const NAV_ICON_BUTTON_CLASS = - "grid size-9 shrink-0 place-items-center rounded-field text-content-muted transition-colors hover:bg-sunken-strong hover:text-content"; + "grid size-10 shrink-0 place-items-center rounded-field text-content-muted transition-colors hover:bg-sunken-strong hover:text-content md:size-11"; function MsalHeaderActions() { const { accounts, instance } = useMsal(); @@ -39,7 +48,7 @@ function MsalHeaderActions() { if (!account) { return ( 로그인 @@ -51,7 +60,7 @@ function MsalHeaderActions() { return (
- + {name} @@ -61,7 +70,7 @@ function MsalHeaderActions() { aria-label={`${name} 로그아웃`} onClick={() => void instance.logoutRedirect()} > -
@@ -83,7 +92,7 @@ function ThemeToggle() { aria-label={label} onClick={() => setTheme(nextTheme)} > -