관리자 "원곡 찾기" 화면: 유튜브 원곡 찾기 결과를 확정·후보·못 찾음·원곡 없음·재생 불가·아직 안 찾음 탭으로(방금 처리된 곡이 위), 진행률·끝 예상·이번 작업 결과, 5초 자동 새로고침(보고 있을 때만, 목록 위에서는 멈춤), 줄에서 바로 확정 + 패널에서 미리듣기·다른 후보·주소 붙여넣기·확정 취소(관리자 후보로, 게임에서 빠지고 자동 확정 안 됨)·원곡 없음 표시·다시 찾기, 처리하면 다음 곡으로. 저장은 기존 경로, 감사 로그 기록

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
EJClaw
2026-10-19 21:47:10 +09:00
parent c4edccf352
commit 8d4e32d737
11 changed files with 760 additions and 5 deletions

View File

@@ -259,6 +259,53 @@ try {
await gctx.close();
});
await step('원곡 찾기: 진행률, 후보 바로 확정, 확정 취소 → 후보, 원곡 없음, 5초 자동 새로고침', async () => {
const c = new Catalog(db);
const now = Date.now();
const tried = (id: number, at: number) => db.query("INSERT OR REPLACE INTO signals (song_id, kind, value, fetched_at) VALUES (?, 'yt_tried_ytmusic', ?, ?)").run(id, at, at);
const [guess] = c.upsert({ title: '후보곡', artists: [{ name: '후보가수' }], source: 'e2e', ref: 'g' });
db.query("UPDATE songs SET youtube_status = 'candidate', youtube_source = 'ytmusic', youtube_id = 'candvideo01', youtube_title = '후보곡 (Live)', youtube_channel = '후보가수', embeddable = 1, youtube_checked_at = ? WHERE id = ?").run(now, guess!);
db.query("INSERT INTO youtube_candidates (song_id, video_id, title, channel, duration_sec, score, source) VALUES (?, 'candvideo01', '후보곡 (Live)', '후보가수', 200, 55, 'ytmusic')").run(guess!);
tried(guess!, now);
const [lost] = c.upsert({ title: '못찾은곡', artists: [{ name: '누구' }], source: 'e2e', ref: 'l' });
tried(lost!, now - 1000);
const [auto] = c.upsert({ title: '자동확정곡', artists: [{ name: '자동가수' }], source: 'e2e', ref: 'a' });
db.query("UPDATE songs SET youtube_status = 'matched', youtube_source = 'ytmusic', youtube_id = 'autovideo01', youtube_title = '자동확정곡', youtube_channel = '자동가수 - Topic', embeddable = 1, youtube_checked_at = ? WHERE id = ?").run(now, auto!);
tried(auto!, now);
db.query("INSERT INTO collect_jobs (kind, status, done, total, started_at, pid) VALUES ('match-youtube', 'running', 3, 10, ?, 1)").run(now - 60_000);
await p.getByRole('link', { name: '🔎 원곡 찾기' }).click();
await p.getByRole('heading', { name: '원곡 찾기' }).waitFor();
await p.getByText('🔎 지금 찾는 중').waitFor();
await p.getByText('3 / 10 (30%)').waitFor();
// 후보 tab is first: one click confirms, and it moves to 확정
await row(p, '후보곡').getByRole('button', { name: '확정', exact: true }).click();
await toastSeen(p, "'후보곡' 확정했어요");
const st = (t: string) => db.query<{ youtube_status: string; youtube_source: string | null }, [string]>('SELECT youtube_status, youtube_source FROM songs WHERE title = ?').get(t)!;
expect(st('후보곡').youtube_status === 'matched', '후보 확정 안 됨');
await p.getByRole('button', { name: /^확정 \d/ }).click();
await row(p, '자동확정곡').click();
await p.getByRole('complementary', { name: '원곡 확인' }).getByRole('button', { name: '확정 취소' }).click();
await toastSeen(p, '확정을 취소했어요');
expect(st('자동확정곡').youtube_status === 'candidate' && st('자동확정곡').youtube_source === 'admin', '확정 취소가 후보(관리자)로 안 바뀜');
await p.screenshot({ path: join(SHOTS, 'youtube-review-panel.png') });
await p.getByRole('button', { name: /^못 찾음 \d/ }).click();
await row(p, '못찾은곡').click();
await p.getByRole('button', { name: '원곡 없음으로 표시' }).click();
await toastSeen(p, '원곡 없음으로 표시했어요');
expect(st('못찾은곡').youtube_source === 'admin', '원곡 없음 표시 안 됨');
// the matcher finds a new song: it shows up by itself within 5 seconds (pointer away from the list)
await p.mouse.move(5, 5);
await p.getByRole('button', { name: /^못 찾음 \d/ }).click();
const [fresh] = c.upsert({ title: '방금찾은곡', artists: [{ name: '새가수' }], source: 'e2e', ref: 'f' });
tried(fresh!, Date.now());
await row(p, '방금찾은곡').waitFor({ timeout: 8000 });
await p.screenshot({ path: join(SHOTS, 'youtube-review.png'), fullPage: true });
const acts = db.query<{ action: string }, []>("SELECT action FROM admin_audit WHERE action LIKE 'song.%' ORDER BY id DESC LIMIT 3").all().map((r) => r.action);
expect(acts.includes('song.youtube.unconfirm') && acts.includes('song.youtube.none'), `기록 없음: ${acts}`);
db.query("UPDATE collect_jobs SET status = 'done', finished_at = ? WHERE kind = 'match-youtube' AND status = 'running'").run(Date.now());
});
await p.goto(ORIGIN + '/admin/songs');
await p.locator('.data-table tbody tr').first().waitFor();
await p.screenshot({ path: join(SHOTS, 'stage8-songs.png'), fullPage: true });