fix: detect fake imtype for qdreader cron

This commit is contained in:
2026-05-23 13:22:26 +08:00
parent 8d59be2d71
commit 7388cf8eb5
4 changed files with 42 additions and 26 deletions
+17 -15
View File
@@ -752,25 +752,27 @@ test('manual sign replies per account first and summary separately for multi-acc
assert.match(r.replies[2], /日志已归档/);
});
test('cron detection uses ImType cron and does not consume input as command text', () => {
test('cron detection uses ImType cron/fake and does not consume input as command text', () => {
const store = {
qdreader_cookie_json: JSON.stringify({ '12345': cookie }),
qdreader_user_bind_json: JSON.stringify({ '12345': 'user-a' }),
};
const r = runPlugin({
content: '',
store,
userId: 'cron',
globals: {
ImType: () => 'cron',
input: () => 'q',
Date: fixedDateClass('2026-05-19T07:01:00.000+08:00'),
},
});
assert.equal(r.calls.length, 4);
assert.equal(r.replies.length, 1);
assert.match(r.replies[0], /汇总:成功 1 \/ 失败 0 \/ 总计 1/);
assert.match(r.replies[0], /定时任务\/零点任务/);
for (const imType of ['cron', 'fake']) {
const r = runPlugin({
content: imType === 'fake' ? 'q' : '',
store: { ...store },
userId: 'cron',
globals: {
ImType: () => imType,
input: () => 'q',
Date: fixedDateClass('2026-05-19T07:01:00.000+08:00'),
},
});
assert.equal(r.calls.length, 4, imType);
assert.equal(r.replies.length, 1, imType);
assert.match(r.replies[0], /汇总:成功 1 \/ 失败 0 \/ 总计 1/, imType);
assert.match(r.replies[0], /定时任务\/零点任务/, imType);
}
});
test('manual sign only runs current user accounts while cron runs all accounts', () => {