Add song-level report triage
This commit is contained in:
@@ -284,3 +284,18 @@ test('admin song list includes metadata-only phone songs for lyrics lookup', asy
|
||||
expect((await app.request(`/api/admin/media/${id}/redownload`, { method: 'POST', headers: { Cookie: cookie } })).status).toBe(202);
|
||||
expect((await app.request('/api/admin/media/phoneSong01/redownload', { method: 'POST' })).status).toBe(401);
|
||||
});
|
||||
|
||||
test('report triage filters aging flags and resolves every open report for one song', async () => {
|
||||
const id = VID;
|
||||
const a = await dbmod.upsertFlag({ videoId: id, index: 0, text: 'Flagged line', rev: 1, reason: 'words', note: '', reporter: 'listener-a' });
|
||||
const b = await dbmod.upsertFlag({ videoId: id, index: 0, text: 'Flagged line', rev: 1, reason: 'typo', note: '', reporter: 'listener-b' });
|
||||
await dbmod.db.execute({ sql: 'UPDATE lyric_flags SET created_at=? WHERE id IN (?,?)', args: [Math.floor(Date.now() / 1000) - 10 * 86400, a.id, b.id] });
|
||||
const cookie = await adminCookie();
|
||||
const aged = await (await app.request('/api/admin/flags?status=open&olderThanDays=7', { headers: { Cookie: cookie } })).json();
|
||||
expect(aged.flags.filter(flag => flag.videoId === id)).toHaveLength(2);
|
||||
const unauthorized = await app.request(`/api/admin/flags/song/${id}/resolve`, { method: 'POST', headers: { 'Content-Type': 'application/json' }, body: '{}' });
|
||||
expect(unauthorized.status).toBe(401);
|
||||
const response = await app.request(`/api/admin/flags/song/${id}/resolve`, json('POST', {}, { Cookie: cookie }));
|
||||
expect(await response.json()).toMatchObject({ ok: true, resolved: 2 });
|
||||
expect((await dbmod.listFlagsForVideo(id, 'open'))).toHaveLength(0);
|
||||
});
|
||||
|
||||
Reference in New Issue
Block a user