Riot ID 자동 갱신 (Riot 클라이언트에 붙으면 바로 · 10분마다 이름 서비스로 연결 계정의 지금 Riot ID 확인, puuid 는 그대로 두고 표시 이름만) · 경기 탭 데스매치 숨김 · 모드(GET /api/matches/modes) · 날짜(after) 필터 (예전 앱은 사이트가 거름) · 범인찾기 목록 데스매치 숨김 · 녹음 없거나 끊긴 경기도 범인찾기 (eligibility.notes, AI 자료에 안내 줄) · Riot 경기 기록 마지막 확인 시각(historyAt) 안내 · 테스트

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
EJClaw
2026-11-21 07:14:07 +09:00
parent 8782df2111
commit 5e756f9eb8
21 changed files with 413 additions and 40 deletions

View File

@@ -49,8 +49,9 @@ test('범인찾기: 분석 가능 판정과 AI 자료', () => {
const ctx = setup();
const { id } = seedValorant(ctx);
const m = ctx.store.getMatch(id)!;
assert.deepEqual(ctx.culprit.eligibility(m), { state: 'ready', reasons: [] });
assert.deepEqual(ctx.culprit.eligibility(m), { state: 'ready', reasons: [], notes: [] });
const input = ctx.culprit.buildInput(m);
assert.ok(!input.text.includes('녹음'), '녹음이 경기를 다 덮으면 녹음 안내 줄 없음');
const lines = input.text.split('\n');
assert.match(lines[0], /^# 경기 발로란트 .* 13:9 \(우리 팀 승리\) · 22라운드/);
// 우리 팀이 P1~P5, 하늘은 음성O, 디스코드 계정이 없는 상대는 음성X
@@ -88,16 +89,30 @@ test('범인찾기: 분석 가능 판정과 AI 자료', () => {
assert.ok(u2Index > lines.findIndex((l) => l.startsWith('[u1] ')));
});
test('범인찾기: 녹음이 늦게 시작 · 음성 변환 중 · 녹음 제외', () => {
test('범인찾기: 녹음이 늦게 시작 · 녹음 없음 · 음성 변환 중 · 녹음 제외', () => {
// 녹음이 끊긴 경기도 분석한다 (v1.11.0): 녹음된 대화만 쓰고 AI 에 알린다
const late = setup();
const a = seedValorant(late, { sessionStartOffsetMs: 17 * MIN });
const e = late.culprit.eligibility(late.store.getMatch(a.id)!);
assert.equal(e.state, 'blocked');
assert.deepEqual(e.reasons, ['녹음이 경기 시작 12분 뒤에 시작됐습니다']);
assert.deepEqual(e, { state: 'ready', reasons: [], notes: ['녹음이 경기 시작 12분 뒤에 시작됐습니다: 녹음된 대화만 씁니다'] });
assert.ok(late.culprit.buildInput(late.store.getMatch(a.id)!).text.includes('\n# 녹음이 경기 시작 12분 뒤에 시작됐습니다. 녹음이 빠진 구간의 대화는 없다\n'));
// 앱을 켜지 않고 한 경기 (녹음 · 대화 없음): 플레이 기록 · 채팅으로만
const none = setup();
const n = seedValorant(none);
none.store.db.prepare('DELETE FROM utterances').run();
none.store.db.prepare('DELETE FROM sessions').run();
const nm = none.store.getMatch(n.id)!;
assert.deepEqual(none.culprit.eligibility(nm), { state: 'ready', reasons: [], notes: ['녹음 없음: 플레이 기록 · 채팅으로만 분석합니다'] });
const ni = none.culprit.buildInput(nm);
assert.ok(ni.text.includes('\n# 이 경기는 음성 녹음이 없다. 모두 음성X 로 보고 플레이 기록과 채팅으로만 평가한다\n'));
assert.ok(ni.players.every((p) => !p.voice));
assert.equal(ni.stats.utterances, 0);
assert.ok(ni.stats.events > 0 && ni.stats.rounds > 0);
const pend = setup();
const b = seedValorant(pend, { pending: true });
assert.deepEqual(pend.culprit.eligibility(pend.store.getMatch(b.id)!), { state: 'pending', reasons: ['음성 변환 중 (1문장 남음)'] });
assert.deepEqual(pend.culprit.eligibility(pend.store.getMatch(b.id)!), { state: 'pending', reasons: ['음성 변환 중 (1문장 남음)'], notes: [] });
// 녹음 제외한 사람의 대화는 보내지 않는다
const ex = setup();

View File

@@ -27,6 +27,7 @@ test('발로란트·롤 어댑터: 가짜 Riot 서버로 경기 시작→채팅
process.env.GVR_LOL_LIVE_URL = mock.base;
process.env.GVR_POLL_MS = '150';
process.env.GVR_DETAIL_RETRY_MS = '100';
process.env.GVR_NAMES_EVERY_MS = '200';
const { Store } = await import('../src/core/db/db.ts');
const { Timeline } = await import('../src/core/timeline.ts');
const { GameAssets } = await import('../src/core/games/assets.ts');
@@ -89,6 +90,16 @@ test('발로란트·롤 어댑터: 가짜 Riot 서버로 경기 시작→채팅
assert.deepEqual(sum.score, { ally: 2, enemy: 1 });
assert.equal(sum.win, true);
// ---- Riot ID 를 바꾼 사람: 연결(puuid)은 그대로, 표시되는 Riot ID 만 새 이름으로
store.upsertUser({ id: 'friend', name: '민수', avatar: null });
store.setAccounts('friend', [{ puuid: 'riotid:아직모름#KR1', riotId: '아직모름#KR1' }]);
const before = live.filter((e) => e.type === 'users.updated').length;
mock.st.names = { 'self-puuid-0001': ['새하늘', 'KR2'] };
await until(() => store.listAccounts().some((a) => a.puuid === 'self-puuid-0001' && a.riot_id === '새하늘#KR2'), 5000, 'rename');
assert.equal(store.userIdForPuuid('self-puuid-0001'), 'owner');
assert.ok(live.filter((e) => e.type === 'users.updated').length > before, '사이트에 유저 목록 다시 보냄');
assert.ok(store.listAccounts().some((a) => a.user_id === 'friend' && a.riot_id === '아직모름#KR1'), 'puuid 모르는 계정은 그대로');
// ---- 롤
mock.st.lolPhase = 'ChampSelect';
await until(() => (gm as any).adapters[1].pendingChat.length === 1, 5000, 'champ select chat');

View File

@@ -73,6 +73,8 @@ test('경기 기록: 발로란트 · 롤 기록을 가져와 history 경기로
assert.equal(store.getMatch('lol-9001')!.source, 'history');
assert.ok(!store.getMatch('val-gone-5'));
assert.ok(JSON.parse(store.meta('history_skip:valorant')!).includes('val-gone-5'));
// 사이트 경기 탭 안내: 마지막으로 끝까지 확인한 때
await until(() => gm.live().every((g) => typeof g.historyAt === 'number'), 5000, 'historyAt');
// 필터
const ids = (has?: 'timeline' | 'voice') => store.listMatches({ limit: 100, has }).map((m) => m.id).sort();
@@ -203,6 +205,7 @@ test('경기 기록: 진행 상황은 지금 게임 상태(games.state)로 나
// 롤만 가져오는 중
let lolRunning = true;
const fake = (game: 'valorant' | 'lol') => ({
lastDoneAt: () => null,
progress: () => (game === 'lol' && lolRunning ? { phase: 'fetch', first: true, scanned: 40, done: 10, total: 40, startedAt: Date.now() - 20000, etaMs: 60000 } : null),
cancel: () => {
if (game !== 'lol' || !lolRunning) return { cancelled: false, resumeAt: null };
@@ -329,3 +332,56 @@ test('경기 기록: 끝까지 훑은 계정에서 새 경기를 받다가 취
store.close();
}
});
test('경기 목록: 데스매치는 빼고, 모드 · 날짜로 거른다 · 모드 목록 (v1.11.0)', async () => {
const dir = tmp();
const { Store } = await import('../src/core/db/db.ts');
const { Timeline } = await import('../src/core/timeline.ts');
const { GameAssets } = await import('../src/core/games/assets.ts');
const { GameManager } = await import('../src/core/games/manager.ts');
const { Culprit } = await import('../src/core/culprit.ts');
const { Bus } = await import('../src/core/util/events.ts');
const { buildApi } = await import('../src/core/api/server.ts');
const { defaultSettings } = await import('../src/core/settings.ts');
const store = new Store(path.join(dir, 'db.sqlite'));
const bus = new Bus();
const s = defaultSettings();
const tl = new Timeline(store);
const gm = new GameManager(store, new GameAssets(path.join(dir, 'cache')), Object.assign(new EventEmitter(), { request: async () => ({}) }) as any, { setGameActive: async () => undefined } as any, tl, bus, () => s, () => null);
const DAY = 86400000;
const T = Date.UTC(2026, 10, 20, 12);
const add = (id: string, game: 'valorant' | 'lol', queue: string | null, at: number, mode: string | null = queue) =>
store.upsertMatch({ id, game, started_at: at, ended_at: at + 1800000, queue, mode, status: 'complete', source: 'history' });
add('val-comp1', 'valorant', 'competitive', T);
add('val-dm', 'valorant', 'deathmatch', T - 1000);
add('val-unr', 'valorant', 'unrated', T - DAY);
add('val-comp2', 'valorant', 'competitive', T - 3 * DAY);
add('val-prem', 'valorant', 'premier', T - 4 * DAY);
add('val-dm-live', 'valorant', '', T - 5 * DAY, 'deathmatch'); // 큐가 비고 모드 칸에만 있는 데스매치
add('lol-1', 'lol', '420', T - 2 * DAY, 'CLASSIC');
const app = await buildApi({ store, timeline: tl, games: gm, dict: {} as any, culprit: new Culprit(store, tl, gm), bus, settings: () => s, trainingDir: () => dir, overviewExtra: () => ({ guild: null, recording: {} as any }), version: 'test' });
const ids = async (qs: string) => (await app.inject({ url: `/api/matches${qs}` })).json().map((m: any) => m.id);
try {
assert.deepEqual(await ids(''), ['val-comp1', 'val-unr', 'lol-1', 'val-comp2', 'val-prem'], '데스매치는 목록에 없다');
assert.deepEqual(await ids('?mode=' + encodeURIComponent('경쟁전')), ['val-comp1', 'val-comp2']);
assert.deepEqual(await ids('?mode=' + encodeURIComponent('데스매치')), [], '데스매치는 모드로 골라도 나오지 않는다');
assert.deepEqual(await ids('?mode=' + encodeURIComponent('없는모드')), []);
// 날짜: after 이상 · before 미만 (사이트는 고른 날의 0시 · 다음 날 0시를 보낸다)
assert.deepEqual(await ids(`?after=${T - 3 * DAY}&before=${T}`), ['val-unr', 'lol-1', 'val-comp2']);
assert.deepEqual(await ids(`?game=valorant&mode=${encodeURIComponent('경쟁전')}&after=${T - DAY}`), ['val-comp1']);
const modes = (await app.inject({ url: '/api/matches/modes' })).json();
assert.deepEqual(modes, [
{ game: 'valorant', mode: '경쟁전', count: 2 },
{ game: 'lol', mode: '솔로 랭크', count: 1 },
{ game: 'valorant', mode: '일반전', count: 1 },
{ game: 'valorant', mode: '프리미어', count: 1 },
]);
assert.deepEqual((await app.inject({ url: '/api/matches/modes?game=lol' })).json(), [{ game: 'lol', mode: '솔로 랭크', count: 1 }]);
// 범인찾기 목록에도 데스매치는 없다
const cu = (await app.inject({ url: '/api/culprit/matches' })).json().map((x: any) => x.match.id);
assert.ok(cu.includes('val-comp1') && !cu.includes('val-dm') && !cu.includes('val-dm-live'));
} finally {
await app.close();
store.close();
}
});

View File

@@ -22,6 +22,8 @@ export interface MockState {
valHistory: { MatchID: string; GameStartTime: number }[];
/** 롤 경기 기록 (LCU, 새것부터) */
lolHistoryList: { gameId: number; gameCreation: number }[];
/** 이름 서비스: puuid → [이름, 태그] (Riot ID 를 바꾼 사람 흉내) */
names: Record<string, [string, string]>;
/** 요청 기록 (경로) */
hits: string[];
}
@@ -46,6 +48,7 @@ export async function startMockRiot(dir: string) {
lolStart: 0,
valHistory: [],
lolHistoryList: [],
names: {},
hits: [],
};
const password = 'pw-test';
@@ -95,6 +98,10 @@ export async function startMockRiot(dir: string) {
return auth.startsWith('Bearer ') && st.valState !== 'INGAME' ? [200, makeValDetails(st.valStart)] : [404, {}];
},
],
[
/^\/name-service\/v2\/players$/,
(_m, auth) => (auth.startsWith('Bearer ') ? [200, Object.entries(st.names).map(([Subject, [GameName, TagLine]]) => ({ Subject, GameName, TagLine }))] : [401, {}]),
],
// ---- LoL Live Client Data
[/^\/liveclientdata\/allgamedata$/, () => (st.lolLive ? [200, st.lolLive] : [404, {}])],
// ---- LCU