fix(qdreader): format query logs for readability

This commit is contained in:
2026-05-20 12:28:08 +08:00
parent 74a8e45405
commit 5bc2a818e1
5 changed files with 118 additions and 51 deletions
+30 -5
View File
@@ -289,10 +289,33 @@ test('query falls back to archived sign results after daily log was cleared', ()
qdreader_archive_json: JSON.stringify({ '2026-05-18': archiveRun }),
};
const r = runPlugin({ content: '启点查询', store, userId: 'user-a', listens: ['1'] });
assert.match(r.replies[1], /启点最近归档签到记录/);
assert.match(r.replies[1], /最近归档:2026-05-18/);
assert.match(r.replies[1], /12\*\*\*45(主号):✅ 签到成功/);
assert.match(r.replies[1], /67\*\*\*90(副号):❌ Cookie失效/);
assert.match(r.replies[1], /启点最近签到记录/);
assert.match(r.replies[1], /归档批次2026-05-18/);
assert.match(r.replies[1], /汇总:✅ 1 ❌ 1 总计 2/);
assert.match(r.replies[1], /• 12\*\*\*45(主号):✅ 签到成功/);
assert.match(r.replies[1], /• 67\*\*\*90(副号):❌ Cookie失效/);
});
test('query output shortens timestamps and long raw messages for readability', () => {
const archiveRun = {
source: 'cron',
finishedAt: '2026-05-18T07:15:02.123Z',
total: 1,
okCount: 0,
failCount: 1,
items: [
{ uid: '12345', ok: false, msg: 'Error: very long upstream response payload with stack trace and raw json body that should not flood chat output', time: '2026-05-18T07:15:01.456Z' },
],
};
const store = {
qdreader_cookie_json: JSON.stringify({ '12345': cookie }),
qdreader_user_bind_json: JSON.stringify({ '12345': 'user-a' }),
qdreader_archive_json: JSON.stringify({ '2026-05-18': archiveRun }),
};
const r = runPlugin({ content: '启点查询', store, userId: 'user-a', listens: ['1'] });
assert.match(r.replies[1], /时间:2026-05-18 07:15/);
assert.match(r.replies[1], /Error: very long upstream response payload with stack tra\.\.\./);
assert.doesNotMatch(r.replies[1], /raw json body that should not flood/);
});
test('manual sign and cron sign both call sign gateway then qidian checkin', () => {
@@ -393,7 +416,9 @@ test('query command shows last sign log not account management', () => {
const r = runPlugin({ content: '启点查询', store, userId: 'user-a', listens: ['1'] });
assert.match(r.replies[0], /启点查询/);
assert.match(r.replies[1], /启点最近签到记录/);
assert.match(r.replies[1], /最近批次:定时任务/);
assert.match(r.replies[1], /最近批次/);
assert.match(r.replies[1], /来源:定时任务/);
assert.match(r.replies[1], /汇总:✅ 1 | ❌ 1 | 总计 2/);
assert.match(r.replies[1], /12\*\*\*45/);
assert.match(r.replies[1], /主号/);
assert.match(r.replies[1], /签到成功/);