fix(qdreader): harden midnight cron dispatch

This commit is contained in:
2026-05-19 15:54:43 +08:00
parent 5b0f20fa24
commit bca0aaa2f7
5 changed files with 35 additions and 10 deletions
+23
View File
@@ -265,6 +265,29 @@ test('midnight cron archives previous run log and clears daily logs without runn
assert.deepEqual(JSON.parse(r.store.qdreader_last_result_json), {});
});
test('delayed midnight cron still archives instead of signing', () => {
const previousRun = {
runId: '20260518_cron',
source: 'cron',
finishedAt: '2026-05-18T07:15:02.000Z',
total: 1,
okCount: 1,
failCount: 0,
items: [{ uid: '12345', ok: true, msg: '昨日签到成功' }],
};
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', globals: { Date: fixedDateClass('2026-05-19T00:23:00.000+08:00') } });
assert.equal(r.calls.length, 0);
assert.match(r.replies[0], /日志归档完成/);
assert.equal(JSON.parse(r.store.qdreader_archive_json)['2026-05-18'].runId, '20260518_cron');
});
test('query falls back to archived sign results after daily log was cleared', () => {
const archiveRun = {
source: 'cron',