@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.
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 -113
  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 -112
  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 +18 -28
  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 +2 -13
  70. package/src/machine/game_v2_1.js +42 -166
  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 -463
  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 -91
  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 -144
  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 -195
  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 -148
  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 -629
  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,629 +0,0 @@
1
- import test from 'node:test'
2
- import assert from 'node:assert/strict'
3
-
4
- import userSignUpFactory from '../src/machine/user_sign_up.js'
5
- import gameV21Factory from '../src/machine/game_v2_1.js'
6
- import withdrawManualFactory from '../src/machine/withdraw/withdraw_manual.js'
7
- import storage from '../src/util/storage.js'
8
- import { GAME_SEARCH } from '../src/util/constant.js'
9
- import { createLocalStorageMock } from './helpers.js'
10
-
11
- test('user_sign_up actions: phone/email payload mapping and device token toggle', () => {
12
- const request = {
13
- config: {
14
- fpToken: 'fp',
15
- sentry: { captureMessage: () => {}, captureException: () => {}, setTag: () => {} },
16
- defaultChannel: 'default-channel',
17
- defaultSubchannel: 'default-sub',
18
- },
19
- send: async () => ({ data: {} }),
20
- }
21
- const machine = userSignUpFactory(request)
22
-
23
- const setSignUpPhone = machine.options.actions.setSignUpPhone.assignment
24
- const setSignUpEmail = machine.options.actions.setSignUpEmail.assignment
25
- const setDeviceTokenEnable = machine.options.actions.setDeviceTokenEnable.assignment
26
-
27
- const phoneResult = setSignUpPhone(machine.initialState.context, {
28
- data: {
29
- email: 'p@example.com',
30
- countryCode: '66',
31
- phone: '0800000000',
32
- nick_name: 'P',
33
- password: 'pw',
34
- channel: 'ch',
35
- subchannel: 'sub',
36
- affiliateCode: 'AFF',
37
- },
38
- })
39
- assert.equal(phoneResult.signUpData.provider, 'phone')
40
- assert.equal(phoneResult.signUpData.phone, '0800000000')
41
- assert.equal(phoneResult.channel, 'ch')
42
-
43
- const emailResult = setSignUpEmail(machine.initialState.context, {
44
- data: {
45
- email: 'e@example.com',
46
- nick_name: 'E',
47
- password: 'pw',
48
- channel: 'ch2',
49
- subchannel: 'sub2',
50
- countryCode: '66',
51
- phone: '0811111111',
52
- },
53
- })
54
- assert.equal(emailResult.signUpData.provider, 'email')
55
- assert.equal(emailResult.signUpData.countryCode, '66')
56
- assert.equal(emailResult.subchannel, 'sub2')
57
-
58
- const toggle = setDeviceTokenEnable(machine.initialState.context, { data: false })
59
- assert.equal(toggle.deviceTokenEnable, false)
60
- })
61
-
62
- test('user_sign_up authenticate fallback: no ac and no storage channel uses default config', async () => {
63
- global.localStorage = createLocalStorageMock()
64
- global.window = { location: { href: 'https://example.com/reg' } }
65
-
66
- const sentryMessages = []
67
- let lastReq = null
68
- const request = {
69
- config: {
70
- fpToken: 'fp',
71
- sentry: {
72
- captureMessage: (msg) => sentryMessages.push(msg),
73
- captureException: () => {},
74
- setTag: () => {},
75
- },
76
- defaultChannel: 'default-channel',
77
- defaultSubchannel: 'default-sub',
78
- },
79
- hosts: [],
80
- send: async (req) => {
81
- lastReq = req
82
- return { data: {} }
83
- },
84
- }
85
- const machine = userSignUpFactory(request)
86
- const authenticate = machine.options.services.authenticate
87
-
88
- await authenticate(
89
- {
90
- ...machine.initialState.context,
91
- signUpData: {
92
- provider: 'local',
93
- username: 'a',
94
- password: 'b',
95
- affiliateCode: null,
96
- },
97
- channel: null,
98
- subchannel: null,
99
- fc: null,
100
- reCaptchaToken: 'captcha',
101
- deviceTokenEnable: false,
102
- },
103
- {}
104
- )
105
-
106
- assert.equal(lastReq.url.includes('channel=default-channel'), true)
107
- assert.equal(lastReq.url.includes('subchannel=default-sub'), true)
108
- assert.equal(lastReq.url.includes('ac='), false)
109
- assert.equal(sentryMessages.length > 0, true)
110
- })
111
-
112
- test('user_sign_up authenticate uses context channel/subchannel when defaults are absent', async () => {
113
- global.localStorage = createLocalStorageMock()
114
- global.window = { location: { href: 'https://example.com/reg2' } }
115
-
116
- let lastReq = null
117
- const request = {
118
- config: {
119
- fpToken: 'fp',
120
- sentry: {
121
- captureMessage: () => {},
122
- captureException: () => {},
123
- setTag: () => {},
124
- },
125
- defaultChannel: null,
126
- defaultSubchannel: null,
127
- },
128
- hosts: [],
129
- send: async (req) => {
130
- lastReq = req
131
- return { data: {} }
132
- },
133
- }
134
- const machine = userSignUpFactory(request)
135
- const authenticate = machine.options.services.authenticate
136
-
137
- await authenticate(
138
- {
139
- ...machine.initialState.context,
140
- signUpData: { provider: 'local', username: 'a', password: 'b', affiliateCode: 'undefined' },
141
- channel: 'ctx-channel',
142
- subchannel: 'ctx-sub',
143
- reCaptchaToken: 'captcha',
144
- deviceTokenEnable: false,
145
- },
146
- {}
147
- )
148
-
149
- assert.equal(lastReq.url.includes('channel=ctx-channel'), true)
150
- assert.equal(lastReq.url.includes('subchannel=ctx-sub'), true)
151
- assert.equal(lastReq.url.includes('ac='), false)
152
- })
153
-
154
- test('game_v2_1 actions: append/swap/url/info/flags branches', () => {
155
- const request = {
156
- config: { appSecret: 'secret' },
157
- send: async () => ({}),
158
- getToken: () => null,
159
- }
160
- const machine = gameV21Factory(request)
161
- const actions = machine.options.actions
162
- const guards = machine.options.guards
163
-
164
- const baseContext = {
165
- ...machine.initialState.context,
166
- content: { data: [{ id: 1 }], timestamp: 1, totalPage: 5 },
167
- addition: { data: [{ id: 'a' }], timestamp: 1, totalPage: 5 },
168
- }
169
-
170
- const reset = actions.resetContent.assignment(baseContext, {})
171
- assert.equal(reset.index, -1)
172
- assert.deepEqual(reset.content.data, [])
173
- assert.deepEqual(actions.setStaticData.assignment(baseContext, { data: [{ id: 's1', category: 3 }] }), {
174
- staticData: [{ id: 's1', category: 3 }],
175
- staticInfoByCategory: { 3: [] },
176
- })
177
- assert.deepEqual(actions.setAdditionEnable.assignment(baseContext, { data: true }), { additionEnable: true })
178
- assert.deepEqual(actions.setLoadable.assignment(baseContext, { data: true }), { loadable: true })
179
- assert.equal(actions.increaseIndex.assignment({ ...baseContext, index: 3 }, {}).index, 4)
180
- assert.deepEqual(actions.resetSHA.assignment(baseContext, {}), {})
181
- assert.equal(actions.setLastPage.assignment({ ...baseContext, index: 4, content: { totalPage: 5 } }, {}).isLastPage, true)
182
- assert.deepEqual(actions.setRoom.assignment(baseContext, { data: { categoryId: 7 } }), { room: { categoryId: 7 } })
183
- assert.deepEqual(actions.setBatch.assignment(baseContext, { data: [{ id: 1 }] }), { batch: [{ id: 1 }] })
184
-
185
- const searchAppend = actions.appendContent.assignment(
186
- { ...baseContext, room: { categoryId: GAME_SEARCH }, additionEnable: false },
187
- { data: [{ data: [{ id: 2 }] }] }
188
- )
189
- assert.equal(searchAppend, undefined)
190
-
191
- const appendWithAddition = actions.appendContent.assignment(
192
- { ...baseContext, room: { categoryId: 1 }, additionEnable: true },
193
- { data: [{ data: [{ id: 2 }] }, { data: [{ id: 'b' }] }] }
194
- )
195
- assert.equal(appendWithAddition.content.data.length, 2)
196
- assert.equal(appendWithAddition.addition.data.length, 2)
197
- const appendWithAdditionFallback = actions.appendContent.assignment(
198
- { ...baseContext, room: { categoryId: 1 }, additionEnable: true },
199
- { data: [{ data: [{ id: 3 }] }, {}] }
200
- )
201
- assert.equal(appendWithAdditionFallback.addition.data.length, 1)
202
-
203
- const appendNormal = actions.appendContent.assignment(
204
- { ...baseContext, room: { categoryId: 1 }, additionEnable: false },
205
- { data: [{ data: [{ id: 2 }] }] }
206
- )
207
- assert.equal(appendNormal.content.data.length, 2)
208
- const appendNormalFallback = actions.appendContent.assignment({ ...baseContext, room: { categoryId: 1 }, additionEnable: false }, { data: [{}] })
209
- assert.equal(appendNormalFallback.content.data.length, 1)
210
- const appendWithoutRoom = actions.appendContent.assignment({ ...baseContext, room: null, additionEnable: false }, { data: [{ data: [{ id: 2 }] }] })
211
- assert.equal(appendWithoutRoom.content.data.length, 2)
212
-
213
- const swapped = actions.swapContent.assignment(baseContext, {
214
- data: [{ data: [{ id: 10 }] }, { data: [{ id: 11 }] }],
215
- })
216
- assert.equal(swapped.content.data.length, 1)
217
- assert.equal(swapped.addition.data.length, 1)
218
-
219
- const gameInfo = actions.setGameInfo.assignment(baseContext, {
220
- data: {
221
- game: {
222
- providerId: 'P1',
223
- gameId: 'G1',
224
- gameTypeId: 'GT1',
225
- mappingId: 'M1',
226
- portrait: true,
227
- gameCode: 'CODE',
228
- name: 'Name',
229
- gameName: 'Game Name',
230
- },
231
- },
232
- })
233
- assert.equal(gameInfo.game.portrait, 1)
234
- const gameInfoLandscape = actions.setGameInfo.assignment(baseContext, {
235
- data: {
236
- game: {
237
- providerId: 'P1',
238
- gameId: 'G1',
239
- gameTypeId: 'GT1',
240
- mappingId: 'M1',
241
- portrait: false,
242
- gameCode: 'CODE',
243
- name: 'Name',
244
- gameName: 'Game Name',
245
- },
246
- },
247
- })
248
- assert.equal(gameInfoLandscape.game.portrait, 0)
249
-
250
- const urlState = actions.setGameURL.assignment.type(baseContext, { data: { type: 'redirect' } })
251
- assert.equal(urlState, 'redirect')
252
- assert.equal(actions.setGameURL.assignment.gameToken(baseContext, { data: { gameToken: 'GT' } }), 'GT')
253
- assert.equal(actions.setGameURL.assignment.gameHtml(baseContext, { data: { gameHtml: '<html/>' } }), '<html/>')
254
- assert.equal(actions.setGameURL.assignment.gameURL(baseContext, { data: { gameURL: 'https://game.url' } }), 'https://game.url')
255
- assert.equal(actions.setGameURL.assignment.gameWalletType(baseContext, { data: { gameWalletType: 'main' } }), 'main')
256
- assert.deepEqual(actions.setSwitch.assignment(baseContext, { data: { game: { providerId: 'P2' } } }), { switchGame: { providerId: 'P2' } })
257
- assert.equal(actions.setSwitchGameInfo.assignment({ ...baseContext, switchGame: { providerId: 'P3', gameId: 'G3' } }, {}).game.providerId, 'P3')
258
- assert.equal(
259
- actions.setSwitchGameInfo.assignment({ ...baseContext, switchGame: { providerId: 'P4', gameId: 'G4', portrait: true } }, {}).game.portrait,
260
- 1
261
- )
262
- assert.equal(actions.setWalletType.assignment(baseContext, { data: { walletType: 'main' } }).walletType, 'main')
263
- assert.equal(actions.setPageLoadingDone.assignment(baseContext, {}).pageLoading, true)
264
- assert.equal(actions.setPageLoading.assignment(baseContext, {}).pageLoading, false)
265
- assert.equal(actions.setLang.assignment(baseContext, { data: { locale: 'th-TH' } }).lang, 'th_TH')
266
- assert.equal(actions.setLang.assignment(baseContext, { data: {} }).lang, 'en_US')
267
- assert.equal(actions.setSite.assignment(baseContext, { data: { site: 'MY' } }).site, 'MY')
268
- assert.equal(actions.setSite.assignment(baseContext, { data: {} }).site, undefined)
269
- assert.equal(actions.setGameURL.assignment.type(baseContext, { data: undefined }), undefined)
270
- assert.equal(actions.setGameDemoStatus.assignment(baseContext, { data: { isDemo: true } }).game.isDemo, true)
271
- assert.equal(guards.isDifferentRoom({ ...baseContext, room: { categoryId: 1 } }, { data: { categoryId: 2 } }), true)
272
- assert.equal(guards.isDifferentRoom({ ...baseContext, room: { categoryId: 1 } }, { data: { categoryId: 1 } }), false)
273
- assert.equal(guards.hasNext({ ...baseContext, loadable: true, isLastPage: false }, {}), true)
274
- assert.equal(guards.hasNext({ ...baseContext, loadable: false, isLastPage: false }, {}), false)
275
- assert.equal(guards.hasRoomAndIsNotInGame({ ...baseContext, room: { categoryId: 1 }, isPlaying: false }, {}), true)
276
- assert.equal(guards.hasRoomAndIsNotInGame({ ...baseContext, room: { categoryId: 1 }, isPlaying: true }, {}), false)
277
- })
278
-
279
- test('game_v2_1 services: batch/page/update/connect/demo/disconnect branches', async () => {
280
- global.window = {
281
- location: { href: 'https://example.com/path?x=1', origin: 'https://example.com' },
282
- }
283
-
284
- let hasToken = false
285
- const sent = []
286
- const request = {
287
- config: { appSecret: 'secret' },
288
- getToken: () => (hasToken ? 'token' : null),
289
- send: async (req) => {
290
- sent.push(req)
291
- if (req.url?.includes('game/play')) {
292
- return { type: 'redirect', redirect_url: 'https://game.url', gameToken: 'GT', gameHtml: '<html/>', wallet_type: 'main' }
293
- }
294
- if (req.url?.includes('game/demo')) {
295
- return { type: 'html', redirect_url: '', gameToken: 'DG', gameHtml: '<demo/>', is_demo: true }
296
- }
297
- if (req.url?.includes('getListCategory') || req.url?.includes('getListCategoryByRange')) {
298
- return { data: [{ isGame: true, id: 1 }] }
299
- }
300
- if (req.url?.includes('getListAddition') || req.url?.includes('getListAdditionByRange')) {
301
- return { data: [{ id: 'addition' }] }
302
- }
303
- return { data: [] }
304
- },
305
- }
306
-
307
- const machine = gameV21Factory(request)
308
- const services = machine.options.services
309
-
310
- const staticData = [
311
- {
312
- category: 1,
313
- info: [
314
- { isGame: true, id: 1 },
315
- { isGame: false, id: 2 },
316
- ],
317
- },
318
- ]
319
- const batchNoToken = await services.batchFetch(
320
- {
321
- ...machine.initialState.context,
322
- room: { categoryId: 1 },
323
- index: 0,
324
- additionEnable: false,
325
- staticData,
326
- },
327
- { data: { list: [{ id: 1, i18n: 'slot' }] } }
328
- )
329
- assert.equal(batchNoToken.length, 1)
330
- const batchNoTokenWithoutStaticData = await services.batchFetch(
331
- {
332
- ...machine.initialState.context,
333
- room: { categoryId: 1 },
334
- index: 0,
335
- additionEnable: false,
336
- staticData: undefined,
337
- },
338
- { data: { list: [{ id: 1, i18n: 'slot' }] } }
339
- )
340
- assert.equal(batchNoTokenWithoutStaticData.length, 0)
341
- const batchNoTokenUnknownCategory = await services.batchFetch(
342
- {
343
- ...machine.initialState.context,
344
- room: { categoryId: 999 },
345
- index: 0,
346
- additionEnable: false,
347
- staticData,
348
- },
349
- { data: { list: [{ id: 999, i18n: 'unknown' }] } }
350
- )
351
- assert.equal(batchNoTokenUnknownCategory.length, 0)
352
- const staticGamesOverLimit = Array.from({ length: 30 }, (_, idx) => ({ isGame: true, id: idx + 1 }))
353
- const batchNoTokenStopsAtTwenty = await services.batchFetch(
354
- {
355
- ...machine.initialState.context,
356
- room: { categoryId: 2 },
357
- index: 0,
358
- additionEnable: false,
359
- staticData: [{ category: 2, info: staticGamesOverLimit }],
360
- },
361
- { data: { list: [{ id: 2, i18n: 'slot-over-limit' }] } }
362
- )
363
- assert.equal(batchNoTokenStopsAtTwenty[0].downLine.length, 20)
364
-
365
- hasToken = true
366
- const batchWithToken = await services.batchFetch(
367
- {
368
- ...machine.initialState.context,
369
- room: { categoryId: 1 },
370
- index: 0,
371
- additionEnable: true,
372
- staticData: [],
373
- },
374
- {
375
- data: {
376
- list: [
377
- { id: 1, i18n: 'slot' },
378
- { id: null, i18n: 'invalid' },
379
- ],
380
- },
381
- }
382
- )
383
- assert.equal(Array.isArray(batchWithToken), true)
384
- const batchWithTokenAdditionNoRoom = await services.batchFetch(
385
- {
386
- ...machine.initialState.context,
387
- room: null,
388
- index: 0,
389
- additionEnable: true,
390
- staticData: [],
391
- },
392
- { data: { list: [{ id: 1, i18n: 'slot' }] } }
393
- )
394
- assert.equal(Array.isArray(batchWithTokenAdditionNoRoom), true)
395
- const batchWithTokenNoAddition = await services.batchFetch(
396
- {
397
- ...machine.initialState.context,
398
- room: { categoryId: 1 },
399
- index: 0,
400
- additionEnable: false,
401
- staticData: [],
402
- },
403
- {
404
- data: {
405
- list: [
406
- { id: 1, i18n: 'slot' },
407
- { id: null, i18n: 'invalid' },
408
- ],
409
- },
410
- }
411
- )
412
- assert.equal(Array.isArray(batchWithTokenNoAddition), true)
413
-
414
- const noRoomPage = await services.getPageContent({ ...machine.initialState.context, room: null }, {})
415
- assert.equal(noRoomPage[0].totalPage, 0)
416
-
417
- const searchPage = await services.getPageContent({ ...machine.initialState.context, room: { categoryId: GAME_SEARCH }, index: 0 }, {})
418
- assert.equal(searchPage, undefined)
419
-
420
- hasToken = false
421
- const staticPage = await services.getPageContent({ ...machine.initialState.context, room: { categoryId: 1 }, index: 0, staticData }, {})
422
- assert.equal(staticPage[0].data.length, 2)
423
- const staticPageByCachedMap = await services.getPageContent(
424
- {
425
- ...machine.initialState.context,
426
- room: { categoryId: 1 },
427
- index: 0,
428
- staticInfoByCategory: { 1: [{ isGame: true, id: 777 }] },
429
- staticData: [],
430
- },
431
- {}
432
- )
433
- assert.equal(staticPageByCachedMap[0].data[0].id, 777)
434
-
435
- hasToken = true
436
- const dynamicPage = await services.getPageContent({ ...machine.initialState.context, room: { categoryId: 1 }, index: 0, additionEnable: true }, {})
437
- assert.equal(dynamicPage.length, 2)
438
- const dynamicPageNoAddition = await services.getPageContent(
439
- { ...machine.initialState.context, room: { categoryId: 1 }, index: 0, additionEnable: false },
440
- {}
441
- )
442
- assert.equal(dynamicPageNoAddition.length, 1)
443
-
444
- const noRoomUpdate = await services.updatePageContent({ ...machine.initialState.context, room: null }, {})
445
- assert.deepEqual(noRoomUpdate, [])
446
-
447
- const searchUpdate = await services.updatePageContent({ ...machine.initialState.context, room: { categoryId: GAME_SEARCH } }, {})
448
- assert.deepEqual(searchUpdate, [])
449
-
450
- hasToken = false
451
- const noTokenUpdate = await services.updatePageContent({ ...machine.initialState.context, room: { categoryId: 1 } }, {})
452
- assert.deepEqual(noTokenUpdate, [])
453
-
454
- hasToken = true
455
- const tokenUpdate = await services.updatePageContent(
456
- { ...machine.initialState.context, room: { categoryId: 1 }, content: { timestamp: 1 }, index: 1, additionEnable: true },
457
- {}
458
- )
459
- assert.equal(tokenUpdate.length, 2)
460
- const tokenUpdateNoAddition = await services.updatePageContent(
461
- { ...machine.initialState.context, room: { categoryId: 1 }, content: { timestamp: 1 }, index: 1, additionEnable: false },
462
- {}
463
- )
464
- assert.equal(tokenUpdateNoAddition.length, 1)
465
-
466
- const noGameConnect = await services.connectGame({ ...machine.initialState.context, game: { providerId: null, gameId: null } }, {})
467
- assert.equal(noGameConnect, undefined)
468
-
469
- const connectResult = await services.connectGame(
470
- {
471
- ...machine.initialState.context,
472
- base: '/',
473
- lang: 'en_US',
474
- isMobile: 'mobile',
475
- walletType: 'main',
476
- game: { providerId: 'PG', gameId: 'G1', gameTypeId: 'GT1', mappingId: 'M1' },
477
- },
478
- {}
479
- )
480
- assert.equal(connectResult.gameToken, 'GT')
481
- const connectResultNonReturnProvider = await services.connectGame(
482
- {
483
- ...machine.initialState.context,
484
- base: '/',
485
- lang: 'en_US',
486
- isMobile: 'desktop',
487
- walletType: 'main',
488
- game: { providerId: 'XYZ', gameId: 'G2', gameTypeId: 'GT2', mappingId: 'M2' },
489
- },
490
- {}
491
- )
492
- assert.equal(connectResultNonReturnProvider.gameURL, 'https://game.url')
493
-
494
- const demoResult = await services.demoGame(
495
- {
496
- ...machine.initialState.context,
497
- site: 'MY',
498
- lang: 'th_TH',
499
- isMobile: 'desktop',
500
- game: { providerId: 'PG', gameId: 'G1', gameTypeId: 'GT1', mappingId: 'M1', isDemo: false },
501
- },
502
- {}
503
- )
504
- assert.equal(demoResult.isDemo, true)
505
-
506
- await services.disconnectGame({ ...machine.initialState.context, game: { providerId: 'PG' } }, { data: 'uid-site' })
507
- assert.equal(
508
- sent.some((req) => req.url?.includes('game/logout')),
509
- true
510
- )
511
- })
512
-
513
- test('withdraw_manual actions/guards/services cover major branches', async () => {
514
- const sent = []
515
- const request = {
516
- config: { appSecret: 'secret' },
517
- send: async (req) => {
518
- sent.push(req)
519
- if (req.url?.includes('getBindingPaymentList')) return { bankList: [] }
520
- if (req.url?.includes('getBindingPaymentInfo')) return { bankList: [] }
521
- if (req.url?.includes('getPaymentDetail')) return [{ method: 'manual' }]
522
- if (req.url?.includes('getDoubleWalletWithdrawRule')) {
523
- return { balance: 100, enableWithdraw: true, enableWithdrawAmount: 50, rules: [{ greaterEqualThen: 0, maxWithdrawAmount: 20 }] }
524
- }
525
- return { data: {} }
526
- },
527
- }
528
-
529
- const machine = withdrawManualFactory(request)
530
- const actions = machine.options.actions
531
- const guards = machine.options.guards
532
- const services = machine.options.services
533
-
534
- const initData = actions.setInitData.assignment(machine.initialState.context, {
535
- data: {
536
- bindingPaymentList: { bankList: [{ bankCode: 'B1' }] },
537
- bindingPaymentInfo: { bankList: [{ bankCode: 'B1' }], cryptoList: [] },
538
- },
539
- })
540
- assert.equal(initData.boundBanks.length, 1)
541
- assert.equal(actions.preset.assignment(machine.initialState.context, {}).attachmentType, 'withdraw')
542
- assert.equal(actions.setMode.assignment(machine.initialState.context, { data: 'main' }).mode, 'main')
543
-
544
- const cond = actions.updateWithdrawCondition.assignment(machine.initialState.context, {
545
- data: {
546
- enableWithdraw: true,
547
- enableWithdrawAmount: '10',
548
- currentWithdrawLimit: 1,
549
- targetWithdrawLimit: 2,
550
- balance: 100,
551
- freeGameDetail: [],
552
- freeGameExpired: false,
553
- rules: [
554
- { greaterEqualThen: 0, maxWithdrawAmount: 50 },
555
- { greaterEqualThen: 80, maxWithdrawAmount: 90 },
556
- ],
557
- },
558
- })
559
- assert.equal(cond.maxWithdrawAmount, 90)
560
- assert.equal(cond.enableWithdrawAmount, 10)
561
-
562
- assert.equal(
563
- guards.isAvailableAmount({
564
- paymentDetail: [{ minimum: 10, maximum: 100 }],
565
- currentBank: { bankCode: 'B1' },
566
- amount: 20,
567
- userInfo: { balance: 30 },
568
- }),
569
- true
570
- )
571
- assert.equal(guards.hasAttachmentType({ attachmentType: 'pool' }), true)
572
- assert.equal(guards.haveProcessing({ paymentDetail: [{ processing: [{ id: 1 }] }] }), true)
573
- assert.equal(guards.isBankNotBound({ boundBanks: [] }), true)
574
- assert.equal(guards.isConvertible({ enableWithdraw: false, freeGameDetail: [{ freeGameCount: 1, freeGameUsedCount: 1 }] }), true)
575
- assert.equal(guards.isNotWithdrawable({ balance: 1, enableWithdraw: true, paymentDetail: [{ minimum: 10 }] }), true)
576
- assert.equal(guards.isOtpRequired({}, { data: { status: 'otp-verifying' } }), true)
577
- assert.equal(guards.isNotWithdrawMinDepositAmount({ withdrawCheck: { passDepositeLimit: false } }), true)
578
- assert.equal(guards.isPassWithdrawCooldownTime({ withdrawCheck: { passWithdrawCooldownTime: false } }), true)
579
- assert.equal(guards.isNotWIthdrawServiceTime({ withdrawCheck: { withdrawInServiceTime: false } }), true)
580
-
581
- await services.fetchInitData({}, {})
582
- await services.fetchPaymentData({}, {})
583
- await services.fetchWithdrawRules({ mode: 'main' }, {})
584
- await services.fetchWithdrawRulePreview({}, {})
585
- await services.fetchCalculation({ paymentDetail: [{ method: 'manual' }], currentBank: { cryptoCurrency: 'USDT' }, amount: 10 }, {})
586
- await services.submitWithdraw(
587
- {
588
- paymentDetail: [{ method: 'manual' }],
589
- currentBank: {
590
- bindingType: 'BANK',
591
- bankCode: 'B1',
592
- branch: 'BRANCH',
593
- accountNumber: '123',
594
- ifscCode: 'IFSC',
595
- holderName: 'Holder',
596
- },
597
- amount: 20,
598
- },
599
- {}
600
- )
601
- await services.submitWithdraw(
602
- {
603
- paymentDetail: [{ method: 'manual' }],
604
- currentBank: {
605
- bindingType: 'BANK',
606
- bankCode: 'GCASH',
607
- branch: 'BRANCH',
608
- accountNumber: '123',
609
- },
610
- amount: 20,
611
- },
612
- {}
613
- )
614
- await services.convertFreeCredit({}, {})
615
- await services.resetOtp({ requestId: 'RID', target: 'phone' }, {})
616
- await services.acknowledge({ requestId: 'RID', target: 'phone' }, { data: '123456' })
617
- await services.pool({ amount: 99 }, {})
618
- await services.giveUp({}, {})
619
- await services.withdrawCheck({}, {})
620
-
621
- assert.equal(
622
- sent.some((req) => req.url?.includes('/transaction')),
623
- true
624
- )
625
- assert.equal(
626
- sent.some((req) => req.url?.includes('restore')),
627
- true
628
- )
629
- })