@jetthai/cuora 2.0.0-beta.0 → 2.0.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/.claude/commands/sync-ai-prompts.md +93 -0
- package/.claude/settings.local.json +23 -0
- package/.github/copilot-instructions.md +405 -0
- package/.husky/post-checkout +32 -0
- package/.husky/pre-commit +1 -3
- package/.husky/pre-push +36 -0
- package/AGENTS.md +405 -0
- package/AI_PROMPT_SOURCE.md +403 -0
- package/CHANGELOG.md +274 -3
- package/CLAUDE.md +405 -0
- package/GEMINI.md +405 -0
- package/README.md +299 -15
- package/docs/kibana/crypto-way-deposit-amount-bug-analysis.md +1003 -0
- package/docs/kibana/play-providerId-error.md +202 -0
- package/docs/kibana/play-selectedWalletType.md +1 -0
- package/docs/kibana/play-selectedWalletType_2.md +1 -0
- package/docs/kibana/play-selectedWalletType_analysis.md +565 -0
- package/package.json +3 -3
- package/scripts/auto-version.js +68 -0
- package/scripts/auto-version.sh +33 -0
- package/scripts/branch-auto-npm-publish.js +29 -0
- package/scripts/check-version.sh +36 -0
- package/scripts/clean-tags.sh +84 -0
- package/src/api/account.js +0 -1
- package/src/api/activity.js +22 -37
- package/src/api/auth.js +5 -36
- package/src/api/common.js +5 -3
- package/src/api/game.js +0 -10
- package/src/api/payment.js +17 -55
- package/src/api/user.js +10 -16
- package/src/index.js +2 -2
- package/src/machine/activity/activity_cash.js +84 -36
- package/src/machine/activity/cash_rain_activity.js +0 -1
- package/src/machine/activity/continue_deposit_activity.js +0 -1
- package/src/machine/activity/deposit_activity.js +0 -1
- package/src/machine/activity/diamond_shop_activity_cash.js +0 -8
- package/src/machine/activity/fafafa_activity.js +0 -11
- package/src/machine/activity/friend_invite_friends_activity.js +8 -7
- package/src/machine/activity/index.js +0 -12
- package/src/machine/activity/instant_rebate_activity.js +0 -1
- package/src/machine/activity/jackpot.js +0 -1
- package/src/machine/activity/otp_verified_activity.js +0 -1
- package/src/machine/activity/ranking_activity.js +0 -1
- package/src/machine/activity/roulette_activity_v2.js +0 -1
- package/src/machine/activity/sign_in_activity.js +0 -1
- package/src/machine/activity/sign_in_monthly_activity.js +1 -2
- package/src/machine/activity/specify_bets_activity.js +0 -1
- package/src/machine/activity/specify_turnover_activity.js +0 -1
- package/src/machine/activity/time_bomb_activity.js +0 -1
- package/src/machine/activity/vip_card_activity.js +0 -1
- package/src/machine/auth.js +112 -112
- package/src/machine/auth_otp_v3.js +11 -8
- package/src/machine/bank_binding.js +2 -3
- package/src/machine/common.js +14 -98
- package/src/machine/deposit/crypto_bank_cash.js +20 -35
- package/src/machine/deposit/crypto_qrcode_cash.js +26 -64
- package/src/machine/deposit/crypto_way_cash.js +48 -37
- package/src/machine/deposit/direct_cash.js +8 -10
- package/src/machine/deposit/index.js +0 -28
- package/src/machine/deposit/loadcard_cash.js +14 -32
- package/src/machine/deposit/manual_cash.js +8 -11
- package/src/machine/deposit/qrcode_cash.js +15 -32
- package/src/machine/deposit/usdt_cash.js +1 -15
- package/src/machine/deposit/virtual_bank_cash.js +13 -12
- package/src/machine/error.js +7 -1
- package/src/machine/game_betslip.js +0 -1
- package/src/machine/game_favorite_v2.js +0 -1
- package/src/machine/game_info.js +1 -13
- package/src/machine/game_search_cash.js +0 -1
- package/src/machine/game_v2_1.js +39 -126
- package/src/machine/honor_board_cash.js +8 -11
- package/src/machine/inbox.js +43 -105
- package/src/machine/index.js +0 -32
- package/src/machine/leaderboard.js +8 -12
- package/src/machine/navbar.js +1 -3
- package/src/machine/ranking.js +45 -30
- package/src/machine/reward_cash.js +0 -40
- package/src/machine/roulette_v2.js +14 -11
- package/src/machine/setting.js +0 -1
- package/src/machine/side_cash.js +3 -3
- package/src/machine/user_info.js +0 -1
- package/src/machine/user_photo.js +0 -1
- package/src/machine/user_reset_password.js +0 -14
- package/src/machine/user_sign_up.js +46 -61
- package/src/machine/websocket.js +18 -62
- package/src/machine/withdraw/index.js +0 -6
- package/src/machine/withdraw/withdraw_manual_cash.js +59 -39
- package/src/request/config.js +2 -0
- package/src/request/request.js +49 -60
- package/src/util/amount.js +8 -0
- package/src/util/constant.js +0 -1
- package/src/util/err998SentryExtra.js +26 -0
- package/src/util/index.js +2 -4
- package/src/util/paramStore.js +139 -0
- package/src/util/storage.js +3 -4
- package/BREAKING_CHANGES.md +0 -9
- package/resetGitBranch.sh +0 -101
- package/src/lib/fingerprint_v3_11_12.js +0 -11433
- package/src/machine/activity/activity.js +0 -213
- package/src/machine/activity/diamond_shop_activity_fc.js +0 -197
- package/src/machine/activity/diamond_shop_activity_vn.js +0 -179
- package/src/machine/activity/invite_friends_activity.js +0 -115
- package/src/machine/activity/mini_game_activity.js +0 -69
- package/src/machine/activity/return_bonus_activity.js +0 -155
- package/src/machine/auth_otp_v2.js +0 -178
- package/src/machine/bank_binding_amb.js +0 -146
- package/src/machine/bonus.js +0 -76
- package/src/machine/deposit/amb.js +0 -93
- package/src/machine/deposit/crypto_bank.js +0 -340
- package/src/machine/deposit/crypto_qrcode.js +0 -158
- package/src/machine/deposit/crypto_way.js +0 -253
- package/src/machine/deposit/deposit_fc.js +0 -272
- package/src/machine/deposit/direct.js +0 -311
- package/src/machine/deposit/float.js +0 -375
- package/src/machine/deposit/krway.js +0 -152
- package/src/machine/deposit/loadcard_vn.js +0 -352
- package/src/machine/deposit/manual_vn.js +0 -459
- package/src/machine/deposit/qrcode_v2.js +0 -339
- package/src/machine/deposit/usdt.js +0 -163
- package/src/machine/deposit/virtual_bank_vn.js +0 -270
- package/src/machine/deposit/vpay.js +0 -374
- package/src/machine/game_hot_new.js +0 -80
- package/src/machine/game_replay.js +0 -47
- package/src/machine/game_search_v2.js +0 -402
- package/src/machine/honor_board.js +0 -133
- package/src/machine/merge.js +0 -58
- package/src/machine/payment_data.js +0 -87
- package/src/machine/promotions.js +0 -163
- package/src/machine/reward.js +0 -256
- package/src/machine/reward_fc.js +0 -99
- package/src/machine/side.js +0 -160
- package/src/machine/side_v2.js +0 -223
- package/src/machine/vip_table.js +0 -58
- package/src/machine/welcome.js +0 -111
- package/src/machine/withdraw/withdraw_crypto_cash.js +0 -328
- package/src/machine/withdraw/withdraw_krway.js +0 -223
- package/src/machine/withdraw/withdraw_manual.js +0 -541
- package/src/util/deviceToken.js +0 -60
- package/src/util/math.js +0 -4
- package/test/api.behavior.test.js +0 -69
- package/test/api.contract.test.js +0 -18
- package/test/config.test.js +0 -27
- package/test/deviceToken.test.js +0 -139
- package/test/helpers.coverage.test.js +0 -11
- package/test/helpers.js +0 -91
- package/test/index.exports.test.js +0 -14
- package/test/machine.activity.core.coverage.test.js +0 -337
- package/test/machine.activity.gap.coverage.test.js +0 -252
- package/test/machine.activity.more.coverage.test.js +0 -180
- package/test/machine.activity_plus_and_binding_amb.coverage.test.js +0 -201
- package/test/machine.activity_timer_bonus.coverage.test.js +0 -136
- package/test/machine.activity_welcome.low.coverage.test.js +0 -211
- package/test/machine.amb_rewardfc_websocket.more.coverage.test.js +0 -201
- package/test/machine.auth.coverage.test.js +0 -215
- package/test/machine.bank_binding.test.js +0 -143
- package/test/machine.binding_otp_krway.coverage.test.js +0 -223
- package/test/machine.contract.test.js +0 -50
- package/test/machine.crypto_bank.coverage.test.js +0 -270
- package/test/machine.crypto_way.coverage.test.js +0 -108
- package/test/machine.crypto_way_cash.coverage.test.js +0 -114
- package/test/machine.definition.test.js +0 -137
- package/test/machine.deposit.manual.coverage.test.js +0 -365
- package/test/machine.deposit_fc.coverage.test.js +0 -126
- package/test/machine.direct.coverage.test.js +0 -96
- package/test/machine.direct_cash.coverage.test.js +0 -108
- package/test/machine.error.coverage.test.js +0 -37
- package/test/machine.events.test.js +0 -126
- package/test/machine.favorite_jackpot.coverage.test.js +0 -82
- package/test/machine.float.coverage.test.js +0 -136
- package/test/machine.flow.test.js +0 -226
- package/test/machine.game_hot_new_vip_table.coverage.test.js +0 -105
- package/test/machine.game_search_cash.coverage.test.js +0 -155
- package/test/machine.game_search_v2.test.js +0 -199
- package/test/machine.game_user_profile.coverage.test.js +0 -100
- package/test/machine.honor_board.test.js +0 -133
- package/test/machine.inbox.common.coverage.test.js +0 -304
- package/test/machine.loadcard_cash.coverage.test.js +0 -101
- package/test/machine.loadcard_vn.coverage.test.js +0 -122
- package/test/machine.misc.coverage.test.js +0 -361
- package/test/machine.more2.coverage.test.js +0 -261
- package/test/machine.options.execution.test.js +0 -272
- package/test/machine.priority.coverage.test.js +0 -603
- package/test/machine.qrcode_cash.coverage.test.js +0 -107
- package/test/machine.qrcode_v2.coverage.test.js +0 -121
- package/test/machine.regression.test.js +0 -82
- package/test/machine.roulette_v2.test.js +0 -142
- package/test/machine.side_reward_reset.coverage.test.js +0 -220
- package/test/machine.targeted.coverage.test.js +0 -313
- package/test/machine.usdt.coverage.test.js +0 -95
- package/test/machine.usdt_cash.coverage.test.js +0 -73
- package/test/machine.vip_card_activity.test.js +0 -114
- package/test/machine.virtual_bank_cash.coverage.test.js +0 -105
- package/test/machine.virtual_bank_vn.coverage.test.js +0 -105
- package/test/machine.vpay.coverage.test.js +0 -142
- package/test/machine.withdraw_crypto_cash.coverage.test.js +0 -166
- package/test/machine.withdraw_krway.coverage.test.js +0 -123
- package/test/machine.withdraw_manual.coverage.test.js +0 -185
- package/test/machine.withdraw_manual_cash.coverage.test.js +0 -123
- package/test/request.test.js +0 -325
- package/test/util.storage.errors.test.js +0 -47
- package/test/util.test.js +0 -41
|
@@ -1,122 +0,0 @@
|
|
|
1
|
-
import test from 'node:test'
|
|
2
|
-
import assert from 'node:assert/strict'
|
|
3
|
-
|
|
4
|
-
import loadcardVnFactory from '../src/machine/deposit/loadcard_vn.js'
|
|
5
|
-
|
|
6
|
-
test('loadcard_vn actions/guards/services cover card flow and payload mapping', async () => {
|
|
7
|
-
global.window = {
|
|
8
|
-
atob: (value) => Buffer.from(value, 'base64').toString('utf8'),
|
|
9
|
-
}
|
|
10
|
-
|
|
11
|
-
const sent = []
|
|
12
|
-
const request = {
|
|
13
|
-
config: { appSecret: 'secret' },
|
|
14
|
-
send: async (req) => {
|
|
15
|
-
sent.push(req)
|
|
16
|
-
if (req.url === 'getConfig') {
|
|
17
|
-
return { config: Buffer.from(JSON.stringify({ bonusPreviewEnable: true })).toString('base64') }
|
|
18
|
-
}
|
|
19
|
-
if (req.url === 'payment/v2/paymentDetail') {
|
|
20
|
-
return [
|
|
21
|
-
{
|
|
22
|
-
category: 'loadcard',
|
|
23
|
-
method: 'loadcard_vn',
|
|
24
|
-
channel_id: 'CARD1',
|
|
25
|
-
optional: [100, 200],
|
|
26
|
-
jumpLinkEnable: 1,
|
|
27
|
-
},
|
|
28
|
-
{
|
|
29
|
-
category: 'loadcard',
|
|
30
|
-
method: 'loadcard_vn_2',
|
|
31
|
-
channel_id: 'CARD2',
|
|
32
|
-
optional: [300],
|
|
33
|
-
jumpLinkEnable: 0,
|
|
34
|
-
},
|
|
35
|
-
]
|
|
36
|
-
}
|
|
37
|
-
if (req.url === 'payment/v2/loadcard_vn/bonus/preview') return [{ tier: 1 }]
|
|
38
|
-
if (req.url === 'payment/v2/loadcard_vn/expected/result') return { data: { bonus: 8 } }
|
|
39
|
-
if (req.url === 'payment/v2/loadcard_vn/transaction') return { applyId: 909 }
|
|
40
|
-
return {}
|
|
41
|
-
},
|
|
42
|
-
}
|
|
43
|
-
|
|
44
|
-
const machine = loadcardVnFactory(request)
|
|
45
|
-
const { actions, guards, services } = machine.options
|
|
46
|
-
const checkingCond = machine.config.states.checking.always[0].cond
|
|
47
|
-
const loadedSelectCardCond = machine.config.states.loaded.on.SELECT_CARD[0].cond
|
|
48
|
-
const cardInfoSelectCardCond = machine.config.states.cardInfo.on.SELECT_CARD[0].cond
|
|
49
|
-
|
|
50
|
-
const reset = actions.reset.assignment({ any: 1 }, {})
|
|
51
|
-
assert.equal(reset.selectedAmount, null)
|
|
52
|
-
assert.equal(reset.result, null)
|
|
53
|
-
|
|
54
|
-
const init = actions.setInitData.assignment(machine.initialState.context, {
|
|
55
|
-
data: {
|
|
56
|
-
siteConfig: { bonusPreviewEnable: true },
|
|
57
|
-
paymentDetail: [
|
|
58
|
-
{ category: 'loadcard', method: 'loadcard_vn', channel_id: 'CARD1', optional: [100, 200], jumpLinkEnable: 1 },
|
|
59
|
-
{ category: 'loadcard', method: 'loadcard_vn_2', channel_id: 'CARD2', optional: [300], jumpLinkEnable: 0 },
|
|
60
|
-
],
|
|
61
|
-
},
|
|
62
|
-
})
|
|
63
|
-
assert.equal(init.cards.length, 2)
|
|
64
|
-
assert.equal(init.currentMethod, 'loadcard_vn')
|
|
65
|
-
assert.equal(init.options[0], 100)
|
|
66
|
-
|
|
67
|
-
assert.equal(actions.setBonusPreview.assignment(machine.initialState.context, { data: [{ tier: 1 }] }).bonusPreviewData[0].tier, 1)
|
|
68
|
-
|
|
69
|
-
const setCard = actions.setCard.assignment(machine.initialState.context, {
|
|
70
|
-
data: { method: 'loadcard_vn_2', optional: [300], channel_id: 'CARD2', jumpLinkEnable: 0 },
|
|
71
|
-
})
|
|
72
|
-
assert.equal(setCard.currentMethod, 'loadcard_vn_2')
|
|
73
|
-
assert.equal(setCard.options[0], 300)
|
|
74
|
-
|
|
75
|
-
assert.equal(actions.setCardNumber.assignment(machine.initialState.context, { data: 'C123' }).cardNumber, 'C123')
|
|
76
|
-
assert.equal(actions.setSerialNumber.assignment(machine.initialState.context, { data: 'S123' }).serialNumber, 'S123')
|
|
77
|
-
assert.equal(actions.setAmount.assignment(machine.initialState.context, { data: 500 }).selectedAmount, 500)
|
|
78
|
-
|
|
79
|
-
assert.deepEqual(actions.setCalculation.assignment(machine.initialState.context, { data: { data: { x: 1 } } }).calculation, { x: 1 })
|
|
80
|
-
assert.deepEqual(actions.setCalculation.assignment(machine.initialState.context, { data: { y: 2 } }).calculation, { y: 2 })
|
|
81
|
-
assert.equal(actions.clearCalculation.assignment(machine.initialState.context, {}).calculation, null)
|
|
82
|
-
|
|
83
|
-
assert.equal(actions.setResult.assignment(machine.initialState.context, { data: { applyId: 2 } }).result.applyId, 2)
|
|
84
|
-
assert.equal(actions.setPromotion.assignment(machine.initialState.context, { data: { activityNo: 'A1' } }).promotion.activityNo, 'A1')
|
|
85
|
-
assert.equal(checkingCond({ siteConfig: { bonusPreviewEnable: true }, promotion: { activityNo: 'A1' }, selectedCard: { id: 1 } }, {}), true)
|
|
86
|
-
assert.equal(loadedSelectCardCond({ siteConfig: { bonusPreviewEnable: true }, promotion: { activityNo: 'A1' } }, {}), true)
|
|
87
|
-
assert.equal(cardInfoSelectCardCond({ siteConfig: { bonusPreviewEnable: true }, promotion: { activityNo: 'A1' } }, {}), true)
|
|
88
|
-
|
|
89
|
-
assert.equal(guards.isSubmittable({ cardNumber: 'C', serialNumber: 'S' }), 'S')
|
|
90
|
-
assert.equal(guards.isSubmittable({ cardNumber: 'C', serialNumber: null }), null)
|
|
91
|
-
assert.equal(guards.jumpLinkEnable({ selectedCard: { jumpLinkEnable: 1 } }), true)
|
|
92
|
-
assert.equal(guards.jumpLinkEnable({ selectedCard: { jumpLinkEnable: 0 } }), false)
|
|
93
|
-
|
|
94
|
-
const initData = await services.fetchInitData({}, {})
|
|
95
|
-
assert.equal(initData.siteConfig.bonusPreviewEnable, true)
|
|
96
|
-
assert.equal(initData.paymentDetail.length, 2)
|
|
97
|
-
|
|
98
|
-
const preview = await services.fetchBonusPreview({ currentMethod: 'loadcard_vn', promotion: { activityNo: 'ACT1' } }, {})
|
|
99
|
-
assert.equal(preview[0].tier, 1)
|
|
100
|
-
|
|
101
|
-
const calc = await services.fetchCalculation({ currentMethod: 'loadcard_vn', selectedAmount: '600', promotion: { activityNo: 'ACT2' } }, {})
|
|
102
|
-
assert.equal(calc.data.bonus, 8)
|
|
103
|
-
|
|
104
|
-
const submitted = await services.submitDeposit(
|
|
105
|
-
{
|
|
106
|
-
currentMethod: 'loadcard_vn',
|
|
107
|
-
selectedCard: { channel_id: 'CARD1' },
|
|
108
|
-
selectedAmount: 700,
|
|
109
|
-
cardNumber: 'CARDCODE',
|
|
110
|
-
serialNumber: 'SERIAL',
|
|
111
|
-
promotion: { activityNo: 'ACT3' },
|
|
112
|
-
},
|
|
113
|
-
{}
|
|
114
|
-
)
|
|
115
|
-
assert.equal(submitted.applyId, 909)
|
|
116
|
-
|
|
117
|
-
const submitReq = sent.find((entry) => entry.url === 'payment/v2/loadcard_vn/transaction')
|
|
118
|
-
assert.equal(submitReq.params.card_type, 'CARD1')
|
|
119
|
-
assert.equal(submitReq.params.card_code, 'CARDCODE')
|
|
120
|
-
assert.equal(submitReq.params.card_seri, 'SERIAL')
|
|
121
|
-
assert.equal(submitReq.params.promotionsNo, 'ACT3')
|
|
122
|
-
})
|
|
@@ -1,361 +0,0 @@
|
|
|
1
|
-
import test from 'node:test'
|
|
2
|
-
import assert from 'node:assert/strict'
|
|
3
|
-
|
|
4
|
-
import navbarFactory from '../src/machine/navbar.js'
|
|
5
|
-
import paymentDataFactory from '../src/machine/payment_data.js'
|
|
6
|
-
import rankingFactory from '../src/machine/ranking.js'
|
|
7
|
-
import leaderboardFactory from '../src/machine/leaderboard.js'
|
|
8
|
-
import promotionsFactory from '../src/machine/promotions.js'
|
|
9
|
-
|
|
10
|
-
test('navbar actions/guards/services cover game merge and config decode', async () => {
|
|
11
|
-
global.window = {
|
|
12
|
-
atob: (v) => Buffer.from(v, 'base64').toString('binary'),
|
|
13
|
-
}
|
|
14
|
-
|
|
15
|
-
const calls = []
|
|
16
|
-
const request = {
|
|
17
|
-
config: { appSecret: 'secret' },
|
|
18
|
-
send: async (req) => {
|
|
19
|
-
calls.push(req)
|
|
20
|
-
if (req.url === 'getNavbarSetting') {
|
|
21
|
-
const payload = {
|
|
22
|
-
settings: [
|
|
23
|
-
{ type: 'GAME', gameCode: 'G1' },
|
|
24
|
-
{ type: 'LINK', path: '/a' },
|
|
25
|
-
],
|
|
26
|
-
}
|
|
27
|
-
const b64 = Buffer.from(JSON.stringify(payload), 'utf8').toString('base64').replace(/\+/g, '-').replace(/\//g, '_').replace(/=+$/g, '')
|
|
28
|
-
return { config: `${b64}.x.y` }
|
|
29
|
-
}
|
|
30
|
-
if (req.url === 'game/list/v3/gameInfo') {
|
|
31
|
-
return { data: [{ gameCode: 'G1', gameName: 'Game One' }] }
|
|
32
|
-
}
|
|
33
|
-
return {}
|
|
34
|
-
},
|
|
35
|
-
}
|
|
36
|
-
const machine = navbarFactory(request)
|
|
37
|
-
const actions = machine.options.actions
|
|
38
|
-
const guards = machine.options.guards
|
|
39
|
-
const services = machine.options.services
|
|
40
|
-
|
|
41
|
-
const navbarPatch = actions.setNavbar.assignment(machine.initialState.context, {
|
|
42
|
-
data: { navbarConfig: { settings: [{ type: 'GAME', gameCode: 'G1' }, { type: 'LINK' }] } },
|
|
43
|
-
})
|
|
44
|
-
assert.equal(navbarPatch.navbar.length, 2)
|
|
45
|
-
|
|
46
|
-
const gameCodePatch = actions.filterGameCodes.assignment(
|
|
47
|
-
{ ...machine.initialState.context, navbar: [{ type: 'GAME', gameCode: 'G1' }, { type: 'LINK' }, { type: 'game' }] },
|
|
48
|
-
{}
|
|
49
|
-
)
|
|
50
|
-
assert.deepEqual(gameCodePatch.gameCodes, ['G1'])
|
|
51
|
-
|
|
52
|
-
const combined = actions.combindGames.assignment(
|
|
53
|
-
{
|
|
54
|
-
...machine.initialState.context,
|
|
55
|
-
navbar: [
|
|
56
|
-
{ type: 'game', gameCode: 'G1' },
|
|
57
|
-
{ type: 'link', path: '/a' },
|
|
58
|
-
],
|
|
59
|
-
},
|
|
60
|
-
{ data: { data: [{ gameCode: 'G1', gameName: 'Game One' }] } }
|
|
61
|
-
)
|
|
62
|
-
assert.equal(combined.navbar[0].gameName, 'Game One')
|
|
63
|
-
assert.equal(combined.navbar[1].path, '/a')
|
|
64
|
-
|
|
65
|
-
assert.equal(guards.haveGames({}, { data: { navbarConfig: { settings: [{ type: 'game' }] } } }), true)
|
|
66
|
-
assert.equal(guards.haveGames({}, { data: { navbarConfig: { settings: [] } } }), false)
|
|
67
|
-
|
|
68
|
-
const decoded = await services.fetchNavbar({}, {})
|
|
69
|
-
assert.equal(decoded.navbarConfig.settings[0].gameCode, 'G1')
|
|
70
|
-
const gameInfo = await services.getGameInfo({ gameCodes: ['G1'] }, {})
|
|
71
|
-
assert.equal(gameInfo.data[0].gameName, 'Game One')
|
|
72
|
-
assert.equal(calls.length >= 2, true)
|
|
73
|
-
})
|
|
74
|
-
|
|
75
|
-
test('payment_data actions/services map status and spot market list', async () => {
|
|
76
|
-
const calls = []
|
|
77
|
-
const request = {
|
|
78
|
-
send: async (req) => {
|
|
79
|
-
calls.push(req)
|
|
80
|
-
if (req.url === 'payment/v2/history')
|
|
81
|
-
return [
|
|
82
|
-
{ id: 1, status: 2 },
|
|
83
|
-
{ id: 2, status: 3 },
|
|
84
|
-
{ id: 3, status: 99 },
|
|
85
|
-
]
|
|
86
|
-
if (req.url === 'payment/v2/spotmarket') return { timestamp: 10, data: Array.from({ length: 120 }, (_, i) => ({ i })) }
|
|
87
|
-
return {}
|
|
88
|
-
},
|
|
89
|
-
}
|
|
90
|
-
const machine = paymentDataFactory(request)
|
|
91
|
-
const actions = machine.options.actions
|
|
92
|
-
const services = machine.options.services
|
|
93
|
-
|
|
94
|
-
const mapped = actions.setTransactionList.assignment(machine.initialState.context, {
|
|
95
|
-
data: [{ status: 2 }, { status: 3 }, { status: 4 }, { status: 8 }, { status: 1 }],
|
|
96
|
-
})
|
|
97
|
-
assert.deepEqual(
|
|
98
|
-
mapped.transactionList.map((x) => x.statusName),
|
|
99
|
-
['pending', 'success', 'reject', 'expired', undefined]
|
|
100
|
-
)
|
|
101
|
-
|
|
102
|
-
const spot = actions.setSpotMarket.assignment(machine.initialState.context, {
|
|
103
|
-
data: { timestamp: 99, data: Array.from({ length: 120 }, (_, i) => i) },
|
|
104
|
-
})
|
|
105
|
-
assert.equal(spot.spotMarketTime, 99)
|
|
106
|
-
assert.equal(spot.spotMarketList.length, 100)
|
|
107
|
-
|
|
108
|
-
const list = await services.fetchTransactionList({}, { data: 7 })
|
|
109
|
-
assert.equal(list.length, 3)
|
|
110
|
-
const market = await services.fetchSpotMarket({}, {})
|
|
111
|
-
assert.equal(market.data.length, 120)
|
|
112
|
-
assert.equal(calls.length, 2)
|
|
113
|
-
})
|
|
114
|
-
|
|
115
|
-
test('ranking actions/guards/services cover champion options and detail flows', async () => {
|
|
116
|
-
const calls = []
|
|
117
|
-
const request = {
|
|
118
|
-
config: { appSecret: 'secret' },
|
|
119
|
-
getToken: () => 'token',
|
|
120
|
-
send: async (req) => {
|
|
121
|
-
calls.push(req)
|
|
122
|
-
if (req.url === 'ranking/detail/option') {
|
|
123
|
-
return { data: { rule: 'CHAMPION', cycle: 'MONTHLY', currentRound: [30, 8, 2] } }
|
|
124
|
-
}
|
|
125
|
-
if (req.url === 'hot-game/ranking') return { data: [{ provider: 'PG', gameCode: 'G1' }] }
|
|
126
|
-
if (req.url === 'ranking/detail') {
|
|
127
|
-
return {
|
|
128
|
-
data: { topRanking: [{ provider: 'PG', settleStatus: true }], playerRanking: { provider: 'EV' }, description: 'd', descriptionUrl: ['u'] },
|
|
129
|
-
}
|
|
130
|
-
}
|
|
131
|
-
if (req.url === 'tournament/detail') return { data: { topRanking: [], playerRanking: {} } }
|
|
132
|
-
return {}
|
|
133
|
-
},
|
|
134
|
-
}
|
|
135
|
-
const machine = rankingFactory(request)
|
|
136
|
-
const actions = machine.options.actions
|
|
137
|
-
const guards = machine.options.guards
|
|
138
|
-
const services = machine.options.services
|
|
139
|
-
|
|
140
|
-
const setActivity = actions.setActivity.assignment(machine.initialState.context, {
|
|
141
|
-
data: { site: 's1', activityNo: 'A1' },
|
|
142
|
-
})
|
|
143
|
-
assert.equal(setActivity.auth, true)
|
|
144
|
-
|
|
145
|
-
const setRanking = actions.setRanking.assignment(machine.initialState.context, {
|
|
146
|
-
data: { topRanking: [{ provider: 'PG', settleStatus: true }], playerRanking: { provider: 'EV' }, description: 'desc' },
|
|
147
|
-
})
|
|
148
|
-
assert.equal(setRanking.topRanking[0].providerId, 'PG')
|
|
149
|
-
assert.equal(setRanking.playerRanking.providerId, 'EV')
|
|
150
|
-
assert.equal(setRanking.settleStatus, true)
|
|
151
|
-
|
|
152
|
-
const setRankingGames = actions.setRankingGames.assignment(machine.initialState.context, {
|
|
153
|
-
data: [{ provider: 'PG', gameCode: 'G1' }],
|
|
154
|
-
})
|
|
155
|
-
assert.equal(setRankingGames.gameRanking[0].providerId, 'PG')
|
|
156
|
-
|
|
157
|
-
const options = actions.setRankingOptions.assignment(machine.initialState.context, {
|
|
158
|
-
data: { rule: 'CHAMPION', cycle: 'MONTHLY', currentRound: [30, 8, 2] },
|
|
159
|
-
})
|
|
160
|
-
assert.deepEqual(options.options.cycle, ['DAILY', 'WEEKLY', 'MONTHLY', 'ALL'])
|
|
161
|
-
assert.equal(options.cycle, 'DAILY')
|
|
162
|
-
assert.equal(options.round, 30)
|
|
163
|
-
assert.equal(options.options.round.DAILY.length, 30)
|
|
164
|
-
assert.equal(options.options.round.ALL.length, 2)
|
|
165
|
-
const nonChampionOptions = actions.setRankingOptions.assignment(machine.initialState.context, {
|
|
166
|
-
data: { rule: 'NORMAL', cycle: 'WEEKLY', currentRound: [10] },
|
|
167
|
-
})
|
|
168
|
-
assert.deepEqual(nonChampionOptions.options.cycle, ['WEEKLY'])
|
|
169
|
-
assert.equal(nonChampionOptions.cycle, 'WEEKLY')
|
|
170
|
-
const rankingNoData = actions.setRanking.assignment(machine.initialState.context, { data: null })
|
|
171
|
-
assert.deepEqual(rankingNoData.topRanking, [])
|
|
172
|
-
assert.deepEqual(rankingNoData.playerRanking, {})
|
|
173
|
-
assert.deepEqual(actions.setRankingGames.assignment(machine.initialState.context, { data: null }).gameRanking, [])
|
|
174
|
-
|
|
175
|
-
const setCycle = actions.setOptions.assignment(
|
|
176
|
-
{ ...machine.initialState.context, currentRound: [30, 8, 2], cycle: 'DAILY', round: 30 },
|
|
177
|
-
{ data: { cycle: 'WEEKLY' } }
|
|
178
|
-
)
|
|
179
|
-
assert.equal(setCycle.cycle, 'WEEKLY')
|
|
180
|
-
assert.equal(setCycle.round, 8)
|
|
181
|
-
|
|
182
|
-
const setRound = actions.setOptions.assignment({ ...machine.initialState.context, cycle: 'WEEKLY', round: 8 }, { data: { round: 7 } })
|
|
183
|
-
assert.equal(setRound.round, 7)
|
|
184
|
-
const setAllCycle = actions.setOptions.assignment(
|
|
185
|
-
{ ...machine.initialState.context, currentRound: [30, 8, 2], cycle: 'DAILY', round: 30 },
|
|
186
|
-
{ data: { cycle: 'ALL' } }
|
|
187
|
-
)
|
|
188
|
-
assert.equal(setAllCycle.round, 2)
|
|
189
|
-
assert.deepEqual(actions.setOptions.assignment({ ...machine.initialState.context, cycle: 'WEEKLY', round: 7 }, { data: { round: 7 } }), {})
|
|
190
|
-
|
|
191
|
-
assert.equal(guards.hasAuth({ auth: true }), true)
|
|
192
|
-
assert.equal(guards.canGetGameRanking({ auth: true, rule: 'CHAMPION' }), true)
|
|
193
|
-
assert.equal(guards.canGetGameRanking({ auth: true, rule: 'OTHER' }), false)
|
|
194
|
-
|
|
195
|
-
const optRes = await services.fetchRankingOptions({ activityNo: 'A1' })
|
|
196
|
-
const gamesRes = await services.fetchRankingGames({ activityNo: 'A1' })
|
|
197
|
-
const detailRes = await services.fetchRankingDetail({ activityNo: 'A1', cycle: 'DAILY', round: 1 })
|
|
198
|
-
const tourRes = await services.fetchTournament({ activityNo: 'A1', cycle: 'DAILY', round: 1, site: 's1' })
|
|
199
|
-
assert.equal(optRes.rule, 'CHAMPION')
|
|
200
|
-
assert.equal(gamesRes[0].provider, 'PG')
|
|
201
|
-
assert.equal(detailRes.description, 'd')
|
|
202
|
-
assert.deepEqual(tourRes.topRanking, [])
|
|
203
|
-
assert.equal(calls.length >= 4, true)
|
|
204
|
-
})
|
|
205
|
-
|
|
206
|
-
test('leaderboard actions/guards/services cover map cache and auth branches', async () => {
|
|
207
|
-
const calls = []
|
|
208
|
-
let hasToken = false
|
|
209
|
-
const request = {
|
|
210
|
-
config: { appSecret: 'secret' },
|
|
211
|
-
getToken: () => (hasToken ? 'token' : null),
|
|
212
|
-
send: async (req) => {
|
|
213
|
-
calls.push(req)
|
|
214
|
-
if (req.url === 'all-activities/list' || req.url === 'activities/list') {
|
|
215
|
-
return { data: [{ activityType: 2 }, { activityType: 200 }, { activityType: 1 }] }
|
|
216
|
-
}
|
|
217
|
-
if (req.url === 'tournament/detail') {
|
|
218
|
-
return { data: { topRanking: [{ rank: 1 }], awards: ['A'] } }
|
|
219
|
-
}
|
|
220
|
-
if (req.url === 'activities') {
|
|
221
|
-
return { data: { rankingList: [{ rank: 2 }], awards: ['B'] } }
|
|
222
|
-
}
|
|
223
|
-
return { data: {} }
|
|
224
|
-
},
|
|
225
|
-
}
|
|
226
|
-
const machine = leaderboardFactory(request)
|
|
227
|
-
const actions = machine.options.actions
|
|
228
|
-
const guards = machine.options.guards
|
|
229
|
-
const services = machine.options.services
|
|
230
|
-
|
|
231
|
-
const rankActivities = actions.setRankActivities.assignment(machine.initialState.context, {
|
|
232
|
-
data: [{ activityType: 2 }, { activityType: 200 }, { activityType: 99 }],
|
|
233
|
-
})
|
|
234
|
-
assert.equal(rankActivities.rankActivities.length, 2)
|
|
235
|
-
|
|
236
|
-
assert.equal(actions.setActivityNo.assignment(machine.initialState.context, { data: 'A1' }).activityNo, 'A1')
|
|
237
|
-
|
|
238
|
-
const withRankingList = actions.setActivityMap.assignment(
|
|
239
|
-
{ ...machine.initialState.context, activityNo: 'A1', activityMap: {} },
|
|
240
|
-
{ data: { rankingList: [{ id: 1 }], awards: ['A'] } }
|
|
241
|
-
)
|
|
242
|
-
assert.equal(withRankingList.activityMap.A1.topRanking.length, 1)
|
|
243
|
-
|
|
244
|
-
const withoutRankingList = actions.setActivityMap.assignment(
|
|
245
|
-
{ ...machine.initialState.context, activityNo: 'A2', activityMap: {} },
|
|
246
|
-
{ data: { any: 1, awards: ['B'] } }
|
|
247
|
-
)
|
|
248
|
-
assert.equal(withoutRankingList.activityMap.A2.any, 1)
|
|
249
|
-
|
|
250
|
-
const detail = actions.setActivityDetail.assignment(
|
|
251
|
-
{ ...machine.initialState.context, activityNo: 'A1', activityMap: { A1: { topRanking: [] } } },
|
|
252
|
-
{}
|
|
253
|
-
)
|
|
254
|
-
assert.deepEqual(detail.activityDetail, { topRanking: [] })
|
|
255
|
-
|
|
256
|
-
assert.equal(Boolean(guards.isExist({ activityMap: { A1: {} }, activityNo: 'A1' })), true)
|
|
257
|
-
assert.equal(guards.hasActivityNo({ activityNo: 'A1' }), true)
|
|
258
|
-
|
|
259
|
-
const originalSetTimeout = global.setTimeout
|
|
260
|
-
global.setTimeout = (fn) => {
|
|
261
|
-
fn()
|
|
262
|
-
return 0
|
|
263
|
-
}
|
|
264
|
-
|
|
265
|
-
hasToken = false
|
|
266
|
-
const listPublic = await services.fetchActivityList({}, {})
|
|
267
|
-
hasToken = true
|
|
268
|
-
const listAuthed = await services.fetchActivityList({}, {})
|
|
269
|
-
hasToken = false
|
|
270
|
-
const detailPublic = await services.fetchPublicActivityDetail({ activityNo: 'A1' }, {})
|
|
271
|
-
hasToken = true
|
|
272
|
-
const detailAuthed = await services.fetchPublicActivityDetail({ activityNo: 'A1' }, {})
|
|
273
|
-
global.setTimeout = originalSetTimeout
|
|
274
|
-
|
|
275
|
-
assert.equal(listPublic.length, 3)
|
|
276
|
-
assert.equal(listAuthed.length, 3)
|
|
277
|
-
assert.deepEqual(detailPublic.topRanking, [{ rank: 1 }])
|
|
278
|
-
assert.deepEqual(detailAuthed.rankingList, [{ rank: 2 }])
|
|
279
|
-
assert.equal(calls.length >= 4, true)
|
|
280
|
-
})
|
|
281
|
-
|
|
282
|
-
test('promotions actions/guards/services cover attendEnable and callback flow', async () => {
|
|
283
|
-
const calls = []
|
|
284
|
-
const request = {
|
|
285
|
-
send: async (req) => {
|
|
286
|
-
calls.push(req)
|
|
287
|
-
if (req.url === 'payment/v2/bankWallet/promotions') {
|
|
288
|
-
return [
|
|
289
|
-
{ promotionsNo: 'P1', withdrawRule: 'FREE_LIMIT', minimumAmount: 100 },
|
|
290
|
-
{ promotionsNo: 'P2', withdrawRule: 'DEFAULT', minimumAmount: 200 },
|
|
291
|
-
]
|
|
292
|
-
}
|
|
293
|
-
if (req.url === 'payment/v2/bankWallet/promotion/preview') return { preview: true }
|
|
294
|
-
if (req.url === 'payment/v2/bankWallet/promotion/apply') return { ok: true }
|
|
295
|
-
return {}
|
|
296
|
-
},
|
|
297
|
-
}
|
|
298
|
-
const machine = promotionsFactory(request)
|
|
299
|
-
const actions = machine.options.actions
|
|
300
|
-
const guards = machine.options.guards
|
|
301
|
-
const services = machine.options.services
|
|
302
|
-
|
|
303
|
-
const defaultRule = actions.setPromotionsList.assignment(
|
|
304
|
-
{
|
|
305
|
-
...machine.initialState.context,
|
|
306
|
-
userInfo: { withdraw_rule: 'DEFAULT', bank_amount: '1000' },
|
|
307
|
-
siteConfig: { currencyConversionLimit: 500 },
|
|
308
|
-
},
|
|
309
|
-
{ data: [{ withdrawRule: 'FREE_LIMIT' }, { withdrawRule: 'DEFAULT' }] }
|
|
310
|
-
)
|
|
311
|
-
assert.equal(defaultRule.promotionsList[0].attendEnable, false)
|
|
312
|
-
assert.equal(defaultRule.promotionsList[1].attendEnable, true)
|
|
313
|
-
|
|
314
|
-
const freeLimitRule = actions.setPromotionsList.assignment(
|
|
315
|
-
{
|
|
316
|
-
...machine.initialState.context,
|
|
317
|
-
userInfo: { withdraw_rule: 'FREE_LIMIT', bank_amount: '1000' },
|
|
318
|
-
siteConfig: { currencyConversionLimit: 500 },
|
|
319
|
-
},
|
|
320
|
-
{ data: [{ withdrawRule: 'FREE_LIMIT' }, { withdrawRule: 'DEFAULT' }] }
|
|
321
|
-
)
|
|
322
|
-
assert.equal(
|
|
323
|
-
freeLimitRule.promotionsList.every((x) => x.attendEnable === false),
|
|
324
|
-
true
|
|
325
|
-
)
|
|
326
|
-
|
|
327
|
-
const freeCase = actions.setPromotionsList.assignment(
|
|
328
|
-
{
|
|
329
|
-
...machine.initialState.context,
|
|
330
|
-
userInfo: { withdraw_rule: 'DEFAULT', bank_amount: '100' },
|
|
331
|
-
siteConfig: { currencyConversionLimit: 500 },
|
|
332
|
-
},
|
|
333
|
-
{ data: [{ withdrawRule: 'FREE_LIMIT' }, { withdrawRule: 'DEFAULT' }] }
|
|
334
|
-
)
|
|
335
|
-
assert.equal(
|
|
336
|
-
freeCase.promotionsList.every((x) => x.attendEnable === true),
|
|
337
|
-
true
|
|
338
|
-
)
|
|
339
|
-
|
|
340
|
-
assert.equal(actions.setSelectedPromo.assignment(machine.initialState.context, { data: { promotionsNo: 'P1' } }).selectedPromo.promotionsNo, 'P1')
|
|
341
|
-
assert.equal(actions.setAmount.assignment(machine.initialState.context, { data: 123 }).amount, 123)
|
|
342
|
-
assert.deepEqual(actions.setWithdrawRulePreview.assignment(machine.initialState.context, { data: { x: 1 } }).withdrawRule, { x: 1 })
|
|
343
|
-
|
|
344
|
-
let called = 0
|
|
345
|
-
const callbackPatch = actions.setCallback.assignment(machine.initialState.context, { data: { callback: () => called++ } })
|
|
346
|
-
assert.equal(typeof callbackPatch.callback, 'function')
|
|
347
|
-
actions.doCallback({ callback: callbackPatch.callback }, {})
|
|
348
|
-
assert.equal(called, 1)
|
|
349
|
-
assert.equal(actions.reset.assignment(machine.initialState.context, {}).amount, null)
|
|
350
|
-
|
|
351
|
-
assert.equal(guards.isValidAmount({ selectedPromo: { minimumAmount: 100 }, amount: 100 }), true)
|
|
352
|
-
assert.equal(guards.isValidAmount({ selectedPromo: { minimumAmount: 100 }, amount: 99 }), false)
|
|
353
|
-
|
|
354
|
-
const promoList = await services.fetchPromotionsList({}, {})
|
|
355
|
-
const preview = await services.fetchWithdrawRulePreview({ selectedPromo: { promotionsNo: 'P1' }, amount: '123.45' }, {})
|
|
356
|
-
const apply = await services.applyPromotion({ selectedPromo: { promotionsNo: 'P2' }, amount: '99.5' }, {})
|
|
357
|
-
assert.equal(Array.isArray(promoList), true)
|
|
358
|
-
assert.equal(preview.preview, true)
|
|
359
|
-
assert.equal(apply.ok, true)
|
|
360
|
-
assert.equal(calls.length, 3)
|
|
361
|
-
})
|