fix(qdreader): align weekly exchange payload

This commit is contained in:
2026-05-22 19:28:00 +08:00
parent c7011a43ea
commit 373130c178
5 changed files with 102 additions and 14 deletions
+64 -1
View File
@@ -432,7 +432,7 @@ test('optional QDReader full tasks use upstream executable endpoints and sign ab
(req) => String(req.url).includes('/sign') ? { body: { code: 0, data: { headers: { 'QD-Sign': 'sig' } } } } : { statusCode: 200, body: { code: 0, msg: 'ok' } },
{ statusCode: 200, body: { code: 0, msg: '抽奖成功' } },
(req) => String(req.url).includes('/sign') ? { body: { code: 0, data: { headers: { 'QD-Sign': 'sig' } } } } : { statusCode: 200, body: { code: 0, msg: 'ok' } },
{ statusCode: 200, body: { code: 0, Data: { Balance: 100, GoodsList: [{ GoodsId: 'g1', NeedScore: 10 }] } } },
{ statusCode: 200, body: { code: 0, Data: { Balance: 100, Goods: [{ GoodsId: 'g1', GoodsScore: 10, ChapterCardCount: 5 }] } } },
(req) => String(req.url).includes('/sign') ? { body: { code: 0, data: { headers: { 'QD-Sign': 'sig' } } } } : { statusCode: 200, body: { code: 0, msg: 'ok' } },
{ statusCode: 200, body: { code: 0, msg: '兑换成功' } },
(req) => String(req.url).includes('/sign') ? { body: { code: 0, data: { headers: { 'QD-Sign': 'sig' } } } } : { statusCode: 200, body: { code: 0, msg: 'ok' } },
@@ -458,6 +458,9 @@ test('optional QDReader full tasks use upstream executable endpoints and sign ab
const finishCalls = r.calls.filter(c => /argus\/api\/v1\/video\/adv\/finishWatch$/.test(c.url));
assert.equal(finishCalls.length, 6);
assert.deepEqual(finishCalls.map(c => new URLSearchParams(c.body).get('taskId')), ['adv-1', 'surprise-1', 'one-ad', 'daily-3', 'daily-3', 'daily-3']);
const exchangeCall = r.calls.find(c => /argus\/api\/v3\/checkin\/exchangegoods$/.test(c.url));
assert.equal(new URLSearchParams(exchangeCall.body).get('goodId'), 'g1');
assert.equal(new URLSearchParams(exchangeCall.body).get('GoodsId'), null);
assert.match(r.replies[0], /激励任务✅/);
assert.match(r.replies[0], /每日任务✅/);
assert.match(r.replies[0], /每日抽奖✅/);
@@ -466,6 +469,66 @@ test('optional QDReader full tasks use upstream executable endpoints and sign ab
assert.match(r.replies[0], /大咖荐书✅/);
});
test('weekly exchange follows upstream Goods/GoodsScore and posts lowercase goodId', () => {
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': { weeklyExchange: true } }),
};
const sunday = fixedDateClass('2026-05-24T07:01:00.000+08:00');
const r = runPlugin({
content: '启点签到',
store,
userId: 'user-a',
globals: { Date: sunday },
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: { Balance: 25, Goods: [
{ GoodsId: 'cheap', GoodsScore: 10, ChapterCardCount: 1 },
{ GoodsId: 'best', GoodsScore: 20, ChapterCardCount: 3 },
{ GoodsId: 'too-expensive', GoodsScore: 50, ChapterCardCount: 10 },
] } } },
{ body: { code: 0, data: { headers: { 'QD-Sign': 'sig' } } } },
{ statusCode: 200, body: { code: 0, Data: {}, msg: '' } },
],
});
const exchangeCall = r.calls.find(c => /argus\/api\/v3\/checkin\/exchangegoods$/.test(c.url));
assert.ok(exchangeCall);
assert.equal(new URLSearchParams(exchangeCall.body).get('goodId'), 'best');
assert.equal(new URLSearchParams(exchangeCall.body).get('GoodsId'), null);
assert.match(r.replies[0], /每周兑换✅\(消耗 20 点兑换 3 点章节卡\)/);
});
test('weekly exchange reports upstream not-time result explicitly', () => {
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': { weeklyExchange: true } }),
};
const sunday = fixedDateClass('2026-05-24T07:01:00.000+08:00');
const r = runPlugin({
content: '启点签到',
store,
userId: 'user-a',
globals: { Date: sunday },
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: { Balance: 25, Goods: [{ GoodsId: 'g1', GoodsScore: 10, ChapterCardCount: 1 }] } } },
{ body: { code: 0, data: { headers: { 'QD-Sign': 'sig' } } } },
{ statusCode: 200, body: { result: -220000, message: 'raw not time' } },
],
});
assert.match(r.replies[0], /每周兑换❌\(未到兑换时间\)/);
});
test('bucketGet/bucketSet fallback rejects when user identity is absent', () => {
const replies = [];
const bucketStore = {};