diff --git a/apps/backend/src/services/claim/affiliate-dash-bind-state.test.ts b/apps/backend/src/services/claim/affiliate-dash-bind-state.test.ts index f6c15579..e52efce2 100644 --- a/apps/backend/src/services/claim/affiliate-dash-bind-state.test.ts +++ b/apps/backend/src/services/claim/affiliate-dash-bind-state.test.ts @@ -4,6 +4,7 @@ import assert from 'node:assert/strict' import { canReuseAffiliateDashBindSnapshot, isAffiliateDashBindSnapshotStale, + shouldRefreshAffiliateDashBindStateForSnapshot, } from './kuaishou-cloud-claim-service.js' test('isAffiliateDashBindSnapshotStale detects bind uuid that belongs to old uid', () => { @@ -136,3 +137,47 @@ test('canReuseAffiliateDashBindSnapshot refuses mismatched bound account', () => false, ) }) + +test('shouldRefreshAffiliateDashBindStateForSnapshot keeps polling before submit', () => { + assert.equal( + shouldRefreshAffiliateDashBindStateForSnapshot({ + taskStatus: 'waiting_binding', + orderStatus: 'paid', + submitStatus: '', + }), + true, + ) +}) + +test('shouldRefreshAffiliateDashBindStateForSnapshot stops after submit starts', () => { + assert.equal( + shouldRefreshAffiliateDashBindStateForSnapshot({ + taskStatus: 'redeeming', + orderStatus: 'delivering', + submitStatus: 'delivering', + }), + false, + ) +}) + +test('shouldRefreshAffiliateDashBindStateForSnapshot stops after delivered', () => { + assert.equal( + shouldRefreshAffiliateDashBindStateForSnapshot({ + taskStatus: 'redeemed', + orderStatus: 'delivered', + submitStatus: 'delivered', + }), + false, + ) +}) + +test('shouldRefreshAffiliateDashBindStateForSnapshot stops for failed platform result', () => { + assert.equal( + shouldRefreshAffiliateDashBindStateForSnapshot({ + taskStatus: 'retry_pending', + orderStatus: 'ship_failed', + submitStatus: '', + }), + false, + ) +}) diff --git a/apps/backend/src/services/claim/kuaishou-cloud-claim-service.ts b/apps/backend/src/services/claim/kuaishou-cloud-claim-service.ts index 86506f1e..2550e953 100644 --- a/apps/backend/src/services/claim/kuaishou-cloud-claim-service.ts +++ b/apps/backend/src/services/claim/kuaishou-cloud-claim-service.ts @@ -232,7 +232,9 @@ export async function getKuaishouCloudClaimDetail(token: unknown): Promise