정답 자동 채우기: 채우는 중에 이지선다로 바꾸거나 다른 파일을 열면 '채우는 중'이 남아 만들기·추가 버튼이 계속 막히던 것 — 대상이 없어지거나 화면이 바뀌면 기다림을 풂. 1,000곡까지만 묻고 나머지를 빈 정답으로 '채웠어요' 처리하던 것 — 1,000곡씩 나눠 전부 묻고(fillAnswers), 실패한 요청·빠진 답의 곡은 '못 채워서 적힌 정답만 써요'로 따로 표시. 단위 테스트(2,500곡 나누기, 실패 구분, 화면 바뀐 뒤 중단), e2e quiz(요청 중 이지선다 전환, 502 실패 표시)

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
EJClaw
2026-11-04 16:05:31 +09:00
parent 74eaeb85da
commit a8885a37dc
4 changed files with 158 additions and 8 deletions

View File

@@ -198,6 +198,39 @@ 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('정답 자동 채우기: 빈 정답 칸은 서버가 채움, 채우는 중에 이지선다로 바꿔도 만들기 버튼이 막히지 않음, 실패는 "채웠어요"로 안 보임', async () => {
const csv = new TextEncoder().encode('링크,제목,가수,정답\nhttps://youtu.be/9hzKkTpXDwM,사랑을 했다(LOVE SCENARIO),아이콘,\nhttps://youtu.be/Yz-Af4p_Vv8,광(狂),SG워너비,\n');
const openFile = async () => {
await p.goto(`${ORIGIN}/admin/quizzes`);
await p.getByRole('button', { name: /^파일로 만들기/ }).click();
await p.getByLabel('퀴즈 파일').setInputFiles({ name: '빈 정답.csv', mimeType: 'text/csv', buffer: Buffer.from(csv) });
};
// 1. the request hangs: switching to 이지선다 must not leave the button waiting
let release!: () => void;
const hold = new Promise<void>((r) => (release = r));
await p.route(`${ORIGIN}/api/admin/quizzes/answers`, async (route) => (await hold, route.continue().catch(() => {})));
await openFile();
await p.getByText('자동으로 채우는 중').waitFor();
expect(await p.getByRole('button', { name: '2곡으로 만들기' }).isDisabled(), '채우는 중에는 만들기를 기다림');
await p.getByRole('radio', { name: /이지선다/ }).click();
const duelBtn = p.getByRole('button', { name: '2곡으로 이지선다 만들기' });
await duelBtn.waitFor();
for (let i = 0; i < 20 && (await duelBtn.isDisabled()); i++) await p.waitForTimeout(100);
expect(await duelBtn.isEnabled(), '이지선다로 바꾼 뒤 만들기 버튼이 막힘(요청이 끝나지 않은 채)');
release();
await p.unroute(`${ORIGIN}/api/admin/quizzes/answers`);
// 2. back to 일반: filled from the server, shown under the title
await p.getByRole('radio', { name: /일반 퀴즈/ }).click();
await p.getByText('(자동으로 채웠어요)').waitFor();
await p.getByText('또는 LOVE SCENARIO, 사랑을 했다 LOVE SCENARIO').waitFor();
// 3. the server fails: those songs say so, never "채웠어요"
await p.route(`${ORIGIN}/api/admin/quizzes/answers`, (route) => route.fulfill({ status: 502, contentType: 'application/json', body: '{"error":"잠깐 끊김"}' }));
await openFile();
await p.getByText('2곡은 자동으로 못 채워서 적힌 정답만 써요').waitFor();
expect((await p.getByText('(자동으로 채웠어요)').count()) === 0, '실패했는데 채웠다고 보임');
expect(await p.getByRole('button', { name: '2곡으로 만들기' }).isEnabled(), '실패 뒤 만들기 버튼이 막힘');
await p.unroute(`${ORIGIN}/api/admin/quizzes/answers`);
});
await step('재생목록으로 엑셀 만들기 → 검토(DB 곡·확인 필요·같은 영상은 빠진 곡) → 받은 엑셀을 파일로 만들기: 자동은 DB 하이라이트, 처음부터는 0초', async () => {
await p.goto(`${ORIGIN}/admin/quizzes`);
await p.getByRole('button', { name: /재생목록으로 엑셀 만들기/ }).click();