fix(qdreader): archive daily sign logs at midnight
This commit is contained in:
@@ -225,6 +225,58 @@ test('quick submit rejects save when Autman JS has no user identity', () => {
|
||||
assert.equal(r.store.qdreader_user_bind_json, undefined);
|
||||
});
|
||||
|
||||
test('cron archives previous run log and clears daily logs before new midnight sign', () => {
|
||||
const previousRun = {
|
||||
runId: '20260518_cron',
|
||||
source: 'cron',
|
||||
startedAt: '2026-05-18T00:00:00.000Z',
|
||||
finishedAt: '2026-05-18T00:00:02.000Z',
|
||||
total: 1,
|
||||
okCount: 1,
|
||||
failCount: 0,
|
||||
items: [{ uid: '12345', ok: true, msg: '昨日签到成功', time: '2026-05-18T00:00:01.000Z' }],
|
||||
};
|
||||
const store = {
|
||||
qdreader_cookie_json: JSON.stringify({ '12345': cookie }),
|
||||
qdreader_user_bind_json: JSON.stringify({ '12345': 'user-a' }),
|
||||
qdreader_last_run_json: JSON.stringify(previousRun),
|
||||
qdreader_last_result_json: JSON.stringify({ '12345': JSON.stringify({ ok: true, msg: '昨日签到成功' }) }),
|
||||
};
|
||||
const r = runPlugin({ content: '', store, userId: 'cron' });
|
||||
const archive = JSON.parse(r.store.qdreader_archive_json);
|
||||
assert.equal(archive['2026-05-18'].runId, '20260518_cron');
|
||||
assert.equal(archive['2026-05-18'].items[0].msg, '昨日签到成功');
|
||||
assert.equal(JSON.parse(r.store.qdreader_last_run_json).source, 'cron');
|
||||
assert.equal(JSON.parse(JSON.parse(r.store.qdreader_last_result_json)['12345']).msg, '签到成功');
|
||||
});
|
||||
|
||||
test('query falls back to archived sign results after daily log was cleared', () => {
|
||||
const archiveRun = {
|
||||
source: 'cron',
|
||||
finishedAt: '2026-05-18T00:00:02.000Z',
|
||||
total: 2,
|
||||
okCount: 1,
|
||||
failCount: 1,
|
||||
items: [
|
||||
{ uid: '12345', ok: true, msg: '签到成功', time: '2026-05-18T00:00:01.000Z' },
|
||||
{ uid: '67890', ok: false, msg: 'Cookie失效', time: '2026-05-18T00:00:01.000Z' },
|
||||
],
|
||||
};
|
||||
const store = {
|
||||
qdreader_cookie_json: JSON.stringify({ '12345': cookie, '67890': cookie.replace(/12345/g, '67890') }),
|
||||
qdreader_user_bind_json: JSON.stringify({ '12345': 'user-a', '67890': 'user-a' }),
|
||||
qdreader_remark_json: JSON.stringify({ '12345': '主号', '67890': '副号' }),
|
||||
qdreader_last_run_json: '{}',
|
||||
qdreader_last_result_json: '{}',
|
||||
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失效/);
|
||||
});
|
||||
|
||||
test('manual sign and cron sign both call sign gateway then qidian checkin', () => {
|
||||
const store = {
|
||||
qdreader_cookie_json: JSON.stringify({ '12345': cookie }),
|
||||
|
||||
Reference in New Issue
Block a user