@jetthai/cuora 2.0.0-beta.1 → 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 -113
- package/src/machine/auth_otp_v3.js +11 -8
- package/src/machine/bank_binding.js +2 -3
- package/src/machine/common.js +14 -112
- 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 +18 -28
- 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 +2 -13
- package/src/machine/game_v2_1.js +42 -166
- 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 -463
- 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 -91
- package/src/machine/game_replay.js +0 -47
- package/src/machine/game_search_v2.js +0 -402
- package/src/machine/honor_board.js +0 -144
- 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 -195
- 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 -148
- 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 -629
- 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,304 +0,0 @@
|
|
|
1
|
-
import test from 'node:test'
|
|
2
|
-
import assert from 'node:assert/strict'
|
|
3
|
-
|
|
4
|
-
import inboxFactory from '../src/machine/inbox.js'
|
|
5
|
-
import commonFactory from '../src/machine/common.js'
|
|
6
|
-
import { createLocalStorageMock } from './helpers.js'
|
|
7
|
-
|
|
8
|
-
function toBase64UrlJson(input) {
|
|
9
|
-
return Buffer.from(JSON.stringify(input)).toString('base64').replace(/\+/g, '-').replace(/\//g, '_').replace(/=+$/g, '')
|
|
10
|
-
}
|
|
11
|
-
|
|
12
|
-
test('inbox actions and guards cover selection/read/customer branches', () => {
|
|
13
|
-
const request = { config: { appSecret: 'secret' }, send: async () => ({}) }
|
|
14
|
-
const machine = inboxFactory(request)
|
|
15
|
-
const { actions, guards } = machine.options
|
|
16
|
-
const showMessageCustomerReadCond = machine.config.states.more.states.idle.on.SHOW_MESSAGE[0].cond
|
|
17
|
-
|
|
18
|
-
const baseContext = {
|
|
19
|
-
...machine.initialState.context,
|
|
20
|
-
currentTab: 'CUSTOMER',
|
|
21
|
-
tabs: ['CUSTOMER', 'SYSTEM'],
|
|
22
|
-
inbox: {
|
|
23
|
-
CUSTOMER: {
|
|
24
|
-
page: 0,
|
|
25
|
-
totalPage: 2,
|
|
26
|
-
data: [
|
|
27
|
-
{ groupId: 'g1', isSelected: false, isRead: false },
|
|
28
|
-
{ groupId: 'g2', isSelected: true, isRead: true },
|
|
29
|
-
],
|
|
30
|
-
},
|
|
31
|
-
},
|
|
32
|
-
}
|
|
33
|
-
|
|
34
|
-
assert.equal(guards.hasTabs(baseContext), true)
|
|
35
|
-
assert.equal(guards.isEnd(baseContext), false)
|
|
36
|
-
assert.equal(guards.isEnd({ ...baseContext, inbox: { CUSTOMER: { page: 0, totalPage: 1, data: [] } } }), true)
|
|
37
|
-
assert.equal(guards.isEnd({ ...baseContext, inbox: {} }), false)
|
|
38
|
-
assert.equal(guards.isRead(baseContext, { data: { isRead: true } }), true)
|
|
39
|
-
assert.equal(showMessageCustomerReadCond(baseContext, { data: { isRead: true } }), true)
|
|
40
|
-
assert.equal(guards.isCustomer(baseContext), true)
|
|
41
|
-
assert.equal(guards.isSendable({ messageTitle: 't', messageContent: 'c' }), true)
|
|
42
|
-
|
|
43
|
-
assert.equal(actions.setLang.assignment({ lang: null }, { data: { locale: 'th-TH' } }).lang, 'th-TH')
|
|
44
|
-
assert.equal(actions.setLang.assignment({ lang: 'en-US' }, { data: {} }).lang, 'en-US')
|
|
45
|
-
assert.equal(actions.reset.assignment(baseContext, {}).currentTab, null)
|
|
46
|
-
|
|
47
|
-
const resetPageMissing = actions.resetPage.assignment({ ...baseContext, currentTab: 'SYSTEM' }, {})
|
|
48
|
-
assert.equal(resetPageMissing.inbox.CUSTOMER.page, 0)
|
|
49
|
-
const resetPageHit = actions.resetPage.assignment(baseContext, {})
|
|
50
|
-
assert.equal(resetPageHit.inbox.CUSTOMER.page, -1)
|
|
51
|
-
|
|
52
|
-
assert.equal(
|
|
53
|
-
actions.setTabs.assignment({ ...baseContext, currentTab: null, hasCustomer: true }, { data: ['SYSTEM', 'CUSTOMER'] }).currentTab,
|
|
54
|
-
'CUSTOMER'
|
|
55
|
-
)
|
|
56
|
-
assert.equal(actions.setTabs.assignment({ ...baseContext, currentTab: null, hasCustomer: false }, { data: ['SYSTEM'] }).currentTab, 'SYSTEM')
|
|
57
|
-
assert.equal(actions.setCurrentTab.assignment(baseContext, { data: 'SYSTEM' }).currentTab, 'SYSTEM')
|
|
58
|
-
|
|
59
|
-
const selected = actions.selectMessages.assignment(baseContext, { data: { groupId: 'g1' } })
|
|
60
|
-
assert.equal(selected.inbox.CUSTOMER.data[0].isSelected, true)
|
|
61
|
-
|
|
62
|
-
const cancelSelected = actions.cancelSelectMessages.assignment(baseContext, {})
|
|
63
|
-
assert.equal(
|
|
64
|
-
cancelSelected.inbox.CUSTOMER.data.every((item) => item.isSelected === false),
|
|
65
|
-
true
|
|
66
|
-
)
|
|
67
|
-
assert.equal(actions.cancelSelectMessages.assignment({ ...baseContext, inbox: {} }, {}).selectedDeleteMessages, null)
|
|
68
|
-
|
|
69
|
-
assert.equal(actions.setDelectMessages.assignment(baseContext, {}).selectedDeleteMessages, 'g2')
|
|
70
|
-
|
|
71
|
-
const customerCombined = actions.setCustomerMessage.assignment(baseContext, {
|
|
72
|
-
data: {
|
|
73
|
-
data: [
|
|
74
|
-
{ from: 'SYSTEM', content: 'A', title: 'T1' },
|
|
75
|
-
{ from: 'USER', content: 'B', title: 'T2' },
|
|
76
|
-
],
|
|
77
|
-
},
|
|
78
|
-
})
|
|
79
|
-
assert.equal(typeof customerCombined.messageContent, 'string')
|
|
80
|
-
const customerSingle = actions.setCustomerMessage.assignment(baseContext, {
|
|
81
|
-
data: { data: [{ from: 'USER', content: 'Only', title: 'T3' }] },
|
|
82
|
-
})
|
|
83
|
-
assert.equal(customerSingle.messageContent, 'Only')
|
|
84
|
-
|
|
85
|
-
assert.equal(actions.showMessage.assignment(baseContext, { data: { groupId: 'g1' } }).currentMessage.groupId, 'g1')
|
|
86
|
-
assert.equal(actions.hideMessage.assignment(baseContext, {}).currentMessage, null)
|
|
87
|
-
assert.equal(actions.removeMessage.assignment(baseContext, { data: ['g1'] }).inbox.CUSTOMER.data.length, 1)
|
|
88
|
-
assert.equal(actions.setInbox.assignment(baseContext, { data: { X: { data: [] } } }).inbox.X.data.length, 0)
|
|
89
|
-
assert.equal(actions.setMessageIsRead.assignment(baseContext, { data: { groupId: 'g1' } }).inbox.CUSTOMER.data[0].isRead, true)
|
|
90
|
-
assert.equal(actions.setMessageTitle.assignment(baseContext, { data: 'title' }).messageTitle, 'title')
|
|
91
|
-
assert.equal(actions.setMessageContent.assignment(baseContext, { data: 'content' }).messageContent, 'content')
|
|
92
|
-
})
|
|
93
|
-
|
|
94
|
-
test('inbox services cover reward/mailbox fetch and mutation APIs', async () => {
|
|
95
|
-
const sent = []
|
|
96
|
-
const request = {
|
|
97
|
-
config: { appSecret: 'secret' },
|
|
98
|
-
send: async (req) => {
|
|
99
|
-
sent.push(req)
|
|
100
|
-
if (req.url === 'mailbox/getMessageTypes') return { data: [{ type: 'CUSTOMER' }, { type: 'REWARD' }] }
|
|
101
|
-
if (req.url === 'activities/rewards') return { data: [{ groupId: 'r1', isRead: false }] }
|
|
102
|
-
if (req.url === 'mailbox/getMessageList?include=cl') {
|
|
103
|
-
return { data: [{ groupId: 'm1', isRead: false }], page: 0, totalPage: 3 }
|
|
104
|
-
}
|
|
105
|
-
if (req.url === 'mailbox/updateMessage') {
|
|
106
|
-
if (req.params?.isDelete) return { groupId: req.params.groupId }
|
|
107
|
-
return { ok: true }
|
|
108
|
-
}
|
|
109
|
-
if (req.url === 'mailbox/sendMessage') return { ok: true }
|
|
110
|
-
if (req.url === 'mailbox/getMessage') return { data: [{ from: 'SYSTEM', content: 'hello', title: 'T' }] }
|
|
111
|
-
return {}
|
|
112
|
-
},
|
|
113
|
-
}
|
|
114
|
-
|
|
115
|
-
const machine = inboxFactory(request)
|
|
116
|
-
const { services } = machine.options
|
|
117
|
-
|
|
118
|
-
const tabs = await services.fetchTabs({}, {})
|
|
119
|
-
assert.deepEqual(tabs, ['CUSTOMER', 'REWARD'])
|
|
120
|
-
|
|
121
|
-
const rewardInbox = await services.fetchMessages({ lang: 'en-US', isRewardListEnable: true, currentTab: 'REWARD', inbox: {} }, {})
|
|
122
|
-
assert.equal(rewardInbox.REWARD.data.length, 1)
|
|
123
|
-
|
|
124
|
-
const mailboxInbox = await services.fetchMessages({ lang: 'en-US', isRewardListEnable: false, currentTab: 'CUSTOMER', inbox: {} }, {})
|
|
125
|
-
assert.equal(mailboxInbox.CUSTOMER.data[0].isSelected, false)
|
|
126
|
-
|
|
127
|
-
const reReward = await services.reFetchMessages({ lang: 'en-US', isRewardListEnable: true, currentTab: 'FREE_GAME', inbox: {} }, {})
|
|
128
|
-
assert.equal(reReward.FREE_GAME.page, 0)
|
|
129
|
-
|
|
130
|
-
const reMailbox = await services.reFetchMessages({ lang: 'en-US', isRewardListEnable: false, currentTab: 'CUSTOMER', inbox: {} }, {})
|
|
131
|
-
assert.equal(reMailbox.CUSTOMER.page, 0)
|
|
132
|
-
|
|
133
|
-
const isReadUpdated = await services.updateMessageIsRead({ currentMessage: { groupId: 'm1' } }, {})
|
|
134
|
-
assert.equal(isReadUpdated, true)
|
|
135
|
-
|
|
136
|
-
const deleted = await services.deleteMessages({ selectedDeleteMessages: 'm1,m2' }, {})
|
|
137
|
-
assert.deepEqual(deleted, ['m1', 'm2'])
|
|
138
|
-
|
|
139
|
-
const inquiry = await services.accountInquiry({}, { data: { from: 'USER', title: 'Need help', content: 'Please check' } })
|
|
140
|
-
assert.equal(inquiry.ok, true)
|
|
141
|
-
|
|
142
|
-
const msg = await services.getMessage({ currentMessage: { groupId: 'm1' } }, {})
|
|
143
|
-
assert.equal(Array.isArray(msg.data), true)
|
|
144
|
-
|
|
145
|
-
const sentMsg = await services.sendMessage({ messageTitle: 'T', messageContent: 'C' }, { data: { from: 'USER' } })
|
|
146
|
-
assert.equal(sentMsg.ok, true)
|
|
147
|
-
|
|
148
|
-
assert.equal(
|
|
149
|
-
sent.some((entry) => entry.url === 'mailbox/sendMessage'),
|
|
150
|
-
true
|
|
151
|
-
)
|
|
152
|
-
})
|
|
153
|
-
|
|
154
|
-
test('common actions/guards/services cover config decode, agent persistence and feed shaping', async () => {
|
|
155
|
-
global.localStorage = createLocalStorageMock()
|
|
156
|
-
global.window = {
|
|
157
|
-
location: { search: '?channel=ch&subchannel=sub&ac=aff&fc=friend&pix=p1&kpix=k1&fbclid=fb1' },
|
|
158
|
-
atob: (value) => Buffer.from(value, 'base64').toString('binary'),
|
|
159
|
-
CC_JSB: false,
|
|
160
|
-
}
|
|
161
|
-
global.document = { cookie: '' }
|
|
162
|
-
|
|
163
|
-
const sent = []
|
|
164
|
-
const request = {
|
|
165
|
-
config: { appSecret: 'secret', defaultChannel: 'def-ch', defaultSubchannel: 'def-sub' },
|
|
166
|
-
send: async (req) => {
|
|
167
|
-
sent.push(req)
|
|
168
|
-
if (req.url === 'getConfig') {
|
|
169
|
-
return {
|
|
170
|
-
config: `${toBase64UrlJson({
|
|
171
|
-
loginMethods: { phone: true, email: false },
|
|
172
|
-
registerMethods: { email: true, phone: false },
|
|
173
|
-
registerBindingAffiliateCodeInstructionsEnable: 'true',
|
|
174
|
-
csChat: [{ name: 'customermessage', enable: false }],
|
|
175
|
-
})}.sig`,
|
|
176
|
-
}
|
|
177
|
-
}
|
|
178
|
-
if (req.url === 'getQuickLayout') {
|
|
179
|
-
return { config: `${toBase64UrlJson({ theme: 'x' })}.sig` }
|
|
180
|
-
}
|
|
181
|
-
if (req.url === 'getAffiliateCode') return { affiliateCode: 'DA001' }
|
|
182
|
-
if (req.url === 'feeds')
|
|
183
|
-
return { broadcastList: { broadcasts: [{ type: '0', broadcast_id: 1 }] }, mailBoxInfo: { rows: 10, detailRows: { CUSTOMER: 2 } } }
|
|
184
|
-
if (req.url === 'getAnnouncements') return { data: [{ id: 1 }] }
|
|
185
|
-
return {}
|
|
186
|
-
},
|
|
187
|
-
}
|
|
188
|
-
|
|
189
|
-
const machine = commonFactory(request)
|
|
190
|
-
const { actions, guards, services, delays } = machine.options
|
|
191
|
-
|
|
192
|
-
const setUA = actions.setUA.assignment(machine.initialState.context, {})
|
|
193
|
-
assert.equal(typeof setUA.userAgent, 'object')
|
|
194
|
-
|
|
195
|
-
const setAgent = actions.setAgent.assignment(machine.initialState.context, {})
|
|
196
|
-
assert.equal(setAgent.channel, 'ch')
|
|
197
|
-
assert.equal(setAgent.subchannel, 'sub')
|
|
198
|
-
|
|
199
|
-
global.window.CC_JSB = true
|
|
200
|
-
assert.equal(actions.setAgent.assignment(machine.initialState.context, {}), undefined)
|
|
201
|
-
global.window.CC_JSB = false
|
|
202
|
-
|
|
203
|
-
assert.equal(actions.setFbclid.assignment(machine.initialState.context, {}).fbclid, 'fb1')
|
|
204
|
-
assert.equal(global.document.cookie.includes('_fbc='), true)
|
|
205
|
-
|
|
206
|
-
assert.equal(actions.setPixel.assignment(machine.initialState.context, {}).pix, 'p1')
|
|
207
|
-
assert.equal(actions.setKPixel.assignment(machine.initialState.context, {}).kpix, 'k1')
|
|
208
|
-
|
|
209
|
-
const layoutToken = `${toBase64UrlJson({ layout: 'v1' })}.sig`
|
|
210
|
-
const cfg = actions.setConfig.assignment(machine.initialState.context, {
|
|
211
|
-
data: {
|
|
212
|
-
siteConfig: {
|
|
213
|
-
loginMethods: { phone: true, email: false },
|
|
214
|
-
registerMethods: { email: true, phone: false },
|
|
215
|
-
},
|
|
216
|
-
layoutConfig: layoutToken,
|
|
217
|
-
},
|
|
218
|
-
})
|
|
219
|
-
assert.equal(cfg.siteConfig.loginMethods.phone, true)
|
|
220
|
-
assert.equal(cfg.siteConfig.loginMethods.email, undefined)
|
|
221
|
-
assert.equal(cfg.layoutConfig.layout, 'v1')
|
|
222
|
-
|
|
223
|
-
assert.equal(actions.setDefaultAffiliateCode.assignment(machine.initialState.context, { data: { affiliateCode: 'A1' } }).defaultAffiliateCode, 'A1')
|
|
224
|
-
assert.equal(actions.clearAnnouncements.assignment(machine.initialState.context, {}).announcementList, null)
|
|
225
|
-
assert.equal(actions.setAnnouncements.assignment(machine.initialState.context, { data: { data: [{ id: 1 }] } }).announcementList.data.length, 1)
|
|
226
|
-
|
|
227
|
-
const feeds = actions.setFeeds.assignment(
|
|
228
|
-
{ ...machine.initialState.context, siteConfig: { csChat: [{ name: 'customermessage', enable: false }] } },
|
|
229
|
-
{ data: { broadcastList: { broadcasts: [] }, mailBoxInfo: { rows: 10, detailRows: { CUSTOMER: 3 } } } }
|
|
230
|
-
)
|
|
231
|
-
assert.equal(feeds.mailBoxInfo.rows, 7)
|
|
232
|
-
|
|
233
|
-
const broadcast = actions.setBroadcast.assignment(
|
|
234
|
-
{
|
|
235
|
-
...machine.initialState.context,
|
|
236
|
-
broadcastList: {
|
|
237
|
-
broadcasts: [
|
|
238
|
-
{ type: '0', broadcast_id: 1 },
|
|
239
|
-
{ type: '0', broadcast_id: 2 },
|
|
240
|
-
],
|
|
241
|
-
},
|
|
242
|
-
sentNormalBroadcastList: [{ broadcast_id: 1 }],
|
|
243
|
-
normalBroadcast: { broadcast_id: 2 },
|
|
244
|
-
},
|
|
245
|
-
{}
|
|
246
|
-
)
|
|
247
|
-
assert.equal(broadcast.normalBroadcast, undefined)
|
|
248
|
-
assert.equal(broadcast.sentNormalBroadcastList.length, 2)
|
|
249
|
-
const broadcastNext = actions.setBroadcast.assignment(
|
|
250
|
-
{
|
|
251
|
-
...machine.initialState.context,
|
|
252
|
-
broadcastList: {
|
|
253
|
-
broadcasts: [
|
|
254
|
-
{ type: '1', broadcast_id: 10 },
|
|
255
|
-
{ type: '0', broadcast_id: 11 },
|
|
256
|
-
],
|
|
257
|
-
},
|
|
258
|
-
sentNormalBroadcastList: [{ broadcast_id: 1 }],
|
|
259
|
-
normalBroadcast: null,
|
|
260
|
-
},
|
|
261
|
-
{}
|
|
262
|
-
)
|
|
263
|
-
assert.equal(broadcastNext.normalBroadcast.broadcast_id, 11)
|
|
264
|
-
const broadcastWithoutQueue = actions.setBroadcast.assignment(
|
|
265
|
-
{
|
|
266
|
-
...machine.initialState.context,
|
|
267
|
-
broadcastList: null,
|
|
268
|
-
sentNormalBroadcastList: [],
|
|
269
|
-
normalBroadcast: null,
|
|
270
|
-
},
|
|
271
|
-
{}
|
|
272
|
-
)
|
|
273
|
-
assert.equal(broadcastWithoutQueue.normalBroadcast, undefined)
|
|
274
|
-
|
|
275
|
-
assert.equal(actions.resetBroadcast.assignment(machine.initialState.context, {}).normalBroadcast, null)
|
|
276
|
-
assert.equal(actions.resetByEnterGame.assignment(machine.initialState.context, {}).isPlaying, true)
|
|
277
|
-
assert.equal(actions.leaveGame.assignment(machine.initialState.context, {}).isPlaying, false)
|
|
278
|
-
assert.equal(actions.resetByLogout.assignment(machine.initialState.context, {}).isLogin, false)
|
|
279
|
-
assert.equal(actions.login.assignment(machine.initialState.context, {}).isLogin, true)
|
|
280
|
-
|
|
281
|
-
assert.equal(
|
|
282
|
-
guards.isAffiliateCodeInstructionsEnable({}, { data: { siteConfig: { registerBindingAffiliateCodeInstructionsEnable: 'true' } } }),
|
|
283
|
-
true
|
|
284
|
-
)
|
|
285
|
-
assert.equal(guards.isAffiliateCodeInstructionsEnable({}, { data: { siteConfig: {} } }), false)
|
|
286
|
-
assert.equal(guards.isNotInGame({ isPlaying: false }), true)
|
|
287
|
-
assert.equal(delays.TIMEOUT({ tick: 3000 }), 30000)
|
|
288
|
-
|
|
289
|
-
const fetchedConfig = await services.fetchConfig({}, {})
|
|
290
|
-
assert.equal(fetchedConfig.siteConfig.loginMethods.phone, true)
|
|
291
|
-
|
|
292
|
-
const defaultAff = await services.fetchDefaultAffiliateCode({}, {})
|
|
293
|
-
assert.equal(defaultAff.affiliateCode, 'DA001')
|
|
294
|
-
|
|
295
|
-
const feedData = await services.fetchFeeds({}, {})
|
|
296
|
-
assert.equal(feedData.mailBoxInfo.rows, 10)
|
|
297
|
-
|
|
298
|
-
const ann = await services.fetchAnnouncements({}, {})
|
|
299
|
-
assert.equal(ann.data.length, 1)
|
|
300
|
-
assert.equal(
|
|
301
|
-
sent.some((entry) => entry.url === 'getConfig'),
|
|
302
|
-
true
|
|
303
|
-
)
|
|
304
|
-
})
|
|
@@ -1,101 +0,0 @@
|
|
|
1
|
-
import test from 'node:test'
|
|
2
|
-
import assert from 'node:assert/strict'
|
|
3
|
-
|
|
4
|
-
import loadcardCashFactory from '../src/machine/deposit/loadcard_cash.js'
|
|
5
|
-
|
|
6
|
-
test('loadcard_cash actions/services cover init, promotion, card fields and submit mapping', async () => {
|
|
7
|
-
const sent = []
|
|
8
|
-
const request = {
|
|
9
|
-
send: async (req) => {
|
|
10
|
-
sent.push(req)
|
|
11
|
-
if (req.url === 'payment/v2/loadcard_cash/expected/result') return { data: { bonus: 12 } }
|
|
12
|
-
if (req.url === 'payment/v2/loadcard_cash/transaction') return { applyId: 808 }
|
|
13
|
-
return {}
|
|
14
|
-
},
|
|
15
|
-
}
|
|
16
|
-
|
|
17
|
-
const machine = loadcardCashFactory(request, {
|
|
18
|
-
paymentDetail: [
|
|
19
|
-
{
|
|
20
|
-
transferType: 'deposit',
|
|
21
|
-
category: 'loadcard',
|
|
22
|
-
method: 'loadcard_cash',
|
|
23
|
-
minimum: 50,
|
|
24
|
-
maximum: 5000,
|
|
25
|
-
channel_id: 'LC1',
|
|
26
|
-
optional: [100, 200],
|
|
27
|
-
},
|
|
28
|
-
{
|
|
29
|
-
transferType: 'deposit',
|
|
30
|
-
category: 'loadcard',
|
|
31
|
-
method: 'loadcard_cash_2',
|
|
32
|
-
minimum: 80,
|
|
33
|
-
maximum: 8000,
|
|
34
|
-
channel_id: 'LC2',
|
|
35
|
-
optional: [300],
|
|
36
|
-
},
|
|
37
|
-
],
|
|
38
|
-
promotion: { promotionsNo: 'P1', minimumAmount: 120 },
|
|
39
|
-
selectedAmount: 10,
|
|
40
|
-
})
|
|
41
|
-
|
|
42
|
-
const { actions, services } = machine.options
|
|
43
|
-
const debounceCond = machine.config.states.debouncing.after[1000][0].cond
|
|
44
|
-
|
|
45
|
-
const init = actions.setInitData.assignment(machine.initialState.context, {})
|
|
46
|
-
assert.equal(init.loadcards.length, 2)
|
|
47
|
-
assert.equal(init.selectedLoadcard.method, 'loadcard_cash')
|
|
48
|
-
assert.equal(init.selectedAmount, 120)
|
|
49
|
-
|
|
50
|
-
const initNoMatch = actions.setInitData.assignment(
|
|
51
|
-
{ paymentDetail: [{ category: 'other', transferType: 'deposit', minimum: 10 }], currentCategory: 'loadcard' },
|
|
52
|
-
{}
|
|
53
|
-
)
|
|
54
|
-
assert.equal(initNoMatch.selectedLoadcard, undefined)
|
|
55
|
-
assert.equal(initNoMatch.selectedAmount, 0)
|
|
56
|
-
|
|
57
|
-
const promo = actions.setPromotion.assignment({ ...init, selectedAmount: 30 }, { data: { promotionsNo: 'P2', minimumAmount: 300 } })
|
|
58
|
-
assert.equal(promo.selectedAmount, 300)
|
|
59
|
-
assert.equal(promo.calculation, null)
|
|
60
|
-
|
|
61
|
-
const setLoadcard = actions.setLoadcard.assignment(
|
|
62
|
-
{ ...init, promotion: { minimumAmount: 200 }, selectedAmount: 100 },
|
|
63
|
-
{ data: { method: 'loadcard_cash_2', optional: [300], channel_id: 'LC2' } }
|
|
64
|
-
)
|
|
65
|
-
assert.equal(setLoadcard.selectedLoadcard.method, 'loadcard_cash_2')
|
|
66
|
-
assert.equal(setLoadcard.selectedAmount, 200)
|
|
67
|
-
|
|
68
|
-
assert.equal(actions.setAmount.assignment(machine.initialState.context, { data: 456 }).selectedAmount, 456)
|
|
69
|
-
assert.deepEqual(actions.setCalculation.assignment(machine.initialState.context, { data: { data: { x: 1 } } }).calculation, { x: 1 })
|
|
70
|
-
assert.deepEqual(actions.setCalculation.assignment(machine.initialState.context, { data: { y: 2 } }).calculation, { y: 2 })
|
|
71
|
-
assert.equal(actions.clearCalculation.assignment(machine.initialState.context, {}).calculation, null)
|
|
72
|
-
assert.equal(actions.setResult.assignment(machine.initialState.context, { data: { applyId: 1 } }).result.applyId, 1)
|
|
73
|
-
assert.equal(actions.setCardNumber.assignment(machine.initialState.context, { data: 'CARD' }).cardNumber, 'CARD')
|
|
74
|
-
assert.equal(actions.setSerialNumber.assignment(machine.initialState.context, { data: 'SERIAL' }).serialNumber, 'SERIAL')
|
|
75
|
-
assert.equal(debounceCond({ selectedLoadcard: { minimum: 100, maximum: 500 }, selectedAmount: 200 }, {}), true)
|
|
76
|
-
assert.equal(debounceCond({ selectedLoadcard: null, selectedAmount: 100 }, {}), false)
|
|
77
|
-
|
|
78
|
-
const calc = await services.fetchCalculation(
|
|
79
|
-
{ selectedLoadcard: { method: 'loadcard_cash' }, selectedAmount: 500, promotion: { promotionsNo: 'P3' } },
|
|
80
|
-
{}
|
|
81
|
-
)
|
|
82
|
-
assert.equal(calc.data.bonus, 12)
|
|
83
|
-
|
|
84
|
-
const submitted = await services.submitDeposit(
|
|
85
|
-
{
|
|
86
|
-
selectedLoadcard: { method: 'loadcard_cash', channel_id: 'LC1' },
|
|
87
|
-
selectedAmount: 700,
|
|
88
|
-
promotion: { promotionsNo: 'P4' },
|
|
89
|
-
cardNumber: 'CARD123',
|
|
90
|
-
serialNumber: 'SERIAL123',
|
|
91
|
-
},
|
|
92
|
-
{}
|
|
93
|
-
)
|
|
94
|
-
assert.equal(submitted.applyId, 808)
|
|
95
|
-
|
|
96
|
-
const submitReq = sent.find((entry) => entry.url === 'payment/v2/loadcard_cash/transaction')
|
|
97
|
-
assert.equal(submitReq.params.card_type, 'LC1')
|
|
98
|
-
assert.equal(submitReq.params.card_code, 'CARD123')
|
|
99
|
-
assert.equal(submitReq.params.card_seri, 'SERIAL123')
|
|
100
|
-
assert.equal(submitReq.params.promotionsNo, 'P4')
|
|
101
|
-
})
|
|
@@ -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
|
-
})
|