@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,226 +0,0 @@
|
|
|
1
|
-
import test from 'node:test'
|
|
2
|
-
import assert from 'node:assert/strict'
|
|
3
|
-
|
|
4
|
-
import mergeFactory from '../src/machine/merge.js'
|
|
5
|
-
import settingFactory from '../src/machine/setting.js'
|
|
6
|
-
import qrcodeCashFactory from '../src/machine/deposit/qrcode_cash.js'
|
|
7
|
-
import directCashFactory from '../src/machine/deposit/direct_cash.js'
|
|
8
|
-
import usdtCashFactory from '../src/machine/deposit/usdt_cash.js'
|
|
9
|
-
import authFactory from '../src/machine/auth.js'
|
|
10
|
-
import commonFactory from '../src/machine/common.js'
|
|
11
|
-
import { createLocalStorageMock } from './helpers.js'
|
|
12
|
-
|
|
13
|
-
function createRequestStub() {
|
|
14
|
-
return {
|
|
15
|
-
config: {
|
|
16
|
-
apiURL: 'https://api.example.com',
|
|
17
|
-
apiVersion: 'v1',
|
|
18
|
-
clientId: 'client',
|
|
19
|
-
appSecret: 'secret',
|
|
20
|
-
platform: 'web',
|
|
21
|
-
version: '1.0.0',
|
|
22
|
-
fpToken: 'fp-token',
|
|
23
|
-
sentry: { captureException: () => {}, setTag: () => {} },
|
|
24
|
-
defaultChannel: 'web',
|
|
25
|
-
defaultSubchannel: 'home',
|
|
26
|
-
socketURL: 'wss://socket.example.com',
|
|
27
|
-
bucketName: 'bucket',
|
|
28
|
-
},
|
|
29
|
-
send: async () => ({}),
|
|
30
|
-
getToken: () => null,
|
|
31
|
-
}
|
|
32
|
-
}
|
|
33
|
-
|
|
34
|
-
test('merge flow: becomes mergeable and enters merging on MERGE', () => {
|
|
35
|
-
const machine = mergeFactory(createRequestStub())
|
|
36
|
-
|
|
37
|
-
let state = machine.initialState
|
|
38
|
-
assert.equal(state.value, 'idle')
|
|
39
|
-
|
|
40
|
-
state = machine.transition(state, {
|
|
41
|
-
type: 'SET_USER_INFO',
|
|
42
|
-
data: { retain: 10, balance: '3', withdraw_policy: 'NORMAL' },
|
|
43
|
-
})
|
|
44
|
-
assert.equal(state.value, 'mergeable')
|
|
45
|
-
|
|
46
|
-
state = machine.transition(state, { type: 'MERGE' })
|
|
47
|
-
assert.equal(state.value, 'merging')
|
|
48
|
-
})
|
|
49
|
-
|
|
50
|
-
test('merge flow: remains idle when user is not mergeable', () => {
|
|
51
|
-
const machine = mergeFactory(createRequestStub())
|
|
52
|
-
let state = machine.initialState
|
|
53
|
-
|
|
54
|
-
state = machine.transition(state, {
|
|
55
|
-
type: 'SET_USER_INFO',
|
|
56
|
-
data: { retain: 0, balance: '100', withdraw_policy: 'NORMAL' },
|
|
57
|
-
})
|
|
58
|
-
|
|
59
|
-
assert.equal(state.value, 'idle')
|
|
60
|
-
})
|
|
61
|
-
|
|
62
|
-
test('setting flow: loads from localStorage and persists modify events', () => {
|
|
63
|
-
global.localStorage = createLocalStorageMock()
|
|
64
|
-
localStorage.setItem('setting', JSON.stringify({ sound: false, music: true, locale: 'th-TH' }))
|
|
65
|
-
|
|
66
|
-
const machine = settingFactory()
|
|
67
|
-
let state = machine.initialState
|
|
68
|
-
|
|
69
|
-
assert.equal(state.context.sound, false)
|
|
70
|
-
assert.equal(state.context.music, true)
|
|
71
|
-
assert.equal(state.context.locale, 'th-TH')
|
|
72
|
-
|
|
73
|
-
state = machine.transition(state, { type: 'MODIFY_SETTING', data: { sound: true, music: false, locale: 'en-US' } })
|
|
74
|
-
assert.equal(state.context.sound, true)
|
|
75
|
-
assert.equal(state.context.music, false)
|
|
76
|
-
assert.equal(JSON.parse(localStorage.getItem('setting')).music, false)
|
|
77
|
-
})
|
|
78
|
-
|
|
79
|
-
test('setting flow: DEFAULT_SETTING overrides current context', () => {
|
|
80
|
-
global.localStorage = createLocalStorageMock()
|
|
81
|
-
const machine = settingFactory()
|
|
82
|
-
let state = machine.initialState
|
|
83
|
-
|
|
84
|
-
state = machine.transition(state, { type: 'DEFAULT_SETTING', data: { sound: false, music: false, locale: 'ja-JP' } })
|
|
85
|
-
assert.equal(state.context.sound, false)
|
|
86
|
-
assert.equal(state.context.music, false)
|
|
87
|
-
assert.equal(state.context.locale, 'ja-JP')
|
|
88
|
-
})
|
|
89
|
-
|
|
90
|
-
test('qrcode_cash flow: initializes amount by minimum rule and handles input', () => {
|
|
91
|
-
const machine = qrcodeCashFactory(createRequestStub(), {
|
|
92
|
-
paymentDetail: [
|
|
93
|
-
{
|
|
94
|
-
category: 'qrcode',
|
|
95
|
-
transferType: 'deposit',
|
|
96
|
-
optional: [100, 200],
|
|
97
|
-
minimum: 50,
|
|
98
|
-
maximum: 5000,
|
|
99
|
-
method: 'qrcode_method',
|
|
100
|
-
grandTotalEnable: 0,
|
|
101
|
-
},
|
|
102
|
-
],
|
|
103
|
-
promotion: { minimumAmount: 120 },
|
|
104
|
-
selectedAmount: 10,
|
|
105
|
-
})
|
|
106
|
-
|
|
107
|
-
let state = machine.initialState
|
|
108
|
-
assert.equal(state.value, 'debouncing')
|
|
109
|
-
assert.equal(state.context.selectedAmount, 120)
|
|
110
|
-
|
|
111
|
-
state = machine.transition(state, { type: 'INPUT_AMOUNT', data: 350 })
|
|
112
|
-
assert.equal(state.value, 'debouncing')
|
|
113
|
-
assert.equal(state.context.selectedAmount, 350)
|
|
114
|
-
|
|
115
|
-
state = machine.transition(state, { type: 'SET_PROMOTION', data: { minimumAmount: 400, promotionsNo: 'P001' } })
|
|
116
|
-
assert.equal(state.context.selectedAmount, 400)
|
|
117
|
-
})
|
|
118
|
-
|
|
119
|
-
test('auth flow: LOGIN_ID sets credentials and moves to authentication', () => {
|
|
120
|
-
global.localStorage = createLocalStorageMock()
|
|
121
|
-
const machine = authFactory(createRequestStub())
|
|
122
|
-
|
|
123
|
-
let state = machine.initialState
|
|
124
|
-
state = machine.transition(state, {
|
|
125
|
-
type: 'LOGIN_ID',
|
|
126
|
-
data: { username: 'alice', password: 'pw', reCaptchaToken: 'token' },
|
|
127
|
-
})
|
|
128
|
-
|
|
129
|
-
assert.equal(state.value, 'authentication')
|
|
130
|
-
assert.equal(state.context.reCaptchaToken, 'token')
|
|
131
|
-
assert.equal(state.context.loginData.provider, 'local')
|
|
132
|
-
assert.equal(state.context.loginData.username, 'alice')
|
|
133
|
-
})
|
|
134
|
-
|
|
135
|
-
test('auth flow: LOGIN_PHONE maps phone payload and countryAbbr', () => {
|
|
136
|
-
global.localStorage = createLocalStorageMock()
|
|
137
|
-
const machine = authFactory(createRequestStub())
|
|
138
|
-
let state = machine.initialState
|
|
139
|
-
|
|
140
|
-
state = machine.transition(state, {
|
|
141
|
-
type: 'LOGIN_PHONE',
|
|
142
|
-
data: { countryCode: '66', countryAbbr: 'TH', phone: '0800000000', password: 'pw', reCaptchaToken: 'r' },
|
|
143
|
-
})
|
|
144
|
-
|
|
145
|
-
assert.equal(state.value, 'authentication')
|
|
146
|
-
assert.equal(state.context.loginData.provider, 'phone')
|
|
147
|
-
assert.equal(state.context.loginData.countryCode, '66')
|
|
148
|
-
assert.equal(state.context.countryAbbr, 'TH')
|
|
149
|
-
})
|
|
150
|
-
|
|
151
|
-
test('common flow: login refresh then logout pause toggles feed/login flags', () => {
|
|
152
|
-
global.localStorage = createLocalStorageMock()
|
|
153
|
-
global.window = {
|
|
154
|
-
location: { search: '' },
|
|
155
|
-
atob: (value) => Buffer.from(value, 'base64').toString('binary'),
|
|
156
|
-
CC_JSB: false,
|
|
157
|
-
}
|
|
158
|
-
global.document = { cookie: '' }
|
|
159
|
-
|
|
160
|
-
const machine = commonFactory(createRequestStub())
|
|
161
|
-
let state = machine.initialState
|
|
162
|
-
|
|
163
|
-
assert.equal(state.value.feed, 'idle')
|
|
164
|
-
assert.equal(state.context.isLogin, false)
|
|
165
|
-
|
|
166
|
-
state = machine.transition(state, { type: 'LOGIN_REFRESH' })
|
|
167
|
-
assert.equal(state.value.feed, 'updating')
|
|
168
|
-
assert.equal(state.context.isLogin, true)
|
|
169
|
-
|
|
170
|
-
state = machine.transition(state, { type: 'LOGOUT_PAUSE' })
|
|
171
|
-
assert.equal(state.value.feed, 'idle')
|
|
172
|
-
assert.equal(state.context.isLogin, false)
|
|
173
|
-
assert.equal(state.context.broadcastList, null)
|
|
174
|
-
})
|
|
175
|
-
|
|
176
|
-
test('common flow: enter game pause resets feed payload and keeps feed idle', () => {
|
|
177
|
-
global.localStorage = createLocalStorageMock()
|
|
178
|
-
global.window = {
|
|
179
|
-
location: { search: '' },
|
|
180
|
-
atob: (value) => Buffer.from(value, 'base64').toString('binary'),
|
|
181
|
-
CC_JSB: false,
|
|
182
|
-
}
|
|
183
|
-
global.document = { cookie: '' }
|
|
184
|
-
|
|
185
|
-
const machine = commonFactory(createRequestStub())
|
|
186
|
-
let state = machine.initialState
|
|
187
|
-
|
|
188
|
-
state = machine.transition(state, {
|
|
189
|
-
type: 'ENTER_GAME_PAUSE',
|
|
190
|
-
})
|
|
191
|
-
|
|
192
|
-
assert.equal(state.value.feed, 'idle')
|
|
193
|
-
assert.equal(state.context.isPlaying, true)
|
|
194
|
-
assert.equal(state.context.mailBoxInfo, null)
|
|
195
|
-
})
|
|
196
|
-
|
|
197
|
-
test('direct_cash flow: init selects first method and clamps selectedAmount by promotion minimum', () => {
|
|
198
|
-
const machine = directCashFactory(createRequestStub(), {
|
|
199
|
-
paymentDetail: [
|
|
200
|
-
{
|
|
201
|
-
category: 'direct',
|
|
202
|
-
transferType: 'deposit',
|
|
203
|
-
minimum: 100,
|
|
204
|
-
maximum: 5000,
|
|
205
|
-
method: 'direct_1',
|
|
206
|
-
},
|
|
207
|
-
],
|
|
208
|
-
promotion: { minimumAmount: 300 },
|
|
209
|
-
selectedAmount: 20,
|
|
210
|
-
})
|
|
211
|
-
|
|
212
|
-
const state = machine.initialState
|
|
213
|
-
assert.equal(state.context.selectedDirect.method, 'direct_1')
|
|
214
|
-
assert.equal(state.context.selectedAmount, 300)
|
|
215
|
-
})
|
|
216
|
-
|
|
217
|
-
test('usdt_cash flow: handles empty payment detail with safe defaults', () => {
|
|
218
|
-
const machine = usdtCashFactory(createRequestStub(), {
|
|
219
|
-
paymentDetail: [],
|
|
220
|
-
})
|
|
221
|
-
|
|
222
|
-
const state = machine.initialState
|
|
223
|
-
assert.equal(state.context.currentPayment, null)
|
|
224
|
-
assert.deepEqual(state.context.networks, [])
|
|
225
|
-
assert.equal(state.context.selectedNetwork, null)
|
|
226
|
-
})
|
|
@@ -1,105 +0,0 @@
|
|
|
1
|
-
import test from 'node:test'
|
|
2
|
-
import assert from 'node:assert/strict'
|
|
3
|
-
|
|
4
|
-
import gameHotNewFactory from '../src/machine/game_hot_new.js'
|
|
5
|
-
import vipTableFactory from '../src/machine/vip_table.js'
|
|
6
|
-
|
|
7
|
-
test('game_hot_new actions and services cover id/game mapping branches', async () => {
|
|
8
|
-
const sent = []
|
|
9
|
-
const request = {
|
|
10
|
-
send: async (req) => {
|
|
11
|
-
sent.push(req)
|
|
12
|
-
if (req.url === 'game/list/v2/category' && req.params?.id == null) {
|
|
13
|
-
return {
|
|
14
|
-
list: [
|
|
15
|
-
{ id: 10, category: 'SYSTEM_TOP_GAME' },
|
|
16
|
-
{ id: 20, category: 'SYSTEM_NEW_GAME' },
|
|
17
|
-
],
|
|
18
|
-
}
|
|
19
|
-
}
|
|
20
|
-
if (req.url === 'game/list/v2/category' && req.params?.id === 10) {
|
|
21
|
-
return { list: [{ g: { code: 'H1' } }, { g: { code: 'H2' } }] }
|
|
22
|
-
}
|
|
23
|
-
if (req.url === 'game/list/v2/category' && req.params?.id === 20) {
|
|
24
|
-
return { list: [{ g: { code: 'N1' } }] }
|
|
25
|
-
}
|
|
26
|
-
return {}
|
|
27
|
-
},
|
|
28
|
-
}
|
|
29
|
-
|
|
30
|
-
const machine = gameHotNewFactory(request)
|
|
31
|
-
const actions = machine.options.actions
|
|
32
|
-
const services = machine.options.services
|
|
33
|
-
const ctx = machine.initialState.context
|
|
34
|
-
|
|
35
|
-
const setId = actions.setId.assignment(ctx, {
|
|
36
|
-
data: {
|
|
37
|
-
list: [
|
|
38
|
-
{ id: 10, category: 'SYSTEM_TOP_GAME' },
|
|
39
|
-
{ id: 20, category: 'SYSTEM_NEW_GAME' },
|
|
40
|
-
],
|
|
41
|
-
},
|
|
42
|
-
})
|
|
43
|
-
assert.equal(setId.hot.id, 10)
|
|
44
|
-
assert.equal(setId.new.id, 20)
|
|
45
|
-
|
|
46
|
-
const setIdMissing = actions.setId.assignment(ctx, { data: { list: [] } })
|
|
47
|
-
assert.equal(setIdMissing.hot.id, undefined)
|
|
48
|
-
assert.equal(setIdMissing.new.id, undefined)
|
|
49
|
-
|
|
50
|
-
const setGames = actions.setGames.assignment(ctx, {
|
|
51
|
-
data: { games: { hot: [{ code: 'H1' }], new: [{ code: 'N1' }] } },
|
|
52
|
-
})
|
|
53
|
-
assert.equal(setGames.hot.list.length, 1)
|
|
54
|
-
assert.equal(setGames.new.list.length, 1)
|
|
55
|
-
|
|
56
|
-
const roomItems = await services.getRoomItems(ctx, {})
|
|
57
|
-
assert.equal(roomItems.list.length, 2)
|
|
58
|
-
const games = await services.getGames({ ...ctx, hot: { ...ctx.hot, id: 10 }, new: { ...ctx.new, id: 20 } }, {})
|
|
59
|
-
assert.equal(games.games.hot.length, 2)
|
|
60
|
-
assert.equal(games.games.new.length, 1)
|
|
61
|
-
const emptyGames = await services.getGames({ ...ctx, hot: { ...ctx.hot, id: -1 }, new: { ...ctx.new, id: -2 } }, {})
|
|
62
|
-
assert.equal(emptyGames.games.hot, undefined)
|
|
63
|
-
assert.equal(emptyGames.games.new, undefined)
|
|
64
|
-
|
|
65
|
-
assert.equal(
|
|
66
|
-
sent.some((req) => req.url === 'game/list/v2/category'),
|
|
67
|
-
true
|
|
68
|
-
)
|
|
69
|
-
})
|
|
70
|
-
|
|
71
|
-
test('vip_table service supports both old and v2 response structures', async () => {
|
|
72
|
-
let call = 0
|
|
73
|
-
const request = {
|
|
74
|
-
config: { appSecret: 'secret' },
|
|
75
|
-
send: async (req) => {
|
|
76
|
-
call += 1
|
|
77
|
-
if (req.url === 'activities/viptable' && req.params?.appSecret === 'secret') {
|
|
78
|
-
if (call === 1) {
|
|
79
|
-
return { viptable: { data: [{ title: 'BRONZE' }, { title: 'SILVER' }] } }
|
|
80
|
-
}
|
|
81
|
-
return { data: [{ title: 'GOLD' }] }
|
|
82
|
-
}
|
|
83
|
-
return { data: [{ title: 'GOLD' }] }
|
|
84
|
-
},
|
|
85
|
-
}
|
|
86
|
-
const machine = vipTableFactory(request)
|
|
87
|
-
const actions = machine.options.actions
|
|
88
|
-
const services = machine.options.services
|
|
89
|
-
const ctx = machine.initialState.context
|
|
90
|
-
|
|
91
|
-
const setVip = actions.setVipTable.assignment(ctx, { data: [{ title: 'gold' }] })
|
|
92
|
-
assert.equal(setVip.vipTable[0].title, 'gold')
|
|
93
|
-
|
|
94
|
-
const v2 = await services.fetchVipTable(ctx, {})
|
|
95
|
-
assert.deepEqual(
|
|
96
|
-
v2.map((i) => i.title),
|
|
97
|
-
['bronze', 'silver']
|
|
98
|
-
)
|
|
99
|
-
|
|
100
|
-
const legacy = await services.fetchVipTable({ ...ctx }, {})
|
|
101
|
-
assert.deepEqual(
|
|
102
|
-
legacy.map((i) => i.title),
|
|
103
|
-
['gold']
|
|
104
|
-
)
|
|
105
|
-
})
|
|
@@ -1,195 +0,0 @@
|
|
|
1
|
-
import test from 'node:test'
|
|
2
|
-
import assert from 'node:assert/strict'
|
|
3
|
-
|
|
4
|
-
import gameSearchCashFactory from '../src/machine/game_search_cash.js'
|
|
5
|
-
|
|
6
|
-
test('game_search_cash actions and guards cover assignment branches', () => {
|
|
7
|
-
const machine = gameSearchCashFactory({ send: async () => ({}) })
|
|
8
|
-
const actions = machine.options.actions
|
|
9
|
-
const guards = machine.options.guards
|
|
10
|
-
const ctx = machine.initialState.context
|
|
11
|
-
|
|
12
|
-
assert.equal(actions.setInitialized.assignment(ctx, {}).initialized, true)
|
|
13
|
-
assert.deepEqual(actions.setMainTagList.assignment(ctx, { data: [{ id: 1 }] }).mainTagList, [{ id: 1 }])
|
|
14
|
-
|
|
15
|
-
const initialData = actions.setInitialData.assignment(ctx, {
|
|
16
|
-
data: {
|
|
17
|
-
home: {
|
|
18
|
-
recentlySearch: [
|
|
19
|
-
{ id: 1, i18n: 'ok' },
|
|
20
|
-
{ id: null, i18n: 'x' },
|
|
21
|
-
{ id: 2, i18n: null },
|
|
22
|
-
],
|
|
23
|
-
recentlyGame: [{ id: 'g1' }],
|
|
24
|
-
youMayLike: [{ id: 'm1' }],
|
|
25
|
-
},
|
|
26
|
-
tag: { result: [{ id: 11 }] },
|
|
27
|
-
},
|
|
28
|
-
})
|
|
29
|
-
assert.equal(initialData.recentlySearch.length, 1)
|
|
30
|
-
assert.equal(initialData.mainTagList[0].id, 11)
|
|
31
|
-
|
|
32
|
-
const mainTagCtx = { ...ctx, mainTagList: [{ id: 11 }, { id: 12 }] }
|
|
33
|
-
const mainTagSelected = actions.setMainTagId.assignment(mainTagCtx, { data: 12 })
|
|
34
|
-
assert.equal(mainTagSelected.tagIndex, 1)
|
|
35
|
-
assert.equal(mainTagSelected.click, 1)
|
|
36
|
-
assert.equal(mainTagSelected.clickDefault, null)
|
|
37
|
-
|
|
38
|
-
const setTagFromMain = actions.setTagId.assignment(mainTagCtx, { data: { tagId: 11 } })
|
|
39
|
-
assert.equal(setTagFromMain.tagIndex, 0)
|
|
40
|
-
assert.equal(setTagFromMain.clickDefault, 1)
|
|
41
|
-
|
|
42
|
-
const setTagFromSearch = actions.setTagId.assignment({ ...ctx, tagList: [{ id: 21 }, { id: 22 }] }, { data: { tagId: 22 } })
|
|
43
|
-
assert.equal(setTagFromSearch.tagIndex, 1)
|
|
44
|
-
assert.equal(setTagFromSearch.click, 1)
|
|
45
|
-
assert.equal(setTagFromSearch.clickDefault, null)
|
|
46
|
-
|
|
47
|
-
assert.deepEqual(actions.setGames.assignment(ctx, { data: { traceId: 't1', gameList: [{ gameCode: 'A' }] } }), {
|
|
48
|
-
traceId: 't1',
|
|
49
|
-
gameList: [{ gameCode: 'A' }],
|
|
50
|
-
})
|
|
51
|
-
assert.equal(actions.setKeyword.assignment(ctx, { data: { keyword: 'slot' } }).keyword, 'slot')
|
|
52
|
-
assert.equal(actions.setLang.assignment(ctx, { data: { lang: 'th-TH' } }).lang, 'th-TH')
|
|
53
|
-
assert.deepEqual(actions.setGamesByProvider.assignment(ctx, { data: { gameList: [{ id: 1 }], tagList: [{ id: 9 }] } }), {
|
|
54
|
-
tagList: [{ id: 9 }],
|
|
55
|
-
gameList: [{ id: 1 }],
|
|
56
|
-
})
|
|
57
|
-
assert.equal(actions.clearKeyword.assignment({ ...ctx, keyword: 'x' }, {}).keyword, '')
|
|
58
|
-
assert.deepEqual(actions.setTagList.assignment(ctx, { data: { tagList: [{ id: 1 }] } }), { tagList: [{ id: 1 }] })
|
|
59
|
-
|
|
60
|
-
const codeSet = actions.setGameCode.assignment({ ...ctx, gameList: [{ gameCode: 'A' }, { gameCode: 'B' }] }, { data: 'B' })
|
|
61
|
-
assert.equal(codeSet.gameCode, 'B')
|
|
62
|
-
assert.equal(codeSet.gameCodeIndex, 1)
|
|
63
|
-
|
|
64
|
-
const providerSet = actions.setProviderName.assignment(ctx, {
|
|
65
|
-
data: { providerName: 'PG', keyword: 'hot', lang: 'en-US' },
|
|
66
|
-
})
|
|
67
|
-
assert.equal(providerSet.providerName, 'PG')
|
|
68
|
-
assert.equal(providerSet.keyword, 'hot')
|
|
69
|
-
assert.equal(providerSet.lang, 'en-US')
|
|
70
|
-
|
|
71
|
-
assert.equal(guards.hasMainTags({ ...ctx, mainTagList: [1] }, {}), true)
|
|
72
|
-
assert.equal(guards.hasTagList({ ...ctx, tagList: [1] }, {}), true)
|
|
73
|
-
assert.equal(guards.isInitialized({ ...ctx, initialized: true }, {}), true)
|
|
74
|
-
assert.equal(guards.isGameTagMode(ctx, { data: { isGameTagMode: true } }), true)
|
|
75
|
-
})
|
|
76
|
-
|
|
77
|
-
test('game_search_cash services cover tags/home/list/provider/trace branches', async () => {
|
|
78
|
-
const sent = []
|
|
79
|
-
const request = {
|
|
80
|
-
send: async (req) => {
|
|
81
|
-
sent.push(req)
|
|
82
|
-
if (req.url === 'game/search/home') {
|
|
83
|
-
return {
|
|
84
|
-
recentlySearch: [{ id: 1, i18n: 'slot' }],
|
|
85
|
-
recentlyGame: [{ id: 'g1' }],
|
|
86
|
-
youMayLike: [{ id: 'm1' }],
|
|
87
|
-
}
|
|
88
|
-
}
|
|
89
|
-
if (req.url === 'game/search') {
|
|
90
|
-
return { result: [{ id: 9, i18n: 'slot' }] }
|
|
91
|
-
}
|
|
92
|
-
if (req.url === 'game/search/list') {
|
|
93
|
-
return { traceId: 'trace-1', result: [{ gameCode: 'G001' }] }
|
|
94
|
-
}
|
|
95
|
-
if (req.url === 'game/search/trace') {
|
|
96
|
-
return { ok: true, params: req.params }
|
|
97
|
-
}
|
|
98
|
-
return {}
|
|
99
|
-
},
|
|
100
|
-
}
|
|
101
|
-
|
|
102
|
-
const machine = gameSearchCashFactory(request)
|
|
103
|
-
const services = machine.options.services
|
|
104
|
-
const base = {
|
|
105
|
-
...machine.initialState.context,
|
|
106
|
-
keyword: 'slot',
|
|
107
|
-
lang: 'en-US',
|
|
108
|
-
tagId: 9,
|
|
109
|
-
tagIndex: 0,
|
|
110
|
-
click: 1,
|
|
111
|
-
clickDefault: null,
|
|
112
|
-
providerName: 'PG',
|
|
113
|
-
traceId: 'trace-1',
|
|
114
|
-
gameCode: 'G001',
|
|
115
|
-
gameCodeIndex: 0,
|
|
116
|
-
}
|
|
117
|
-
|
|
118
|
-
const tags = await services.fetchTags(base, {})
|
|
119
|
-
assert.deepEqual(tags.tagList, [{ id: 9, i18n: 'slot' }])
|
|
120
|
-
|
|
121
|
-
const initial = await services.fetchInitialData(base, {})
|
|
122
|
-
assert.equal(initial.home.recentlyGame[0].id, 'g1')
|
|
123
|
-
assert.equal(initial.tag.result[0].id, 9)
|
|
124
|
-
|
|
125
|
-
const games = await services.fetchGames(base, {})
|
|
126
|
-
assert.equal(games.traceId, 'trace-1')
|
|
127
|
-
assert.equal(games.gameList.length, 1)
|
|
128
|
-
|
|
129
|
-
const byProvider = await services.fetchGamesByProvider(base, {})
|
|
130
|
-
assert.equal(byProvider.gameList[0].gameCode, 'G001')
|
|
131
|
-
assert.equal(byProvider.tagList[0].id, 9)
|
|
132
|
-
|
|
133
|
-
const byKeyword = await services.fetchGamesByKeyword(base, {})
|
|
134
|
-
assert.equal(byKeyword.tagId, 9)
|
|
135
|
-
assert.equal(byKeyword.traceId, 'trace-1')
|
|
136
|
-
assert.equal(byKeyword.tagList[0].id, 9)
|
|
137
|
-
|
|
138
|
-
const trace = await services.sendTrace(base, {})
|
|
139
|
-
assert.equal(trace.ok, true)
|
|
140
|
-
assert.equal(trace.params.traceId, 'trace-1')
|
|
141
|
-
assert.equal(trace.params.gameCode, 'G001')
|
|
142
|
-
|
|
143
|
-
const mayLike = await services.sendMayLikeTrace(base, {})
|
|
144
|
-
assert.equal(mayLike.ok, true)
|
|
145
|
-
assert.equal(mayLike.params.isYouMayLike, true)
|
|
146
|
-
|
|
147
|
-
assert.equal(
|
|
148
|
-
sent.some((req) => req.url === 'game/search/home'),
|
|
149
|
-
true
|
|
150
|
-
)
|
|
151
|
-
assert.equal(
|
|
152
|
-
sent.some((req) => req.url === 'game/search/trace'),
|
|
153
|
-
true
|
|
154
|
-
)
|
|
155
|
-
})
|
|
156
|
-
|
|
157
|
-
test('game_search_cash fetchGamesByKeyword safely handles empty tag result', async () => {
|
|
158
|
-
const sent = []
|
|
159
|
-
const request = {
|
|
160
|
-
send: async (req) => {
|
|
161
|
-
sent.push(req)
|
|
162
|
-
if (req.url === 'game/search') {
|
|
163
|
-
return { result: [] }
|
|
164
|
-
}
|
|
165
|
-
if (req.url === 'game/search/list') {
|
|
166
|
-
return { traceId: 'unexpected', result: [{ gameCode: 'x' }] }
|
|
167
|
-
}
|
|
168
|
-
return {}
|
|
169
|
-
},
|
|
170
|
-
}
|
|
171
|
-
|
|
172
|
-
const machine = gameSearchCashFactory(request)
|
|
173
|
-
const services = machine.options.services
|
|
174
|
-
const result = await services.fetchGamesByKeyword(
|
|
175
|
-
{
|
|
176
|
-
...machine.initialState.context,
|
|
177
|
-
keyword: 'no-result',
|
|
178
|
-
lang: 'en-US',
|
|
179
|
-
click: 1,
|
|
180
|
-
clickDefault: null,
|
|
181
|
-
},
|
|
182
|
-
{}
|
|
183
|
-
)
|
|
184
|
-
|
|
185
|
-
assert.deepEqual(result, {
|
|
186
|
-
tagId: null,
|
|
187
|
-
traceId: null,
|
|
188
|
-
gameList: [],
|
|
189
|
-
tagList: [],
|
|
190
|
-
})
|
|
191
|
-
assert.equal(
|
|
192
|
-
sent.some((req) => req.url === 'game/search/list'),
|
|
193
|
-
false
|
|
194
|
-
)
|
|
195
|
-
})
|