@jetthai/cuora 2.0.0-beta.0 → 2.0.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (201) hide show
  1. package/.claude/commands/sync-ai-prompts.md +93 -0
  2. package/.claude/settings.local.json +23 -0
  3. package/.github/copilot-instructions.md +405 -0
  4. package/.husky/post-checkout +32 -0
  5. package/.husky/pre-commit +1 -3
  6. package/.husky/pre-push +36 -0
  7. package/AGENTS.md +405 -0
  8. package/AI_PROMPT_SOURCE.md +403 -0
  9. package/CHANGELOG.md +274 -3
  10. package/CLAUDE.md +405 -0
  11. package/GEMINI.md +405 -0
  12. package/README.md +299 -15
  13. package/docs/kibana/crypto-way-deposit-amount-bug-analysis.md +1003 -0
  14. package/docs/kibana/play-providerId-error.md +202 -0
  15. package/docs/kibana/play-selectedWalletType.md +1 -0
  16. package/docs/kibana/play-selectedWalletType_2.md +1 -0
  17. package/docs/kibana/play-selectedWalletType_analysis.md +565 -0
  18. package/package.json +3 -3
  19. package/scripts/auto-version.js +68 -0
  20. package/scripts/auto-version.sh +33 -0
  21. package/scripts/branch-auto-npm-publish.js +29 -0
  22. package/scripts/check-version.sh +36 -0
  23. package/scripts/clean-tags.sh +84 -0
  24. package/src/api/account.js +0 -1
  25. package/src/api/activity.js +22 -37
  26. package/src/api/auth.js +5 -36
  27. package/src/api/common.js +5 -3
  28. package/src/api/game.js +0 -10
  29. package/src/api/payment.js +17 -55
  30. package/src/api/user.js +10 -16
  31. package/src/index.js +2 -2
  32. package/src/machine/activity/activity_cash.js +84 -36
  33. package/src/machine/activity/cash_rain_activity.js +0 -1
  34. package/src/machine/activity/continue_deposit_activity.js +0 -1
  35. package/src/machine/activity/deposit_activity.js +0 -1
  36. package/src/machine/activity/diamond_shop_activity_cash.js +0 -8
  37. package/src/machine/activity/fafafa_activity.js +0 -11
  38. package/src/machine/activity/friend_invite_friends_activity.js +8 -7
  39. package/src/machine/activity/index.js +0 -12
  40. package/src/machine/activity/instant_rebate_activity.js +0 -1
  41. package/src/machine/activity/jackpot.js +0 -1
  42. package/src/machine/activity/otp_verified_activity.js +0 -1
  43. package/src/machine/activity/ranking_activity.js +0 -1
  44. package/src/machine/activity/roulette_activity_v2.js +0 -1
  45. package/src/machine/activity/sign_in_activity.js +0 -1
  46. package/src/machine/activity/sign_in_monthly_activity.js +1 -2
  47. package/src/machine/activity/specify_bets_activity.js +0 -1
  48. package/src/machine/activity/specify_turnover_activity.js +0 -1
  49. package/src/machine/activity/time_bomb_activity.js +0 -1
  50. package/src/machine/activity/vip_card_activity.js +0 -1
  51. package/src/machine/auth.js +112 -112
  52. package/src/machine/auth_otp_v3.js +11 -8
  53. package/src/machine/bank_binding.js +2 -3
  54. package/src/machine/common.js +14 -98
  55. package/src/machine/deposit/crypto_bank_cash.js +20 -35
  56. package/src/machine/deposit/crypto_qrcode_cash.js +26 -64
  57. package/src/machine/deposit/crypto_way_cash.js +48 -37
  58. package/src/machine/deposit/direct_cash.js +8 -10
  59. package/src/machine/deposit/index.js +0 -28
  60. package/src/machine/deposit/loadcard_cash.js +14 -32
  61. package/src/machine/deposit/manual_cash.js +8 -11
  62. package/src/machine/deposit/qrcode_cash.js +15 -32
  63. package/src/machine/deposit/usdt_cash.js +1 -15
  64. package/src/machine/deposit/virtual_bank_cash.js +13 -12
  65. package/src/machine/error.js +7 -1
  66. package/src/machine/game_betslip.js +0 -1
  67. package/src/machine/game_favorite_v2.js +0 -1
  68. package/src/machine/game_info.js +1 -13
  69. package/src/machine/game_search_cash.js +0 -1
  70. package/src/machine/game_v2_1.js +39 -126
  71. package/src/machine/honor_board_cash.js +8 -11
  72. package/src/machine/inbox.js +43 -105
  73. package/src/machine/index.js +0 -32
  74. package/src/machine/leaderboard.js +8 -12
  75. package/src/machine/navbar.js +1 -3
  76. package/src/machine/ranking.js +45 -30
  77. package/src/machine/reward_cash.js +0 -40
  78. package/src/machine/roulette_v2.js +14 -11
  79. package/src/machine/setting.js +0 -1
  80. package/src/machine/side_cash.js +3 -3
  81. package/src/machine/user_info.js +0 -1
  82. package/src/machine/user_photo.js +0 -1
  83. package/src/machine/user_reset_password.js +0 -14
  84. package/src/machine/user_sign_up.js +46 -61
  85. package/src/machine/websocket.js +18 -62
  86. package/src/machine/withdraw/index.js +0 -6
  87. package/src/machine/withdraw/withdraw_manual_cash.js +59 -39
  88. package/src/request/config.js +2 -0
  89. package/src/request/request.js +49 -60
  90. package/src/util/amount.js +8 -0
  91. package/src/util/constant.js +0 -1
  92. package/src/util/err998SentryExtra.js +26 -0
  93. package/src/util/index.js +2 -4
  94. package/src/util/paramStore.js +139 -0
  95. package/src/util/storage.js +3 -4
  96. package/BREAKING_CHANGES.md +0 -9
  97. package/resetGitBranch.sh +0 -101
  98. package/src/lib/fingerprint_v3_11_12.js +0 -11433
  99. package/src/machine/activity/activity.js +0 -213
  100. package/src/machine/activity/diamond_shop_activity_fc.js +0 -197
  101. package/src/machine/activity/diamond_shop_activity_vn.js +0 -179
  102. package/src/machine/activity/invite_friends_activity.js +0 -115
  103. package/src/machine/activity/mini_game_activity.js +0 -69
  104. package/src/machine/activity/return_bonus_activity.js +0 -155
  105. package/src/machine/auth_otp_v2.js +0 -178
  106. package/src/machine/bank_binding_amb.js +0 -146
  107. package/src/machine/bonus.js +0 -76
  108. package/src/machine/deposit/amb.js +0 -93
  109. package/src/machine/deposit/crypto_bank.js +0 -340
  110. package/src/machine/deposit/crypto_qrcode.js +0 -158
  111. package/src/machine/deposit/crypto_way.js +0 -253
  112. package/src/machine/deposit/deposit_fc.js +0 -272
  113. package/src/machine/deposit/direct.js +0 -311
  114. package/src/machine/deposit/float.js +0 -375
  115. package/src/machine/deposit/krway.js +0 -152
  116. package/src/machine/deposit/loadcard_vn.js +0 -352
  117. package/src/machine/deposit/manual_vn.js +0 -459
  118. package/src/machine/deposit/qrcode_v2.js +0 -339
  119. package/src/machine/deposit/usdt.js +0 -163
  120. package/src/machine/deposit/virtual_bank_vn.js +0 -270
  121. package/src/machine/deposit/vpay.js +0 -374
  122. package/src/machine/game_hot_new.js +0 -80
  123. package/src/machine/game_replay.js +0 -47
  124. package/src/machine/game_search_v2.js +0 -402
  125. package/src/machine/honor_board.js +0 -133
  126. package/src/machine/merge.js +0 -58
  127. package/src/machine/payment_data.js +0 -87
  128. package/src/machine/promotions.js +0 -163
  129. package/src/machine/reward.js +0 -256
  130. package/src/machine/reward_fc.js +0 -99
  131. package/src/machine/side.js +0 -160
  132. package/src/machine/side_v2.js +0 -223
  133. package/src/machine/vip_table.js +0 -58
  134. package/src/machine/welcome.js +0 -111
  135. package/src/machine/withdraw/withdraw_crypto_cash.js +0 -328
  136. package/src/machine/withdraw/withdraw_krway.js +0 -223
  137. package/src/machine/withdraw/withdraw_manual.js +0 -541
  138. package/src/util/deviceToken.js +0 -60
  139. package/src/util/math.js +0 -4
  140. package/test/api.behavior.test.js +0 -69
  141. package/test/api.contract.test.js +0 -18
  142. package/test/config.test.js +0 -27
  143. package/test/deviceToken.test.js +0 -139
  144. package/test/helpers.coverage.test.js +0 -11
  145. package/test/helpers.js +0 -91
  146. package/test/index.exports.test.js +0 -14
  147. package/test/machine.activity.core.coverage.test.js +0 -337
  148. package/test/machine.activity.gap.coverage.test.js +0 -252
  149. package/test/machine.activity.more.coverage.test.js +0 -180
  150. package/test/machine.activity_plus_and_binding_amb.coverage.test.js +0 -201
  151. package/test/machine.activity_timer_bonus.coverage.test.js +0 -136
  152. package/test/machine.activity_welcome.low.coverage.test.js +0 -211
  153. package/test/machine.amb_rewardfc_websocket.more.coverage.test.js +0 -201
  154. package/test/machine.auth.coverage.test.js +0 -215
  155. package/test/machine.bank_binding.test.js +0 -143
  156. package/test/machine.binding_otp_krway.coverage.test.js +0 -223
  157. package/test/machine.contract.test.js +0 -50
  158. package/test/machine.crypto_bank.coverage.test.js +0 -270
  159. package/test/machine.crypto_way.coverage.test.js +0 -108
  160. package/test/machine.crypto_way_cash.coverage.test.js +0 -114
  161. package/test/machine.definition.test.js +0 -137
  162. package/test/machine.deposit.manual.coverage.test.js +0 -365
  163. package/test/machine.deposit_fc.coverage.test.js +0 -126
  164. package/test/machine.direct.coverage.test.js +0 -96
  165. package/test/machine.direct_cash.coverage.test.js +0 -108
  166. package/test/machine.error.coverage.test.js +0 -37
  167. package/test/machine.events.test.js +0 -126
  168. package/test/machine.favorite_jackpot.coverage.test.js +0 -82
  169. package/test/machine.float.coverage.test.js +0 -136
  170. package/test/machine.flow.test.js +0 -226
  171. package/test/machine.game_hot_new_vip_table.coverage.test.js +0 -105
  172. package/test/machine.game_search_cash.coverage.test.js +0 -155
  173. package/test/machine.game_search_v2.test.js +0 -199
  174. package/test/machine.game_user_profile.coverage.test.js +0 -100
  175. package/test/machine.honor_board.test.js +0 -133
  176. package/test/machine.inbox.common.coverage.test.js +0 -304
  177. package/test/machine.loadcard_cash.coverage.test.js +0 -101
  178. package/test/machine.loadcard_vn.coverage.test.js +0 -122
  179. package/test/machine.misc.coverage.test.js +0 -361
  180. package/test/machine.more2.coverage.test.js +0 -261
  181. package/test/machine.options.execution.test.js +0 -272
  182. package/test/machine.priority.coverage.test.js +0 -603
  183. package/test/machine.qrcode_cash.coverage.test.js +0 -107
  184. package/test/machine.qrcode_v2.coverage.test.js +0 -121
  185. package/test/machine.regression.test.js +0 -82
  186. package/test/machine.roulette_v2.test.js +0 -142
  187. package/test/machine.side_reward_reset.coverage.test.js +0 -220
  188. package/test/machine.targeted.coverage.test.js +0 -313
  189. package/test/machine.usdt.coverage.test.js +0 -95
  190. package/test/machine.usdt_cash.coverage.test.js +0 -73
  191. package/test/machine.vip_card_activity.test.js +0 -114
  192. package/test/machine.virtual_bank_cash.coverage.test.js +0 -105
  193. package/test/machine.virtual_bank_vn.coverage.test.js +0 -105
  194. package/test/machine.vpay.coverage.test.js +0 -142
  195. package/test/machine.withdraw_crypto_cash.coverage.test.js +0 -166
  196. package/test/machine.withdraw_krway.coverage.test.js +0 -123
  197. package/test/machine.withdraw_manual.coverage.test.js +0 -185
  198. package/test/machine.withdraw_manual_cash.coverage.test.js +0 -123
  199. package/test/request.test.js +0 -325
  200. package/test/util.storage.errors.test.js +0 -47
  201. 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,155 +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
- })
@@ -1,199 +0,0 @@
1
- import test from 'node:test'
2
- import assert from 'node:assert/strict'
3
-
4
- import gameSearchV2Factory from '../src/machine/game_search_v2.js'
5
-
6
- test('game_search_v2 actions and guards cover keyword/tag/game routing branches', () => {
7
- const machine = gameSearchV2Factory({
8
- send: async () => ({}),
9
- })
10
-
11
- const actions = machine.options.actions
12
- const guards = machine.options.guards
13
- const base = machine.initialState.context
14
-
15
- const mainTagList = [{ id: 'm1' }, { id: 'm2' }]
16
- const tagList = [{ id: 't1' }, { id: 't2' }]
17
- const recentlySearch = [{ id: 'r1' }, { id: 'r2' }]
18
-
19
- assert.deepEqual(actions.setMainTagList.assignment(base, { data: mainTagList }), { mainTagList })
20
-
21
- const initialByRecent = actions.setInitialData.assignment(base, {
22
- data: {
23
- recentlySearch: [
24
- { id: 'a', i18n: 'A' },
25
- { id: null, i18n: 'B' },
26
- { id: 'c', i18n: null },
27
- ],
28
- recentlyGame: [{ gameCode: 'g1' }],
29
- youMayLike: [{ gameCode: 'g2' }],
30
- },
31
- })
32
- assert.deepEqual(initialByRecent.recentlySearch, [{ id: 'a', i18n: 'A' }])
33
- assert.deepEqual(initialByRecent.gameList, [{ gameCode: 'g1' }])
34
-
35
- const initialByLike = actions.setInitialData.assignment(base, {
36
- data: {
37
- recentlySearch: [],
38
- recentlyGame: [],
39
- youMayLike: [{ gameCode: 'g3' }],
40
- },
41
- })
42
- assert.deepEqual(initialByLike.gameList, [{ gameCode: 'g3' }])
43
-
44
- const setMainTagId = actions.setMainTagId.assignment({ ...base, mainTagList }, { data: { tagId: 'm2' } })
45
- assert.equal(setMainTagId.tagIndex, 1)
46
- assert.equal(setMainTagId.click, 1)
47
-
48
- assert.deepEqual(actions.clearMainTag.assignment(base, {}), { tagId: null })
49
-
50
- const setTagIdRecent = actions.setTagId.assignment(
51
- { ...base, mainTagList, tagList, recentlySearch },
52
- { data: { tagId: 'r2', clickTagType: 'RECENTLY SEARCH' } }
53
- )
54
- assert.equal(setTagIdRecent.tagIndex, 1)
55
- assert.equal(setTagIdRecent.click, 1)
56
-
57
- const setTagIdPopular = actions.setTagId.assignment(
58
- { ...base, mainTagList, tagList, recentlySearch },
59
- { data: { tagId: 'm1', clickTagType: 'POPULAR KEYWORDS' } }
60
- )
61
- assert.equal(setTagIdPopular.tagIndex, 0)
62
- assert.equal(setTagIdPopular.clickDefault, 1)
63
-
64
- const setTagIdPopularByEmptyTagList = actions.setTagId.assignment(
65
- { ...base, mainTagList, tagList: [], recentlySearch },
66
- { data: { tagId: 'm2', clickTagType: 'OTHER' } }
67
- )
68
- assert.equal(setTagIdPopularByEmptyTagList.tagIndex, 1)
69
- assert.equal(setTagIdPopularByEmptyTagList.clickDefault, 1)
70
-
71
- const setTagIdNormal = actions.setTagId.assignment(
72
- { ...base, mainTagList, tagList, recentlySearch },
73
- { data: { tagId: 't2', clickTagType: 'OTHER' } }
74
- )
75
- assert.equal(setTagIdNormal.tagIndex, 1)
76
- assert.equal(setTagIdNormal.click, 1)
77
-
78
- assert.deepEqual(actions.setGames.assignment(base, { data: { traceId: 'tr1', result: [{ id: 1 }] } }), {
79
- traceId: 'tr1',
80
- gameList: [{ id: 1 }],
81
- })
82
- assert.deepEqual(actions.setGames.assignment({ ...base, tagId: 'Recently', recentlyGame: [{ id: 'rg' }] }, {}), {
83
- traceId: null,
84
- gameList: [{ id: 'rg' }],
85
- })
86
- assert.deepEqual(actions.setGames.assignment({ ...base, tagId: 'You may like', youMayLike: [{ id: 'yl' }] }, {}), {
87
- traceId: null,
88
- gameList: [{ id: 'yl' }],
89
- })
90
-
91
- assert.deepEqual(
92
- actions.setTraceData.assignment(base, {
93
- data: { traceData: { isYouMayLike: true, isRecentlyGame: false, isRecentlySearch: true } },
94
- }),
95
- { isYouMayLike: true, isRecentlyGame: false, isRecentlySearch: true }
96
- )
97
- assert.deepEqual(actions.setKeyword.assignment(base, { data: { keyword: 'slot' } }), { keyword: 'slot' })
98
- assert.deepEqual(actions.setLang.assignment(base, { data: { lang: 'th-TH' } }), { lang: 'th-TH' })
99
- assert.deepEqual(actions.clearKeywords.assignment(base, {}), { keyword: '' })
100
- assert.deepEqual(actions.setTagList.assignment(base, { data: tagList }), { tagList })
101
-
102
- const setGameCode = actions.setGameCode.assignment({ ...base, gameList: [{ gameCode: 'G1' }, { gameCode: 'G2' }] }, { data: 'G2' })
103
- assert.equal(setGameCode.gameCode, 'G2')
104
- assert.equal(setGameCode.gameCodeIndex, 1)
105
-
106
- const clearExceptKeyword = actions.clearExceptKeyword.assignment({ ...base, keyword: 'fish', gameList: [{ id: 1 }], traceId: 't' }, {})
107
- assert.equal(clearExceptKeyword.query, 'fish')
108
- assert.deepEqual(clearExceptKeyword.gameList, [])
109
- assert.equal(clearExceptKeyword.tagId, null)
110
-
111
- assert.equal(guards.isRecentlyYouMayLike({ tagId: 'Recently' }, {}), true)
112
- assert.equal(guards.isRecentlyYouMayLike({ tagId: 'You may like' }, {}), true)
113
- assert.equal(guards.isRecentlyYouMayLike({ tagId: 'Other' }, {}), false)
114
- assert.equal(guards.hasTagList({ tagList: [{ id: 1 }] }, {}), true)
115
- assert.equal(guards.hasTagList({ tagList: [] }, {}), false)
116
-
117
- const pressEnterSend = machine.config.states.searching.states.searchIdle.on.PRESS_ENTER[0].actions
118
- const sendEvent = pressEnterSend.event({ ...base, tagList: [{ id: 'top-tag' }] }, {})
119
- assert.equal(sendEvent.type, 'SET_TAG_ID')
120
- assert.equal(sendEvent.data.tagId, 'top-tag')
121
- assert.deepEqual(sendEvent.data.traceData, {
122
- isYouMayLike: false,
123
- isRecentlyGame: false,
124
- isRecentlySearch: false,
125
- })
126
- })
127
-
128
- test('game_search_v2 services call expected endpoints and normalize sendTrace id', async () => {
129
- const calls = []
130
- const request = {
131
- send: async (req) => {
132
- calls.push(req)
133
- if (req.url === 'game/search') {
134
- return { result: [{ id: 'tag-1' }] }
135
- }
136
- if (req.url === 'game/search/home') {
137
- return { recentlySearch: [], recentlyGame: [], youMayLike: [] }
138
- }
139
- if (req.url === 'game/search/list') {
140
- return { traceId: 'TRACE-1', result: [{ gameCode: 'GG' }] }
141
- }
142
- if (req.url === 'game/search/trace') {
143
- return { ok: true, params: req.params }
144
- }
145
- return {}
146
- },
147
- }
148
- const machine = gameSearchV2Factory(request)
149
- const services = machine.options.services
150
-
151
- const tags = await services.fetchTags({ keyword: 'slot', lang: 'en-US' }, {})
152
- assert.deepEqual(tags, [{ id: 'tag-1' }])
153
-
154
- const home = await services.fetchInitialData({}, {})
155
- assert.deepEqual(home, { recentlySearch: [], recentlyGame: [], youMayLike: [] })
156
-
157
- const games = await services.fetchGames({ tagId: 'm1', tagIndex: 2, keyword: 'jackpot', click: 1, clickDefault: null }, {})
158
- assert.deepEqual(games, { traceId: 'TRACE-1', result: [{ gameCode: 'GG' }] })
159
-
160
- const traceNormal = await services.sendTrace(
161
- {
162
- traceId: 'T1',
163
- tagId: 'm1',
164
- tagIndex: 0,
165
- gameCode: 'G1',
166
- gameCodeIndex: 1,
167
- keyword: 'aaa',
168
- click: 1,
169
- clickDefault: null,
170
- isYouMayLike: false,
171
- isRecentlyGame: false,
172
- isRecentlySearch: false,
173
- },
174
- {}
175
- )
176
- assert.equal(traceNormal.ok, true)
177
-
178
- const traceSpecial = await services.sendTrace(
179
- {
180
- traceId: 'T2',
181
- tagId: 'Recently',
182
- tagIndex: 0,
183
- gameCode: 'G2',
184
- gameCodeIndex: 2,
185
- keyword: 'bbb',
186
- click: 1,
187
- clickDefault: null,
188
- isYouMayLike: true,
189
- isRecentlyGame: true,
190
- isRecentlySearch: true,
191
- },
192
- {}
193
- )
194
- assert.equal(traceSpecial.params.tagId, null)
195
- assert.equal(
196
- calls.some((req) => req.url === 'game/search/trace'),
197
- true
198
- )
199
- })