fix(qdreader): handle auth and risk-conf daily tasks
This commit is contained in:
@@ -1245,6 +1245,77 @@ test('adv task ignores count metadata and submits each unfinished upstream task
|
||||
assert.ok(finishCalls.every(c => /partial-task/.test(c.body)));
|
||||
});
|
||||
|
||||
test('adv and daily tasks report auth failure instead of empty list on HTTP 401', () => {
|
||||
const store = {
|
||||
qdreader_cookie_json: JSON.stringify({ '12345': cookie }),
|
||||
qdreader_user_bind_json: JSON.stringify({ '12345': 'user-a' }),
|
||||
qdreader_task_pref_json: JSON.stringify({ '12345': { adv: true, extraAdv: true } }),
|
||||
};
|
||||
const unauthorized = { statusCode: 401, body: { timestamp: '2026-06-20T08:11:17Z', status: 401, error: 'Unauthorized', path: '/argus/api/v2/video/adv/mainPage' } };
|
||||
const r = runPlugin({
|
||||
content: '启点签到',
|
||||
store,
|
||||
userId: 'user-a',
|
||||
requests: [
|
||||
{ body: { code: 0, data: { headers: { 'QD-Sign': 'sig' } } } },
|
||||
{ statusCode: 200, body: { code: 1, msg: '今日已签到' } },
|
||||
{ body: { code: 0, data: { headers: { 'QD-Sign': 'sig' } } } },
|
||||
{ statusCode: 200, body: { code: 1, msg: '无可领取礼包' } },
|
||||
{ body: { code: 0, data: { headers: { 'QD-Sign': 'sig' } } } },
|
||||
unauthorized,
|
||||
{ body: { code: 0, data: { headers: { 'QD-Sign': 'sig' } } } },
|
||||
unauthorized,
|
||||
],
|
||||
});
|
||||
assert.match(r.replies[0], /激励任务❌\(登录状态已失效,请更新 Cookie\)/);
|
||||
assert.match(r.replies[0], /每日任务❌\(登录状态已失效,请更新 Cookie\)/);
|
||||
assert.doesNotMatch(r.replies[0], /任务列表为空/);
|
||||
});
|
||||
|
||||
|
||||
test('daily task treats accepted risk-conf callbacks as submitted when status does not refresh immediately', () => {
|
||||
const store = {
|
||||
qdreader_cookie_json: JSON.stringify({ '12345': cookie }),
|
||||
qdreader_user_bind_json: JSON.stringify({ '12345': 'user-a' }),
|
||||
qdreader_task_pref_json: JSON.stringify({ '12345': { extraAdv: true } }),
|
||||
};
|
||||
const unchanged = { code: 0, Data: {
|
||||
SurpriseBenefit: { TaskId: 'surprise-risk', Title: '惊喜福利任务', IsFinished: 0, IsReceived: 0 },
|
||||
VideoRewardTab: { TaskList: [
|
||||
{ TaskId: 'one-risk', Title: '完成1个广告任务得奖励', IsReceived: 0 },
|
||||
{ TaskId: 'three-risk', Title: '完成3个广告任务得奖励', IsReceived: 0 },
|
||||
] }
|
||||
} };
|
||||
const r = runPlugin({
|
||||
content: '启点签到',
|
||||
store,
|
||||
userId: 'user-a',
|
||||
requests: [
|
||||
{ body: { code: 0, data: { headers: { 'QD-Sign': 'sig' } } } },
|
||||
{ statusCode: 200, body: { code: 1, msg: '今日已签到' } },
|
||||
{ body: { code: 0, data: { headers: { 'QD-Sign': 'sig' } } } },
|
||||
{ statusCode: 200, body: { code: 1, msg: '无可领取礼包' } },
|
||||
{ body: { code: 0, data: { headers: { 'QD-Sign': 'sig' } } } },
|
||||
{ statusCode: 200, body: unchanged },
|
||||
{ body: { code: 0, data: { headers: { 'QD-Sign': 'sig' } } } },
|
||||
{ statusCode: 200, body: { Result: '0', Message: '', Data: { RiskConf: { BanId: '3' } } } },
|
||||
{ body: { code: 0, data: { headers: { 'QD-Sign': 'sig' } } } },
|
||||
{ statusCode: 200, body: { Result: '0', Message: '', Data: { RiskConf: { BanId: '3' } } } },
|
||||
{ body: { code: 0, data: { headers: { 'QD-Sign': 'sig' } } } },
|
||||
{ statusCode: 200, body: { Result: '0', Message: '', Data: { RiskConf: { BanId: '3' } } } },
|
||||
{ body: { code: 0, data: { headers: { 'QD-Sign': 'sig' } } } },
|
||||
{ statusCode: 200, body: { Result: '0', Message: '', Data: { RiskConf: { BanId: '3' } } } },
|
||||
{ body: { code: 0, data: { headers: { 'QD-Sign': 'sig' } } } },
|
||||
{ statusCode: 200, body: { Result: '0', Message: '', Data: { RiskConf: { BanId: '3' } } } },
|
||||
{ body: { code: 0, data: { headers: { 'QD-Sign': 'sig' } } } },
|
||||
{ statusCode: 200, body: unchanged },
|
||||
],
|
||||
});
|
||||
assert.match(r.replies[0], /每日任务✅\(已提交,状态待刷新\)/);
|
||||
assert.doesNotMatch(r.replies[0], /部分任务失败/);
|
||||
});
|
||||
|
||||
|
||||
test('adv and daily tasks parse Autman response data when body is empty', () => {
|
||||
const store = {
|
||||
qdreader_cookie_json: JSON.stringify({ '12345': cookie }),
|
||||
|
||||
Reference in New Issue
Block a user