이지선다 모드: 조회수가 더 높은 곡 고르기. 이지선다 퀴즈는 조회수가 든 파일로 만들고(custom_quizzes.kind='duel', custom_quiz_items.views, 013 마이그레이션; 1,234,567·123만·1.2억도 읽음, 조회수 없는 줄은 빠짐) 이지선다에서만, 일반 퀴즈는 듣고맞추기에서만 쓴다. 서버 game/duel.ts: 문제마다 A/B 카드, 카드를 누르면 고른 것(시간 전까지 바꾸기), 시간이 끝나면 조회수 공개·높은 쪽 1점·역배(혼자 맞히고 반대쪽 2명 이상) 2점·같으면 둘 다 정답, 매번 새 두 곡/연속(이긴 곡이 조회수를 보인 채 A로 남음). 화면 DuelScreen: 고른 사람 프로필이 카드 밑에, 카드마다 숨은 플레이어(net/duel-player.ts)로 각자 듣고 다시 누르면 멈춘 곳부터 이어서. 방 설정 이지선다(제한 시간 기본 30초·진행 방식·재생위치·문제 수, 이지선다 퀴즈만 목록에), 결과 화면 역배 성공 수. 관리자 파일로 만들기 종류 선택(조회수 열이 있으면 이지선다), 조회수 편집·내보내기·빈 양식. 폰 점수판 가로 스크롤 키보드 접근(axe). 서버 테스트 146개, e2e duel(실제 유튜브 이어 듣기 포함)·game·quiz·admin·rooms·login·a11y 통과
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
@@ -2,7 +2,7 @@
|
||||
import { expect, test } from 'bun:test';
|
||||
import { decodeCsv, parseCsv, readSheetFile, readXlsx, writeXlsx } from './sheet';
|
||||
import { deflatedZip } from './zip-fixture';
|
||||
import { guessColumns, headerRow, parseQuizRows, parseSec, parseVideoId, quizTemplateRows, quizToRows } from './quiz-file';
|
||||
import { guessColumns, headerRow, parseQuizRows, parseSec, parseVideoId, parseViews, quizTemplateRows, quizToRows } from './quiz-file';
|
||||
|
||||
test('reads an Excel-style workbook: shared strings, rich text, numbers, gaps, sheet order and names', async () => {
|
||||
const x = deflatedZip({
|
||||
@@ -74,8 +74,8 @@ test('rows → quiz songs: as written, 순번 order, bad links / no answer / rep
|
||||
|
||||
test('our export reads back to the same songs (answers, own positions, several hints) and the template is valid', () => {
|
||||
const items = [
|
||||
{ songId: null, videoId: 'iIIjS6yDMQo', title: '감옥탈출', artist: '트레일러', titleAnswers: ['구토할배'], artistAnswers: ['trailer'], hints: ['방탈출', '플래시'], fromFile: true, durationSec: null, auto: false, startSec: 12, highlightSec: 61.5 },
|
||||
{ songId: 3, videoId: 'x0-xFqvJ-U8', title: '갓 오브 워 2', artist: '', titleAnswers: [], artistAnswers: [], hints: [], fromFile: false, durationSec: 200, auto: true, startSec: null, highlightSec: null },
|
||||
{ songId: null, videoId: 'iIIjS6yDMQo', title: '감옥탈출', artist: '트레일러', titleAnswers: ['구토할배'], artistAnswers: ['trailer'], hints: ['방탈출', '플래시'], fromFile: true, durationSec: null, auto: false, startSec: 12, highlightSec: 61.5, views: null },
|
||||
{ songId: 3, videoId: 'x0-xFqvJ-U8', title: '갓 오브 워 2', artist: '', titleAnswers: [], artistAnswers: [], hints: [], fromFile: false, durationSec: 200, auto: true, startSec: null, highlightSec: null, views: null },
|
||||
];
|
||||
const { rows } = quizToRows(items);
|
||||
const text = rows.map((r) => r.map((c) => (c === null ? '' : String(c))));
|
||||
@@ -96,3 +96,43 @@ test('video links and times', () => {
|
||||
expect(parseVideoId('https://example.com/watch?v=VO88htcm09E')).toBeNull();
|
||||
expect([parseSec('95'), parseSec('1:35'), parseSec('01:01:01'), parseSec('1분 5초'), parseSec(''), parseSec('조금')]).toEqual([95, 95, 3661, 65, null, undefined]);
|
||||
});
|
||||
|
||||
test('조회수 as people write it', () => {
|
||||
expect(parseViews('1234567')).toBe(1234567);
|
||||
expect(parseViews('1,234,567')).toBe(1234567);
|
||||
expect(parseViews('1,234,567회')).toBe(1234567);
|
||||
expect(parseViews('123만')).toBe(1230000);
|
||||
expect(parseViews('1.2억')).toBe(120000000);
|
||||
expect(parseViews('1억 2,345만')).toBe(123450000);
|
||||
expect(parseViews('3.4M')).toBe(3400000);
|
||||
expect(parseViews('12K views')).toBe(12000);
|
||||
expect(parseViews('1.2345E+9')).toBe(1234500000);
|
||||
expect(parseViews('')).toBeNull();
|
||||
expect(parseViews('많음')).toBeUndefined();
|
||||
});
|
||||
|
||||
test('이지선다 파일: 제목·가수·조회수, rows without views are left out, export and template read back', () => {
|
||||
const rows = [
|
||||
['순번', '유튜브 링크', '제목', '가수', '조회수'],
|
||||
['2', 'https://youtu.be/iIIjS6yDMQo', '감옥탈출', '트레일러', '1.2억'],
|
||||
['1', 'x0-xFqvJ-U8', '갓 오브 워', '', '3,456,789'],
|
||||
['3', 'https://youtu.be/Es6JbQQE79g', '조회수 없음', '누구', ''],
|
||||
['4', 'https://youtu.be/VO88htcm09E', '이상한 값', '누구', '많음'],
|
||||
];
|
||||
const cols = guessColumns(rows[0]!);
|
||||
expect(cols).toEqual(['order', 'link', 'answer', 'desc', 'views']);
|
||||
const p = parseQuizRows(rows, cols, 0, 'duel');
|
||||
expect(p.items.map((i) => [i.title, i.artist, i.views])).toEqual([
|
||||
['갓 오브 워', '', 3456789],
|
||||
['감옥탈출', '트레일러', 120000000],
|
||||
]);
|
||||
expect(p.rows.filter((r) => r.problem).map((r) => [r.line, r.problem])).toEqual([
|
||||
[4, '조회수가 비어 있어요'],
|
||||
[5, '조회수를 읽을 수 없어요 (많음)'],
|
||||
]);
|
||||
const { rows: out } = quizToRows(p.items, 'duel');
|
||||
const text = out.map((r) => r.map((c) => (c === null ? '' : String(c))));
|
||||
expect(parseQuizRows(text, guessColumns(text[0]!), 0, 'duel').items).toEqual(p.items);
|
||||
const t = quizTemplateRows('duel').rows.map((r) => r.map((c) => (c === null ? '' : String(c))));
|
||||
expect(parseQuizRows(t, guessColumns(t[0]!), 0, 'duel').items).toHaveLength(1);
|
||||
});
|
||||
|
||||
Reference in New Issue
Block a user