fix: persist qdreader last run logs
This commit is contained in:
@@ -72,10 +72,15 @@ test('manual sign and cron sign both call sign gateway then qidian checkin', ()
|
||||
assert.match(manual.calls[0].url, /api\.120399\.xyz\/sign$/);
|
||||
assert.match(manual.calls[1].url, /h5\.if\.qidian\.com\/argus\/api\/v3\/checkin\/checkin$/);
|
||||
assert.match(manual.replies[0], /✅ 12\*\*\*45/);
|
||||
assert.match(manual.replies[0], /记录时间:/);
|
||||
assert.equal(JSON.parse(manual.store.qdreader_last_run_json).source, 'manual');
|
||||
assert.equal(JSON.parse(manual.store.qdreader_last_run_json).okCount, 1);
|
||||
assert.equal(JSON.parse(JSON.parse(manual.store.qdreader_last_result_json)['12345']).source, 'manual');
|
||||
|
||||
const cron = runPlugin({ content: '', store: { ...store } });
|
||||
assert.equal(cron.calls.length, 2);
|
||||
assert.match(cron.replies[0], /启点读书签到结果/);
|
||||
assert.equal(JSON.parse(cron.store.qdreader_last_run_json).source, 'cron');
|
||||
});
|
||||
|
||||
test('bucketGet/bucketSet fallback works when get/set are unavailable in Autman-like env', () => {
|
||||
@@ -136,19 +141,21 @@ test('account command shows only current user bound accounts without cookies', (
|
||||
assert.doesNotMatch(r.replies[1], /QDHeader=/);
|
||||
});
|
||||
|
||||
test('query command shows execution status not account management', () => {
|
||||
test('query command shows last sign log not account management', () => {
|
||||
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-b' }),
|
||||
qdreader_remark_json: JSON.stringify({ '12345': '主号', '67890': '副号' }),
|
||||
qdreader_last_result_json: JSON.stringify({
|
||||
'12345': JSON.stringify({ ok: true, msg: '签到成功', time: '2026-05-17T00:00:00.000Z' }),
|
||||
'67890': JSON.stringify({ ok: false, msg: '失败', time: '2026-05-17T00:00:00.000Z' }),
|
||||
'12345': JSON.stringify({ ok: true, msg: '签到成功', time: '2026-05-17T00:00:00.000Z', source: 'cron', runId: 'r1' }),
|
||||
'67890': JSON.stringify({ ok: false, msg: '失败', time: '2026-05-17T00:00:00.000Z', source: 'cron', runId: 'r1' }),
|
||||
}),
|
||||
qdreader_last_run_json: JSON.stringify({ source: 'cron', finishedAt: '2026-05-17T00:00:01.000Z', okCount: 1, failCount: 1, total: 2 }),
|
||||
};
|
||||
const r = runPlugin({ content: '启点查询', store, userId: 'user-a', listens: ['1'] });
|
||||
assert.match(r.replies[0], /启点查询/);
|
||||
assert.match(r.replies[1], /启点执行情况/);
|
||||
assert.match(r.replies[1], /启点最近签到记录/);
|
||||
assert.match(r.replies[1], /最近批次:定时任务/);
|
||||
assert.match(r.replies[1], /12\*\*\*45/);
|
||||
assert.match(r.replies[1], /主号/);
|
||||
assert.match(r.replies[1], /签到成功/);
|
||||
@@ -162,16 +169,17 @@ test('query menu can inspect a single bound account', () => {
|
||||
qdreader_user_bind_json: JSON.stringify({ '12345': 'user-a', '67890': 'user-a' }),
|
||||
qdreader_remark_json: JSON.stringify({ '12345': '主号', '67890': '副号' }),
|
||||
qdreader_last_result_json: JSON.stringify({
|
||||
'12345': JSON.stringify({ ok: true, msg: '签到成功', time: '2026-05-17T00:00:00.000Z' }),
|
||||
'67890': JSON.stringify({ ok: false, msg: '失败', time: '2026-05-17T00:00:00.000Z' }),
|
||||
'12345': JSON.stringify({ ok: true, msg: '签到成功', time: '2026-05-17T00:00:00.000Z', source: 'cron', runId: 'r1' }),
|
||||
'67890': JSON.stringify({ ok: false, msg: '失败', time: '2026-05-17T00:00:00.000Z', source: 'cron', runId: 'r1' }),
|
||||
}),
|
||||
qdreader_last_run_json: JSON.stringify({ source: 'cron', finishedAt: '2026-05-17T00:00:01.000Z', okCount: 1, failCount: 1, total: 2 }),
|
||||
};
|
||||
const r = runPlugin({ content: '启点查询', store, userId: 'user-a', listens: ['2', '2'] });
|
||||
assert.match(r.replies[0], /启点查询/);
|
||||
assert.match(r.replies[1], /请选择要查询的账号/);
|
||||
assert.match(r.replies[1], /1\. 12\*\*\*45/);
|
||||
assert.match(r.replies[1], /2\. 67\*\*\*90/);
|
||||
assert.match(r.replies[2], /启点单账号执行情况/);
|
||||
assert.match(r.replies[2], /启点单账号最近签到记录/);
|
||||
assert.match(r.replies[2], /67\*\*\*90/);
|
||||
assert.match(r.replies[2], /副号/);
|
||||
assert.doesNotMatch(r.replies[2], /12\*\*\*45/);
|
||||
@@ -191,6 +199,22 @@ test('account menu prompts remark after add and can edit from detail', () => {
|
||||
assert.equal(JSON.parse(clear.store.qdreader_remark_json)['12345'], undefined);
|
||||
});
|
||||
|
||||
|
||||
test('failed sign exceptions are written to last execution log', () => {
|
||||
const store = {
|
||||
qdreader_cookie_json: JSON.stringify({ '12345': cookie }),
|
||||
qdreader_user_bind_json: JSON.stringify({ '12345': 'user-a' }),
|
||||
};
|
||||
const r = runPlugin({ content: '启点签到', store, userId: 'user-a', requests: [new Error('sign api down'), new Error('sign api down')] });
|
||||
assert.match(r.replies[0], /sign api down/);
|
||||
const lastRun = JSON.parse(r.store.qdreader_last_run_json);
|
||||
assert.equal(lastRun.failCount, 1);
|
||||
assert.equal(lastRun.items[0].error, true);
|
||||
const lastResult = JSON.parse(JSON.parse(r.store.qdreader_last_result_json)['12345']);
|
||||
assert.equal(lastResult.ok, false);
|
||||
assert.equal(lastResult.msg, 'sign api down');
|
||||
});
|
||||
|
||||
test('legacy ck query points to separated commands', () => {
|
||||
const r = runPlugin({ content: '启点ck 查询' });
|
||||
assert.match(r.replies[0], /请使用一级菜单:启点账号 或 启点查询/);
|
||||
|
||||
Reference in New Issue
Block a user