修复 affiliate-dash 绑定状态一致性
This commit is contained in:
@@ -0,0 +1,138 @@
|
||||
import test from 'node:test'
|
||||
import assert from 'node:assert/strict'
|
||||
|
||||
import {
|
||||
canReuseAffiliateDashBindSnapshot,
|
||||
isAffiliateDashBindSnapshotStale,
|
||||
} from './kuaishou-cloud-claim-service.js'
|
||||
|
||||
test('isAffiliateDashBindSnapshotStale detects bind uuid that belongs to old uid', () => {
|
||||
assert.equal(
|
||||
isAffiliateDashBindSnapshotStale(
|
||||
{
|
||||
bindUuid: 'bind-old',
|
||||
bindUrl: 'https://dash.example/bind-old',
|
||||
expectedGameAccount: '111',
|
||||
gameAccount: '111',
|
||||
},
|
||||
'222',
|
||||
),
|
||||
true,
|
||||
)
|
||||
})
|
||||
|
||||
test('isAffiliateDashBindSnapshotStale treats unknown bind uid as stale', () => {
|
||||
assert.equal(
|
||||
isAffiliateDashBindSnapshotStale(
|
||||
{
|
||||
bindUuid: 'bind-unknown',
|
||||
bindUrl: 'https://dash.example/bind-unknown',
|
||||
},
|
||||
'222',
|
||||
),
|
||||
true,
|
||||
)
|
||||
})
|
||||
|
||||
test('isAffiliateDashBindSnapshotStale keeps current uid bind snapshot', () => {
|
||||
assert.equal(
|
||||
isAffiliateDashBindSnapshotStale(
|
||||
{
|
||||
bindUuid: 'bind-current',
|
||||
bindUrl: 'https://dash.example/bind-current',
|
||||
expectedGameAccount: '222',
|
||||
gameAccount: '222',
|
||||
},
|
||||
'222',
|
||||
),
|
||||
false,
|
||||
)
|
||||
})
|
||||
|
||||
test('canReuseAffiliateDashBindSnapshot reuses pending current uid bind', () => {
|
||||
assert.equal(
|
||||
canReuseAffiliateDashBindSnapshot(
|
||||
{
|
||||
bindUuid: 'bind-current',
|
||||
bindUrl: 'https://dash.example/bind-current',
|
||||
expectedGameAccount: '222',
|
||||
gameAccount: '222',
|
||||
bound: false,
|
||||
bindMismatch: false,
|
||||
},
|
||||
'222',
|
||||
),
|
||||
true,
|
||||
)
|
||||
})
|
||||
|
||||
test('canReuseAffiliateDashBindSnapshot refuses old uid bind', () => {
|
||||
assert.equal(
|
||||
canReuseAffiliateDashBindSnapshot(
|
||||
{
|
||||
bindUuid: 'bind-old',
|
||||
bindUrl: 'https://dash.example/bind-old',
|
||||
expectedGameAccount: '111',
|
||||
gameAccount: '111',
|
||||
bound: false,
|
||||
bindMismatch: false,
|
||||
},
|
||||
'222',
|
||||
),
|
||||
false,
|
||||
)
|
||||
})
|
||||
|
||||
test('canReuseAffiliateDashBindSnapshot refuses bound snapshot without bound account', () => {
|
||||
assert.equal(
|
||||
canReuseAffiliateDashBindSnapshot(
|
||||
{
|
||||
bindUuid: 'bind-current',
|
||||
bindUrl: 'https://dash.example/bind-current',
|
||||
expectedGameAccount: '222',
|
||||
gameAccount: '222',
|
||||
bound: true,
|
||||
boundAccount: '',
|
||||
bindMismatch: false,
|
||||
},
|
||||
'222',
|
||||
),
|
||||
false,
|
||||
)
|
||||
})
|
||||
|
||||
test('canReuseAffiliateDashBindSnapshot reuses verified matching bound account', () => {
|
||||
assert.equal(
|
||||
canReuseAffiliateDashBindSnapshot(
|
||||
{
|
||||
bindUuid: 'bind-current',
|
||||
bindUrl: 'https://dash.example/bind-current',
|
||||
expectedGameAccount: '222',
|
||||
gameAccount: '222',
|
||||
bound: true,
|
||||
boundAccount: '222',
|
||||
bindMismatch: false,
|
||||
},
|
||||
'222',
|
||||
),
|
||||
true,
|
||||
)
|
||||
})
|
||||
|
||||
test('canReuseAffiliateDashBindSnapshot refuses mismatched bound account', () => {
|
||||
assert.equal(
|
||||
canReuseAffiliateDashBindSnapshot(
|
||||
{
|
||||
bindUuid: 'bind-current',
|
||||
bindUrl: 'https://dash.example/bind-current',
|
||||
expectedGameAccount: '222',
|
||||
gameAccount: '222',
|
||||
bound: true,
|
||||
boundAccount: '333',
|
||||
bindMismatch: false,
|
||||
},
|
||||
'222',
|
||||
),
|
||||
false,
|
||||
)
|
||||
})
|
||||
Reference in New Issue
Block a user