fix(qdreader): restore upstream adv task flow

This commit is contained in:
2026-05-22 00:55:22 +08:00
parent d2a7e49ec5
commit fc4b3bc587
4 changed files with 34 additions and 116 deletions
+12 -15
View File
@@ -861,7 +861,7 @@ test('adv task does not report success when only unrelated task is finished afte
{ statusCode: 200, body: { code: 0, Data: { VideoRewardTab: { TaskList: [{ TaskId: 'old-done', Title: '已完成旧任务', IsFinished: 1 }, { TaskId: '1165585369246138372', Title: '看视频领福利', IsFinished: 0 }] } } } },
],
});
assert.match(r.replies[0], /激励任务❌\(已提交 1 个视频任务,仍有 1 个未完成\)/);
assert.match(r.replies[0], /激励任务❌\(任务未完成\)/);
assert.match(r.replies[0], /汇总:成功 0 \/ 失败 1 \/ 总计 1/);
});
@@ -899,7 +899,7 @@ test('adv task reports failure when submitted target ids remain unfinished even
] } } } },
],
});
assert.match(r.replies[0], /激励任务❌\(已提交 2 个视频任务,仍有 2 个未完成,跳过 1 个需其它入口任务\)/);
assert.match(r.replies[0], /激励任务❌\(任务未完成\)/);
assert.match(r.replies[0], /汇总:成功 0 \/ 失败 1 \/ 总计 1/);
});
@@ -932,9 +932,9 @@ test('adv task skips non-ad entries that must be handled by their own modules',
] } } } },
],
});
assert.match(r.replies[0], /激励任务\(已完成,跳过 1 个需其它入口任务\)/);
assert.equal(r.calls.filter(c => /video\/adv\/finishWatch$/.test(c.url)).length, 1);
assert.doesNotMatch(r.calls.find(c => /video\/adv\/finishWatch$/.test(c.url)).body, /1165585369246138370/);
assert.match(r.replies[0], /激励任务\(任务未完成\)/);
assert.equal(r.calls.filter(c => /video\/adv\/finishWatch$/.test(c.url)).length, 2);
assert.ok(r.calls.some(c => /video\/adv\/finishWatch$/.test(c.url) && /1165585369246138370/.test(c.body)));
});
test('adv task accepts nested data result 9 with empty message from sign gateway wrapper', () => {
@@ -985,16 +985,12 @@ test('adv task repeats same upstream fragment task until requested count before
{ 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: { result: 9, message: '' } },
{ body: { code: 0, data: { headers: { 'QD-Sign': 'sig' } } } },
{ statusCode: 200, body: { code: 0, Data: { VideoRewardTab: { TaskList: [{ TaskId: '1187767793786748928', Title: '激励碎片', IsFinished: 1, NeedCount: 3 }] } } } },
],
});
assert.match(r.replies[0], /激励任务✅\(已完成\)/);
const finishCalls = r.calls.filter(c => /video\/adv\/finishWatch$/.test(c.url));
assert.equal(finishCalls.length, 3);
assert.equal(finishCalls.length, 1);
assert.ok(finishCalls.every(c => /1187767793786748928/.test(c.body)));
});
@@ -1024,6 +1020,8 @@ test('adv task follows upstream completion when final list item is finished afte
{ 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 },
@@ -1031,11 +1029,12 @@ test('adv task follows upstream completion when final list item is finished afte
] } } } },
],
});
assert.match(r.replies[0], /激励任务✅\(已完成,跳过 1 个需其它入口任务\)/);
assert.match(r.replies[0], /激励任务✅\(已完成\)/);
assert.match(r.replies[0], /汇总:成功 1 \/ 失败 0 \/ 总计 1/);
assert.equal(r.calls.filter(c => /video\/adv\/finishWatch$/.test(c.url)).length, 3);
});
test('adv task derives remaining callbacks from Count and NeedCount metadata', () => {
test('adv task ignores count metadata and submits each unfinished upstream task once', () => {
const store = {
qdreader_cookie_json: JSON.stringify({ '12345': cookie }),
qdreader_user_bind_json: JSON.stringify({ '12345': 'user-a' }),
@@ -1055,14 +1054,12 @@ test('adv task derives remaining callbacks from Count and NeedCount metadata', (
{ 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.equal(finishCalls.length, 1);
assert.ok(finishCalls.every(c => /partial-task/.test(c.body)));
});