@jetthai/cuora 1.1.488 → 2.0.0-beta.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/.husky/pre-commit +3 -1
- package/BREAKING_CHANGES.md +9 -0
- package/CHANGELOG.md +3 -316
- package/README.md +15 -299
- package/package.json +5 -5
- package/resetGitBranch.sh +101 -0
- package/src/api/account.js +1 -0
- package/src/api/activity.js +39 -24
- package/src/api/auth.js +36 -5
- package/src/api/common.js +3 -5
- package/src/api/game.js +10 -0
- package/src/api/payment.js +55 -17
- package/src/api/user.js +16 -10
- package/src/index.js +2 -2
- package/src/lib/fingerprint_v3_11_12.js +11433 -0
- package/src/machine/activity/activity.js +213 -0
- package/src/machine/activity/activity_cash.js +36 -84
- package/src/machine/activity/cash_rain_activity.js +1 -0
- package/src/machine/activity/continue_deposit_activity.js +1 -0
- package/src/machine/activity/deposit_activity.js +1 -0
- package/src/machine/activity/diamond_shop_activity_cash.js +8 -0
- package/src/machine/activity/diamond_shop_activity_fc.js +197 -0
- package/src/machine/activity/diamond_shop_activity_vn.js +179 -0
- package/src/machine/activity/fafafa_activity.js +11 -0
- package/src/machine/activity/friend_invite_friends_activity.js +7 -8
- package/src/machine/activity/index.js +12 -0
- package/src/machine/activity/instant_rebate_activity.js +1 -0
- package/src/machine/activity/invite_friends_activity.js +115 -0
- package/src/machine/activity/jackpot.js +1 -0
- package/src/machine/activity/mini_game_activity.js +69 -0
- package/src/machine/activity/otp_verified_activity.js +1 -0
- package/src/machine/activity/ranking_activity.js +1 -0
- package/src/machine/activity/return_bonus_activity.js +155 -0
- package/src/machine/activity/roulette_activity_v2.js +1 -0
- package/src/machine/activity/sign_in_activity.js +1 -0
- package/src/machine/activity/sign_in_monthly_activity.js +2 -1
- package/src/machine/activity/specify_bets_activity.js +1 -0
- package/src/machine/activity/specify_turnover_activity.js +1 -0
- package/src/machine/activity/time_bomb_activity.js +1 -0
- package/src/machine/activity/vip_card_activity.js +1 -0
- package/src/machine/auth.js +112 -149
- package/src/machine/auth_otp_v2.js +178 -0
- package/src/machine/auth_otp_v3.js +22 -64
- package/src/machine/bank_binding.js +3 -2
- package/src/machine/bank_binding_amb.js +146 -0
- package/src/machine/bonus.js +76 -0
- package/src/machine/common.js +98 -14
- package/src/machine/deposit/amb.js +93 -0
- package/src/machine/deposit/crypto_bank.js +340 -0
- package/src/machine/deposit/crypto_bank_cash.js +35 -20
- package/src/machine/deposit/crypto_qrcode.js +158 -0
- package/src/machine/deposit/crypto_qrcode_cash.js +64 -26
- package/src/machine/deposit/crypto_way.js +253 -0
- package/src/machine/deposit/crypto_way_cash.js +37 -48
- package/src/machine/deposit/deposit_fc.js +272 -0
- package/src/machine/deposit/direct.js +311 -0
- package/src/machine/deposit/direct_cash.js +10 -8
- package/src/machine/deposit/float.js +375 -0
- package/src/machine/deposit/index.js +28 -0
- package/src/machine/deposit/krway.js +152 -0
- package/src/machine/deposit/loadcard_cash.js +32 -14
- package/src/machine/deposit/loadcard_vn.js +352 -0
- package/src/machine/deposit/manual_cash.js +11 -8
- package/src/machine/deposit/manual_vn.js +459 -0
- package/src/machine/deposit/qrcode_cash.js +32 -15
- package/src/machine/deposit/qrcode_v2.js +339 -0
- package/src/machine/deposit/usdt.js +163 -0
- package/src/machine/deposit/usdt_cash.js +15 -1
- package/src/machine/deposit/virtual_bank_cash.js +12 -13
- package/src/machine/deposit/virtual_bank_vn.js +270 -0
- package/src/machine/deposit/vpay.js +374 -0
- package/src/machine/error.js +1 -7
- package/src/machine/game_betslip.js +1 -0
- package/src/machine/game_favorite_v2.js +1 -0
- package/src/machine/game_hot_new.js +80 -0
- package/src/machine/game_info.js +13 -1
- package/src/machine/game_replay.js +47 -0
- package/src/machine/game_search_cash.js +1 -0
- package/src/machine/game_search_v2.js +402 -0
- package/src/machine/game_v2_1.js +126 -39
- package/src/machine/honor_board.js +133 -0
- package/src/machine/honor_board_cash.js +28 -22
- package/src/machine/inbox.js +105 -43
- package/src/machine/index.js +32 -0
- package/src/machine/leaderboard.js +12 -8
- package/src/machine/merge.js +58 -0
- package/src/machine/navbar.js +3 -1
- package/src/machine/payment_data.js +87 -0
- package/src/machine/promotions.js +163 -0
- package/src/machine/ranking.js +30 -45
- package/src/machine/reward.js +256 -0
- package/src/machine/reward_cash.js +42 -2
- package/src/machine/reward_fc.js +99 -0
- package/src/machine/roulette_v2.js +11 -14
- package/src/machine/setting.js +1 -0
- package/src/machine/side.js +160 -0
- package/src/machine/side_cash.js +3 -3
- package/src/machine/side_v2.js +223 -0
- package/src/machine/user_info.js +1 -0
- package/src/machine/user_photo.js +1 -0
- package/src/machine/user_reset_password.js +14 -0
- package/src/machine/user_sign_up.js +61 -46
- package/src/machine/vip_table.js +58 -0
- package/src/machine/websocket.js +349 -374
- package/src/machine/welcome.js +111 -0
- package/src/machine/withdraw/index.js +6 -0
- package/src/machine/withdraw/withdraw_crypto_cash.js +328 -0
- package/src/machine/withdraw/withdraw_krway.js +223 -0
- package/src/machine/withdraw/withdraw_manual.js +541 -0
- package/src/machine/withdraw/withdraw_manual_cash.js +39 -59
- package/src/request/config.js +0 -2
- package/src/request/request.js +60 -124
- package/src/util/constant.js +2 -6
- package/src/util/deviceToken.js +60 -0
- package/src/util/index.js +4 -2
- package/src/util/math.js +4 -0
- package/src/util/storage.js +4 -3
- package/test/api.behavior.test.js +69 -0
- package/test/api.contract.test.js +18 -0
- package/test/config.test.js +27 -0
- package/test/deviceToken.test.js +139 -0
- package/test/helpers.coverage.test.js +11 -0
- package/test/helpers.js +91 -0
- package/test/index.exports.test.js +14 -0
- package/test/machine.activity.core.coverage.test.js +337 -0
- package/test/machine.activity.gap.coverage.test.js +252 -0
- package/test/machine.activity.more.coverage.test.js +180 -0
- package/test/machine.activity_plus_and_binding_amb.coverage.test.js +201 -0
- package/test/machine.activity_timer_bonus.coverage.test.js +136 -0
- package/test/machine.activity_welcome.low.coverage.test.js +211 -0
- package/test/machine.amb_rewardfc_websocket.more.coverage.test.js +201 -0
- package/test/machine.auth.coverage.test.js +215 -0
- package/test/machine.bank_binding.test.js +143 -0
- package/test/machine.binding_otp_krway.coverage.test.js +223 -0
- package/test/machine.contract.test.js +50 -0
- package/test/machine.crypto_bank.coverage.test.js +270 -0
- package/test/machine.crypto_way.coverage.test.js +108 -0
- package/test/machine.crypto_way_cash.coverage.test.js +114 -0
- package/test/machine.definition.test.js +137 -0
- package/test/machine.deposit.manual.coverage.test.js +365 -0
- package/test/machine.deposit_fc.coverage.test.js +126 -0
- package/test/machine.direct.coverage.test.js +96 -0
- package/test/machine.direct_cash.coverage.test.js +108 -0
- package/test/machine.error.coverage.test.js +37 -0
- package/test/machine.events.test.js +126 -0
- package/test/machine.favorite_jackpot.coverage.test.js +82 -0
- package/test/machine.float.coverage.test.js +136 -0
- package/test/machine.flow.test.js +226 -0
- package/test/machine.game_hot_new_vip_table.coverage.test.js +105 -0
- package/test/machine.game_search_cash.coverage.test.js +155 -0
- package/test/machine.game_search_v2.test.js +199 -0
- package/test/machine.game_user_profile.coverage.test.js +100 -0
- package/test/machine.honor_board.test.js +133 -0
- package/test/machine.inbox.common.coverage.test.js +304 -0
- package/test/machine.loadcard_cash.coverage.test.js +101 -0
- package/test/machine.loadcard_vn.coverage.test.js +122 -0
- package/test/machine.misc.coverage.test.js +361 -0
- package/test/machine.more2.coverage.test.js +261 -0
- package/test/machine.options.execution.test.js +272 -0
- package/test/machine.priority.coverage.test.js +603 -0
- package/test/machine.qrcode_cash.coverage.test.js +107 -0
- package/test/machine.qrcode_v2.coverage.test.js +121 -0
- package/test/machine.regression.test.js +82 -0
- package/test/machine.roulette_v2.test.js +142 -0
- package/test/machine.side_reward_reset.coverage.test.js +220 -0
- package/test/machine.targeted.coverage.test.js +313 -0
- package/test/machine.usdt.coverage.test.js +95 -0
- package/test/machine.usdt_cash.coverage.test.js +73 -0
- package/test/machine.vip_card_activity.test.js +114 -0
- package/test/machine.virtual_bank_cash.coverage.test.js +105 -0
- package/test/machine.virtual_bank_vn.coverage.test.js +105 -0
- package/test/machine.vpay.coverage.test.js +142 -0
- package/test/machine.withdraw_crypto_cash.coverage.test.js +166 -0
- package/test/machine.withdraw_krway.coverage.test.js +123 -0
- package/test/machine.withdraw_manual.coverage.test.js +185 -0
- package/test/machine.withdraw_manual_cash.coverage.test.js +123 -0
- package/test/request.test.js +325 -0
- package/test/util.storage.errors.test.js +47 -0
- package/test/util.test.js +41 -0
- package/.claude/commands/sync-ai-prompts.md +0 -93
- package/.claude/settings.local.json +0 -23
- package/.github/copilot-instructions.md +0 -448
- package/.husky/post-checkout +0 -32
- package/.husky/pre-push +0 -36
- package/AGENTS.md +0 -448
- package/AI_PROMPT_SOURCE.md +0 -446
- package/CLAUDE.md +0 -448
- package/GEMINI.md +0 -448
- package/docs/kibana/crypto-way-deposit-amount-bug-analysis.md +0 -1003
- package/docs/kibana/play-providerId-error.md +0 -202
- package/docs/kibana/play-selectedWalletType.md +0 -1
- package/docs/kibana/play-selectedWalletType_2.md +0 -1
- package/docs/kibana/play-selectedWalletType_analysis.md +0 -565
- package/docs/my-claude/feat-sharon-JT-1790247240-socket/branch-transfer.md +0 -14
- package/docs/my-claude/feat-sharon-JT-1790247240-socket/cash-module-preparation.json +0 -40
- package/docs/my-claude/feat-sharon-JT-1790247240-socket/cash-module-verification.md +0 -41
- package/docs/my-claude/feat-sharon-JT-1790247240-socket/implementation-ledger.md +0 -87
- package/docs/my-claude/feat-sharon-JT-1790247240-socket/module-report.md +0 -73
- package/docs/my-claude/feat-sharon-JT-1790247240-socket/plan.md +0 -309
- package/docs/my-claude/feat-sharon-JT-1790247240-socket/test-cases.md +0 -245
- package/docs/my-claude/feat-sharon-JT-1791180540-onesignal/transfer.md +0 -9
- package/scripts/auto-version.js +0 -68
- package/scripts/auto-version.sh +0 -33
- package/scripts/branch-auto-npm-publish.js +0 -29
- package/scripts/check-version.sh +0 -36
- package/scripts/clean-tags.sh +0 -84
- package/src/util/amount.js +0 -8
- package/src/util/err998SentryExtra.js +0 -26
- package/src/util/paramStore.js +0 -139
- package/src/util/socketPolicy.js +0 -57
- package/test/auth_otp_v3.test.js +0 -323
- package/tests/websocket.test.mjs +0 -779
|
@@ -0,0 +1,122 @@
|
|
|
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
|
+
})
|
|
@@ -0,0 +1,361 @@
|
|
|
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
|
+
})
|