이지선다 조회수 자동: 빈 양식에서 조회수 열을 빼고, 올린 뒤 서버가 곡마다 토픽 음원 + MV 조회수를 불러와 더함. 짝은 유튜브 뮤직 노래↔동영상 전환(watch 응답의 counterpart, 쿠키 필요), 조회수는 로그인 없이 player videoDetails.viewCount(안 되면 watch 화면 숫자). quizzes/duel-views.ts가 pending 곡을 한 곡씩 처리(재시작해도 이어서), 쿠키 만료면 남은 곡 모두 이유와 함께 failed. 짝이 없는 곡은 있는 영상 하나만 쓰고 비고 표시. 파일·편집기에 적은 숫자는 그대로 쓰고 다시 불러오기에서 빠짐, 칸을 비우고 저장하면 자동. 편집기: 조회수(토픽·MV)·비고 칸, 불러오는 중 표시와 2초 폴링(저장 안 됨으로 안 잡힘), 조회수 다시 불러오기(전체/곡), 저장 때 편집기의 옛 사본이 서버가 불러온 값을 덮지 않음. 내보내기는 직접 넣은 숫자만 조회수 열에. 파일로 만들기는 조회수 열이 없으면 고른 종류 유지. 014 마이그레이션, 단위·API 테스트, e2e duel 단계, docs 04·10·12
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
@@ -1,6 +1,7 @@
|
||||
/**
|
||||
* 이지선다 in real browsers (fake player, no YouTube):
|
||||
* - 관리자 → 퀴즈 → 파일로 만들기: a CSV with a 조회수 column is taken as 이지선다 (rows without views left out), 엑셀로 내보내기
|
||||
* - 관리자 → 퀴즈 → 파일로 만들기: a CSV with a 조회수 column is taken as 이지선다 (numbers used as written, bad ones left out), 엑셀로 내보내기
|
||||
* - 이지선다 양식 without 조회수: the server fetches 토픽 + MV (fake YouTube Music), the editor shows them and the 비고
|
||||
* - 방 설정 → 이지선다 → only 이지선다 퀴즈 are listed; 2 questions from 4 songs
|
||||
* - three players: tapping a card plays it and picks it, picks move, avatars show under the cards, the views come at
|
||||
* the end, alone on the higher card against two = 역배 +2; results with the 역배 column (phone screen too)
|
||||
@@ -28,6 +29,17 @@ const app = startServer({
|
||||
stopWaitMs: 200,
|
||||
discordExchange: async (code) => ({ id: code, username: 'u', global_name: '사금향', avatar: null }),
|
||||
gameTiming: { limitMs: 9000, revealMs: 6000 },
|
||||
// 조회수 자동: duelvid0006 has 토픽 + MV, duelvid0007 only a 토픽
|
||||
quizAdmin: {
|
||||
viewsDelayMs: 300,
|
||||
viewsSource: async () => ({
|
||||
songPair: async (id) =>
|
||||
id === 'duelvid0006'
|
||||
? { type: 'MUSIC_VIDEO_TYPE_ATV', other: { videoId: 'duelmv00006', type: 'MUSIC_VIDEO_TYPE_OMV' } }
|
||||
: { type: 'MUSIC_VIDEO_TYPE_ATV', other: null },
|
||||
viewCount: async (id) => ({ duelvid0006: 153_021_540, duelmv00006: 120_456_643, duelvid0007: 4_321 })[id] ?? 0,
|
||||
}),
|
||||
},
|
||||
});
|
||||
const db = app.db;
|
||||
|
||||
@@ -94,14 +106,14 @@ try {
|
||||
await host.waitForURL(`${ORIGIN}/**`);
|
||||
let quizId = 0;
|
||||
|
||||
await step('파일로 만들기: 조회수 열이 있는 CSV → 이지선다로 골라짐, 조회수 없는 줄은 빠짐 → 4곡으로 만들기 → 내보내기', async () => {
|
||||
const csv = ['유튜브 링크,제목,가수,조회수', 'https://youtu.be/duelvid0001,노래1,가수1,1.2억', 'duelvid0002,노래2,가수2,"34,000,000"', 'https://youtu.be/duelvid0003,노래3,가수3,500만', 'https://youtu.be/duelvid0004,노래4,가수4,12345회', 'https://youtu.be/duelvid0005,노래5,가수5,'].join('\n');
|
||||
await step('파일로 만들기: 조회수 열이 있는 CSV → 이지선다로 골라짐, 읽을 수 없는 조회수 줄은 빠짐 → 4곡으로 만들기 → 내보내기', async () => {
|
||||
const csv = ['유튜브 링크,제목,가수,조회수', 'https://youtu.be/duelvid0001,노래1,가수1,1.2억', 'duelvid0002,노래2,가수2,"34,000,000"', 'https://youtu.be/duelvid0003,노래3,가수3,500만', 'https://youtu.be/duelvid0004,노래4,가수4,12345회', 'https://youtu.be/duelvid0005,노래5,가수5,많음'].join('\n');
|
||||
await host.goto(`${ORIGIN}/admin/quizzes`);
|
||||
await host.getByRole('button', { name: /파일로 만들기/ }).click();
|
||||
await host.getByLabel('퀴즈 파일').setInputFiles({ name: '조회수 대결.csv', mimeType: 'text/csv', buffer: Buffer.from(csv) });
|
||||
await host.getByText('빠지는 줄 1개').waitFor();
|
||||
expect((await host.getByRole('radio', { name: /이지선다/ }).getAttribute('aria-checked')) === 'true', '조회수 열이 있는데 이지선다로 골라지지 않음');
|
||||
await host.getByText('조회수가 비어 있어요').waitFor();
|
||||
await host.getByText('조회수를 읽을 수 없어요 (많음)').waitFor();
|
||||
await host.locator('td', { hasText: '1.2억회' }).waitFor();
|
||||
await host.screenshot({ path: join(SHOTS, 'duel-file-preview.png'), fullPage: true });
|
||||
await host.getByRole('button', { name: '4곡으로 이지선다 만들기' }).click();
|
||||
@@ -118,6 +130,35 @@ try {
|
||||
expect(back[0]!.includes('조회수') && back[1]![4] === '120000000', `내보낸 내용: ${JSON.stringify(back.slice(0, 2))}`);
|
||||
});
|
||||
|
||||
await step('이지선다 양식(조회수 열 없음) → 자동: 올린 뒤 토픽 + MV 조회수를 불러오고, 토픽만 있는 곡은 비고로 표시', async () => {
|
||||
await host.goto(`${ORIGIN}/admin/quizzes`);
|
||||
await host.getByRole('button', { name: /파일로 만들기/ }).click();
|
||||
await host.getByRole('radio', { name: /이지선다/ }).click();
|
||||
const [dl] = await Promise.all([host.waitForEvent('download'), host.getByRole('button', { name: /빈 양식 받기/ }).click()]);
|
||||
const template = (await readXlsx(new Uint8Array(await Bun.file((await dl.path())!).arrayBuffer())))[0]!.rows;
|
||||
expect(!template[0]!.includes('조회수'), `양식 열: ${JSON.stringify(template[0])}`);
|
||||
const csv = [template[0]!.join(','), '1,https://youtu.be/duelvid0006,라일락,아이유,,', '2,https://youtu.be/duelvid0007,토픽만,누구,,'].join('\n');
|
||||
await host.getByLabel('퀴즈 파일').setInputFiles({ name: '자동 조회수.csv', mimeType: 'text/csv', buffer: Buffer.from(csv) });
|
||||
// no 조회수 column: the 이지선다 picked above stays
|
||||
await host.locator('td', { hasText: '토픽만' }).waitFor();
|
||||
expect((await host.getByRole('radio', { name: /이지선다/ }).getAttribute('aria-checked')) === 'true', '조회수 열이 없는 파일에서 이지선다 선택이 풀림');
|
||||
expect((await host.locator('td', { hasText: /^자동$/ }).count()) === 2, '미리보기의 조회수가 자동으로 안 보임');
|
||||
await host.getByRole('button', { name: '2곡으로 이지선다 만들기' }).click();
|
||||
await host.waitForURL(/\/admin\/quizzes\/\d+$/);
|
||||
const rows = host.locator('.quiz-songs tbody tr');
|
||||
await rows.nth(0).getByText('2.7억회').waitFor();
|
||||
await rows.nth(0).getByText('토픽 1.5억 · MV 1.2억').waitFor();
|
||||
await rows.nth(1).getByText('MV 없음 (토픽 조회수만)').waitFor();
|
||||
// taking in the fetched numbers is not an unsaved change
|
||||
await host.getByText('저장됨').waitFor();
|
||||
await rows.nth(0).click();
|
||||
await host.getByText(/273,478,183회.*= 토픽 153,021,540회 \+ MV 120,456,643회/).waitFor();
|
||||
await host.screenshot({ path: join(SHOTS, 'duel-views-auto.png'), fullPage: true });
|
||||
const id = Number(new URL(host.url()).pathname.split('/').pop());
|
||||
const saved = db.query<{ title: string; views: number }, [number]>('SELECT title, views FROM custom_quiz_items WHERE quiz_id = ? ORDER BY pos').all(id);
|
||||
expect(JSON.stringify(saved) === JSON.stringify([{ title: '라일락', views: 273_478_183 }, { title: '토픽만', views: 4_321 }]), `저장된 조회수: ${JSON.stringify(saved)}`);
|
||||
});
|
||||
|
||||
let code = '';
|
||||
const g1 = await guestPage('철수');
|
||||
const g2 = await guestPage('영희', { width: 390, height: 844, mobile: true });
|
||||
@@ -131,7 +172,9 @@ try {
|
||||
await host.getByText('방 설정에서 이지선다 퀴즈를 골라 주세요.').waitFor();
|
||||
const list = host.getByRole('listbox', { name: '이지선다 퀴즈 목록' });
|
||||
await list.getByRole('option').first().waitFor();
|
||||
expect((await list.getByRole('option').count()) === 1, '이지선다 퀴즈가 아닌 것도 보임');
|
||||
// the two 이지선다 quizzes made above, no 일반 퀴즈
|
||||
const names = await list.getByRole('option').allInnerTexts();
|
||||
expect(names.length === 2 && names.some((n) => n.includes('조회수 대결')) && names.some((n) => n.includes('자동 조회수')), `이지선다 퀴즈 목록: ${JSON.stringify(names)}`);
|
||||
await list.getByRole('option', { name: /조회수 대결/ }).click();
|
||||
await host.getByText('퀴즈 곡 4곡').waitFor();
|
||||
await host.locator('.pool-banner', { hasText: '2문제' }).waitFor();
|
||||
|
||||
Reference in New Issue
Block a user