재생목록으로 엑셀 만들기: 관리자 → 퀴즈 목록 카드. 플레이리스트 가져오기와 같은 검토(서버 DB 곡, 영상 제목 정리, 스포티파이는 유튜브 뮤직 검색, 다른 사이트 재생 확인) 결과를 파일로 만들기가 그대로 읽는 엑셀로 받음 — 시트 '퀴즈'(순번·유튜브 영상 링크·제목·가수·시작(초)·하이라이트(초)·길이(초)·비고)와 '빠진 곡'(재생 막힘·없는 영상·못 찾은 곡·같은 영상, 이유와 함께; 제목 열이 없어 곡으로 읽히지 않음). 비고: DB 곡 / 제목·가수 확인 필요(영상 제목에 가수-제목 형식이 없어 채널 이름을 가수로 씀, 플레이리스트 가져오기에도 표시) / 확인 필요 / 유튜브 뮤직에서 찾음. 조회수 열은 넣지 않음(이지선다는 서버가 불러옴). 파일로 만들기·파일에서 가져오기: '시작·하이라이트가 빈 곡: 자동 / 처음부터' 선택(처음부터 = 0/0으로 적어 하이라이트부터 방에서도 처음부터), 길이(초) 열 읽기. 파일로 만들기의 자동 곡은 서버 DB에 같은 영상이 있으면 그 하이라이트(직접 위치로)와 길이를 씀 — 파일 곡은 DB와 연결하지 않아 자동이 늘 처음부터였던 것. writeXlsxSheets(여러 시트). 단위·API 테스트, e2e quiz 단계, docs 10·12
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
@@ -109,7 +109,7 @@ try {
|
||||
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.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', '조회수 열이 있는데 이지선다로 골라지지 않음');
|
||||
@@ -132,7 +132,7 @@ try {
|
||||
|
||||
await step('이지선다 양식(조회수 열 없음) → 자동: 올린 뒤 토픽 + MV 조회수를 불러오고, 토픽만 있는 곡은 비고로 표시', async () => {
|
||||
await host.goto(`${ORIGIN}/admin/quizzes`);
|
||||
await host.getByRole('button', { name: /파일로 만들기/ }).click();
|
||||
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;
|
||||
|
||||
@@ -3,6 +3,7 @@
|
||||
* - a DB song added from the search shows (and, with 자동 off, keeps) the DB highlight, not the 30% guess
|
||||
* - an edit made while 저장 is on its way stays and stays unsaved
|
||||
* - 파일로 만들기 from an Excel-style (deflated) .xlsx, 엑셀로 내보내기 reads back, 파일에서 가져오기 a CP949 .csv
|
||||
* - 재생목록으로 엑셀 만들기 → the file goes back into 파일로 만들기 (빈 시작·하이라이트: 자동 / 처음부터)
|
||||
* Run: bun run build && bun e2e/quiz.e2e.ts (needs /usr/bin/google-chrome)
|
||||
*/
|
||||
import { chromium, type Browser, type BrowserContext } from 'playwright-core';
|
||||
@@ -28,7 +29,23 @@ const app = startServer({
|
||||
stopWaitMs: 200,
|
||||
discordExchange: async (code) => ({ id: code, username: 'u', global_name: '사금향', avatar: null }),
|
||||
checkEmbed: async () => ({ state: 'ok', author: 'IU - Topic', title: 'Official Audio' }),
|
||||
quizAdmin: { searchYoutube: async () => [], lavalink: null },
|
||||
quizAdmin: {
|
||||
searchYoutube: async () => [],
|
||||
lavalink: { url: 'http://lavalink.e2e', password: 'x' },
|
||||
importDelayMs: 0,
|
||||
lavalinkFetch: (async () =>
|
||||
Response.json({
|
||||
loadType: 'playlist',
|
||||
data: {
|
||||
info: { name: '내 재생목록' },
|
||||
tracks: [
|
||||
{ info: { identifier: 'jeqdYqsrsA0', title: '아이유 - 좋은 날 (Official MV)', author: 'LOEN', length: 236000, sourceName: 'youtube' } },
|
||||
{ info: { identifier: 'iIIjS6yDMQo', title: '밤편지 (Official MV)', author: '아이유 공식', length: 260000, sourceName: 'youtube' } },
|
||||
{ info: { identifier: 'jeqdYqsrsA0', title: '아이유 - 좋은 날', author: 'LOEN', length: 236000, sourceName: 'youtube' } },
|
||||
],
|
||||
},
|
||||
})) as unknown as typeof fetch,
|
||||
},
|
||||
});
|
||||
const db = app.db;
|
||||
{
|
||||
@@ -134,7 +151,7 @@ try {
|
||||
'xl/worksheets/sheet2.xml': `<worksheet><sheetData><row r="1">${cell('A1', '메모')}</row></sheetData></worksheet>`,
|
||||
});
|
||||
await p.goto(`${ORIGIN}/admin/quizzes`);
|
||||
await p.getByRole('button', { name: /파일로 만들기/ }).click();
|
||||
await p.getByRole('button', { name: /^파일로 만들기/ }).click();
|
||||
await p.getByLabel('퀴즈 파일').setInputFiles({ name: '게임 BGM.xlsx', mimeType: 'application/vnd.openxmlformats-officedocument.spreadsheetml.sheet', buffer: Buffer.from(xlsx) });
|
||||
await p.getByText('빠지는 줄 2개').waitFor();
|
||||
expect((await p.getByLabel('시트').inputValue()) === '0', '곡이 있는 시트를 먼저 고르지 않음');
|
||||
@@ -180,6 +197,66 @@ try {
|
||||
await p.getByText('저장됨').waitFor();
|
||||
expect(db.query<{ n: number }, [number]>('SELECT COUNT(*) n FROM custom_quiz_items WHERE quiz_id = ?').get(quizId)!.n === 4, '가져온 곡 저장');
|
||||
});
|
||||
await step('재생목록으로 엑셀 만들기 → 검토(DB 곡·확인 필요·같은 영상은 빠진 곡) → 받은 엑셀을 파일로 만들기: 자동은 DB 하이라이트, 처음부터는 0초', async () => {
|
||||
await p.goto(`${ORIGIN}/admin/quizzes`);
|
||||
await p.getByRole('button', { name: /재생목록으로 엑셀 만들기/ }).click();
|
||||
await p.getByLabel('재생목록 주소').fill('https://www.youtube.com/playlist?list=PLe2e');
|
||||
await p.getByRole('button', { name: '검토 시작' }).click();
|
||||
const get = p.getByRole('button', { name: /엑셀 받기/ });
|
||||
await get.waitFor();
|
||||
expect((await get.innerText()).includes('2곡'), `받기 버튼: ${await get.innerText()}`);
|
||||
await p.getByText('재생목록 1번 곡과 같은 영상').waitFor();
|
||||
await p.screenshot({ path: join(SHOTS, 'quiz-playlist-sheet.png'), fullPage: true });
|
||||
const [dl] = await Promise.all([p.waitForEvent('download'), get.click()]);
|
||||
expect(dl.suggestedFilename() === '내 재생목록.xlsx', `파일 이름: ${dl.suggestedFilename()}`);
|
||||
const bytes = new Uint8Array(await Bun.file((await dl.path())!).arrayBuffer());
|
||||
const book = await readXlsx(bytes);
|
||||
expect(book.map((x) => x.name).join() === '퀴즈,빠진 곡', `시트: ${book.map((x) => x.name)}`);
|
||||
expect(
|
||||
JSON.stringify(book[0]!.rows) ===
|
||||
JSON.stringify([
|
||||
['순번', '유튜브 영상 링크', '제목', '가수', '시작(초)', '하이라이트(초)', '길이(초)', '비고'],
|
||||
['1', 'https://youtu.be/jeqdYqsrsA0', '좋은 날', '아이유', '', '', '236', 'DB 곡'],
|
||||
['2', 'https://youtu.be/iIIjS6yDMQo', '밤편지', '아이유', '', '', '260', '제목·가수 확인 필요 (영상 제목 형식이 달라 채널 이름을 가수로 씀)'],
|
||||
]),
|
||||
`엑셀 내용: ${JSON.stringify(book[0]!.rows)}`,
|
||||
);
|
||||
const upload = async (blank: '자동' | '처음부터', name: string) => {
|
||||
await p.goto(`${ORIGIN}/admin/quizzes`);
|
||||
await p.getByRole('button', { name: /^파일로 만들기/ }).click();
|
||||
await p.getByLabel('퀴즈 파일').setInputFiles({ name: '내 재생목록.xlsx', mimeType: 'application/vnd.openxmlformats-officedocument.spreadsheetml.sheet', buffer: Buffer.from(bytes) });
|
||||
await p.getByText('시작·하이라이트가 빈 곡 2곡').waitFor();
|
||||
if (blank === '처음부터') {
|
||||
await p.getByRole('radio', { name: /처음부터 재생/ }).click();
|
||||
await p.screenshot({ path: join(SHOTS, 'quiz-file-blank-positions.png'), fullPage: true });
|
||||
}
|
||||
await p.getByLabel('퀴즈 이름').fill(name);
|
||||
await p.getByRole('button', { name: '2곡으로 만들기' }).click();
|
||||
await p.waitForURL(/\/admin\/quizzes\/\d+$/);
|
||||
const id = Number(new URL(p.url()).pathname.split('/').pop());
|
||||
return db.query<{ title: string; auto: number; start_sec: number | null; highlight_sec: number | null; duration_sec: number | null }, [number]>(
|
||||
'SELECT title, auto, start_sec, highlight_sec, duration_sec FROM custom_quiz_items WHERE quiz_id = ? ORDER BY pos',
|
||||
).all(id);
|
||||
};
|
||||
const auto = await upload('자동', '재생목록 자동');
|
||||
expect(
|
||||
JSON.stringify(auto) ===
|
||||
JSON.stringify([
|
||||
{ title: '좋은 날', auto: 0, start_sec: 0, highlight_sec: 95, duration_sec: 236 },
|
||||
{ title: '밤편지', auto: 1, start_sec: null, highlight_sec: null, duration_sec: 260 },
|
||||
]),
|
||||
`자동: ${JSON.stringify(auto)}`,
|
||||
);
|
||||
const fromStart = await upload('처음부터', '재생목록 처음부터');
|
||||
expect(
|
||||
JSON.stringify(fromStart) ===
|
||||
JSON.stringify([
|
||||
{ title: '좋은 날', auto: 0, start_sec: 0, highlight_sec: 0, duration_sec: 236 },
|
||||
{ title: '밤편지', auto: 0, start_sec: 0, highlight_sec: 0, duration_sec: 260 },
|
||||
]),
|
||||
`처음부터: ${JSON.stringify(fromStart)}`,
|
||||
);
|
||||
});
|
||||
expect(errors.length === 0, `페이지 오류: ${errors.join(' | ')}`);
|
||||
} catch (e) {
|
||||
console.log(e instanceof Error ? e.message.slice(0, 400) : e);
|
||||
|
||||
Reference in New Issue
Block a user