redo-readings: 아직 적용 안 된 제목 정리 행의 정답도 새 표기로(적용하면 옛 발음이 돌아오던 것), 퀴즈 정답 중 연결된 DB 곡에 사람이 넣은 별칭(quiz/admin)으로도 있는 값은 빼지 않음. 회귀 테스트 2개(고치기 전 실패 확인), docs 13
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
@@ -69,3 +69,29 @@ test('saved quizzes: generated readings replaced, typed answers kept, 이지선
|
||||
expect(JSON.parse(got(a).a)).toEqual(['정꾹이', '정국']);
|
||||
expect(got(b)).toEqual({ t: '[]', a: '[]' });
|
||||
});
|
||||
|
||||
test('제목 정리 rows still waiting get the new spellings too: applying one later does not bring the old reading back', async () => {
|
||||
const { applyTitleReviews } = await import('./songs/title-review');
|
||||
const db = openDb(tempDbPath());
|
||||
const [id] = new Catalog(db).upsert({ title: 'Heaven (feat. X)', artists: [{ name: 'Rod Stewart' }], source: 't', ref: '1' });
|
||||
db.query(
|
||||
"INSERT INTO title_reviews (song_id, kind, status, old_title, old_artist, new_title, new_artist, title_answers, artist_answers, created_at) VALUES (?, 'title', 'pending', 'Heaven (feat. X)', 'Rod Stewart', 'Heaven', 'Rod Stewart', ?, ?, 0)",
|
||||
).run(id!, JSON.stringify(['헤벤']), JSON.stringify(['로드 스투어트']));
|
||||
expect(redoReadings(db).pendingReviews).toBe(1);
|
||||
expect(applyTitleReviews(db, { ids: [id!] }, 'admin').applied).toBe(1);
|
||||
expect(aliases(db, id!, 'title')).toEqual(['Heaven (feat. X)', '헤븐']);
|
||||
expect(aliases(db, id!, 'artist')).toEqual(['로드 스튜어트', '로드스튜어트']);
|
||||
});
|
||||
|
||||
test('saved quizzes: an answer the song DB has from a person (quiz save / admin) stays even when it equals an old generated reading', () => {
|
||||
const db = openDb(tempDbPath());
|
||||
db.query("INSERT INTO users (id, kind, nickname, created_at, last_seen_at) VALUES ('u', 'member', 'u', 0, 0)").run();
|
||||
const quiz = (db.query("INSERT INTO custom_quizzes (owner_id, name, description, visibility, settings_json, kind, created_at, updated_at) VALUES ('u', 'q', '', 'private', '{}', 'normal', 0, 0) RETURNING id").get() as { id: number }).id;
|
||||
const [song] = new Catalog(db).upsert({ title: 'Heaven', artists: [{ name: '에일리' }], source: 't', ref: '1' });
|
||||
db.query("INSERT INTO song_aliases (song_id, part, alias, source) VALUES (?, 'title', '헤벤', 'quiz')").run(song!);
|
||||
const it = (db.query("INSERT INTO custom_quiz_items (quiz_id, pos, song_id, video_id, title, artist, title_answers, artist_answers) VALUES (?, 0, ?, 'aaaaaaaaaaa', 'Heaven', '에일리', ?, '[]') RETURNING id").get(quiz, song!, JSON.stringify(['헤벤'])) as { id: number }).id;
|
||||
redoReadings(db);
|
||||
expect(JSON.parse(db.query<{ t: string }, [number]>('SELECT title_answers t FROM custom_quiz_items WHERE id = ?').get(it)!.t)).toEqual(['헤벤', '헤븐']);
|
||||
// the song's own typed alias is never touched either
|
||||
expect(aliases(db, song!, 'title')).toEqual(['헤벤', '헤븐']);
|
||||
});
|
||||
|
||||
Reference in New Issue
Block a user