fix(qdreader): align adv completion with upstream
This commit is contained in:
@@ -998,6 +998,74 @@ test('adv task repeats same upstream fragment task until requested count before
|
||||
assert.ok(finishCalls.every(c => /1187767793786748928/.test(c.body)));
|
||||
});
|
||||
|
||||
test('adv task follows upstream completion when final list item is finished after callbacks', () => {
|
||||
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 } }),
|
||||
};
|
||||
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: { code: 0, Data: { VideoRewardTab: { TaskList: [
|
||||
{ TaskId: 'target-a', Title: '看视频领福利A', IsFinished: 0 },
|
||||
{ TaskId: 'target-b', Title: '看视频领福利B', IsFinished: 0 },
|
||||
{ TaskId: '1165585369246138370', Title: '每日签到', IsFinished: 0 },
|
||||
] } } } },
|
||||
{ body: { code: 0, data: { headers: { 'QD-Sign': 'sig' } } } },
|
||||
{ statusCode: 200, body: { result: 9, message: '' } },
|
||||
{ body: { code: 0, data: { headers: { 'QD-Sign': 'sig' } } } },
|
||||
{ statusCode: 200, body: { result: 9, message: '' } },
|
||||
{ body: { code: 0, data: { headers: { 'QD-Sign': 'sig' } } } },
|
||||
{ statusCode: 200, body: { code: 0, Data: { VideoRewardTab: { TaskList: [
|
||||
{ TaskId: 'target-a', Title: '看视频领福利A', IsFinished: 0 },
|
||||
{ TaskId: 'target-b', Title: '看视频领福利B', IsFinished: 0 },
|
||||
{ TaskId: '1165585369246138370', Title: '每日签到', IsFinished: 1 },
|
||||
] } } } },
|
||||
],
|
||||
});
|
||||
assert.match(r.replies[0], /激励任务✅\(已完成,跳过 1 个需其它入口任务\)/);
|
||||
assert.match(r.replies[0], /汇总:成功 1 \/ 失败 0 \/ 总计 1/);
|
||||
});
|
||||
|
||||
test('adv task derives remaining callbacks from Count and NeedCount metadata', () => {
|
||||
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 } }),
|
||||
};
|
||||
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: { code: 0, Data: { VideoRewardTab: { TaskList: [{ TaskId: 'partial-task', Title: '看视频领福利', IsFinished: 0, Count: 1, NeedCount: 3 }] } } } },
|
||||
{ body: { code: 0, data: { headers: { 'QD-Sign': 'sig' } } } },
|
||||
{ statusCode: 200, body: { result: 9, message: '' } },
|
||||
{ body: { code: 0, data: { headers: { 'QD-Sign': 'sig' } } } },
|
||||
{ statusCode: 200, body: { result: 9, message: '' } },
|
||||
{ body: { code: 0, data: { headers: { 'QD-Sign': 'sig' } } } },
|
||||
{ statusCode: 200, body: { code: 0, Data: { VideoRewardTab: { TaskList: [{ TaskId: 'partial-task', Title: '看视频领福利', IsFinished: 1, Count: 3, NeedCount: 3 }] } } } },
|
||||
],
|
||||
});
|
||||
assert.match(r.replies[0], /激励任务✅\(已完成\)/);
|
||||
const finishCalls = r.calls.filter(c => /video\/adv\/finishWatch$/.test(c.url));
|
||||
assert.equal(finishCalls.length, 2);
|
||||
assert.ok(finishCalls.every(c => /partial-task/.test(c.body)));
|
||||
});
|
||||
|
||||
test('daily task follows upstream sequence: surprise task, one-ad task, then three daily ad callbacks', () => {
|
||||
const store = {
|
||||
qdreader_cookie_json: JSON.stringify({ '12345': cookie }),
|
||||
|
||||
Reference in New Issue
Block a user