fix(qdreader): limit archive cron grace window

This commit is contained in:
2026-05-19 16:17:38 +08:00
parent bca0aaa2f7
commit 557b5ae9c2
5 changed files with 29 additions and 14 deletions
+15 -2
View File
@@ -266,7 +266,7 @@ test('midnight cron archives previous run log and clears daily logs without runn
});
test('delayed midnight cron still archives instead of signing', () => {
test('five-minute delayed midnight cron still archives instead of signing', () => {
const previousRun = {
runId: '20260518_cron',
source: 'cron',
@@ -282,12 +282,25 @@ test('delayed midnight cron still archives instead of signing', () => {
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') } });
const r = runPlugin({ content: '', store, userId: 'cron', globals: { Date: fixedDateClass('2026-05-19T00:04: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('after five-minute midnight window cron follows sign path', () => {
const store = {
qdreader_cookie_json: JSON.stringify({ '12345': cookie }),
qdreader_user_bind_json: JSON.stringify({ '12345': 'user-a' }),
qdreader_last_run_json: JSON.stringify({ source: 'cron', finishedAt: '2026-05-18T07:15:02.000Z', total: 1, okCount: 1, failCount: 0, items: [{ uid: '12345', ok: true }] }),
};
const r = runPlugin({ content: '', store, userId: 'cron', globals: { Date: fixedDateClass('2026-05-19T00:05:00.000+08:00') } });
assert.equal(r.calls.length, 2);
assert.match(r.replies[0], /启点读书签到结果/);
assert.equal(r.store.qdreader_archive_json, undefined);
});
test('query falls back to archived sign results after daily log was cleared', () => {
const archiveRun = {
source: 'cron',