fix(qdreader): harden cron trigger detection
This commit is contained in:
@@ -55,6 +55,7 @@ function runPlugin({ pluginCode = code, filename = pluginPath, content = '', sto
|
||||
if (String(req.url).includes('/sign')) return { body: { code: 0, data: { headers: { 'QD-Sign': 'sig' } } } };
|
||||
return { statusCode: 200, body: { code: 0, msg: '签到成功' } };
|
||||
},
|
||||
input: () => '',
|
||||
...globals,
|
||||
};
|
||||
vm.createContext(ctx);
|
||||
@@ -717,6 +718,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', () => {
|
||||
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], /定时任务\/零点任务/);
|
||||
});
|
||||
|
||||
test('manual sign only runs current user accounts while cron runs all accounts', () => {
|
||||
const store = {
|
||||
qdreader_cookie_json: JSON.stringify({ '12345': cookie, '67890': cookie.replace(/12345/g, '67890') }),
|
||||
|
||||
Reference in New Issue
Block a user