@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,108 +0,0 @@
1
- import test from 'node:test'
2
- import assert from 'node:assert/strict'
3
-
4
- import directCashFactory from '../src/machine/deposit/direct_cash.js'
5
-
6
- test('direct_cash covers actions, guards and services branches', async () => {
7
- const sent = []
8
- const request = {
9
- send: async (req) => {
10
- sent.push(req)
11
- if (req.url === 'payment/v2/direct_cash_1/getBankList') {
12
- return { data: [{ bankCode: 'B1' }, { bankCode: 'B2' }] }
13
- }
14
- if (req.url === 'payment/v2/direct_cash_1/expected/result') {
15
- return { data: { bonus: 3 } }
16
- }
17
- if (req.url === 'payment/v2/direct_cash_1/transaction') {
18
- return { applyId: 'TX-1' }
19
- }
20
- return {}
21
- },
22
- }
23
-
24
- const machine = directCashFactory(request, {
25
- selectedAmount: 10,
26
- promotion: { minimumAmount: 50, promotionsNo: 'P-1' },
27
- paymentDetail: [
28
- { category: 'direct', transferType: 'deposit', method: 'direct_cash_1', minimum: 100, maximum: 500 },
29
- { category: 'direct', transferType: 'withdraw', method: 'ignored' },
30
- ],
31
- })
32
-
33
- const { actions, guards, services } = machine.options
34
- const initial = machine.initialState.context
35
-
36
- const initData = actions.setInitData.assignment(initial, {})
37
- assert.equal(initData.directs.length, 1)
38
- assert.equal(initData.selectedDirect.method, 'direct_cash_1')
39
- assert.equal(initData.selectedAmount, 100)
40
-
41
- const setBanksFromObject = actions.setBanks.assignment(
42
- { ...initial, selectedDirect: { method: 'direct_cash_1' }, bankMap: {} },
43
- { data: { data: [{ bankCode: 'B1' }] } }
44
- )
45
- assert.equal(setBanksFromObject.bankMap.direct_cash_1[0].bankCode, 'B1')
46
- assert.equal(setBanksFromObject.selectedUserBank.bankCode, 'B1')
47
-
48
- const setBanksFromArray = actions.setBanks.assignment(
49
- { ...initial, selectedDirect: { method: 'direct_cash_1' }, bankMap: {} },
50
- { data: [{ bankCode: 'B2' }] }
51
- )
52
- assert.equal(setBanksFromArray.userBanks[0].bankCode, 'B2')
53
-
54
- assert.equal(actions.setBanks.assignment({ ...initial, selectedDirect: null, bankMap: {} }, { data: [] }), undefined)
55
-
56
- assert.equal(actions.setDirect.assignment(initial, { data: { method: 'direct_cash_2' } }).selectedDirect.method, 'direct_cash_2')
57
- assert.equal(actions.setUserBank.assignment(initial, { data: { bankCode: 'B9' } }).selectedUserBank.bankCode, 'B9')
58
- assert.equal(actions.setAmount.assignment(initial, { data: '333' }).selectedAmount, '333')
59
-
60
- const calcFromV2 = actions.setCalculation.assignment(initial, { data: { data: { bonus: 9 } } })
61
- assert.equal(calcFromV2.calculation.bonus, 9)
62
- const calcLegacy = actions.setCalculation.assignment(initial, { data: { bonus: 8 } })
63
- assert.equal(calcLegacy.calculation.bonus, 8)
64
-
65
- assert.equal(actions.clearCalculation.assignment({ calculation: { x: 1 } }, {}).calculation, null)
66
- assert.equal(actions.setResult.assignment(initial, { data: { applyId: 'TX-2' } }).result.applyId, 'TX-2')
67
- assert.equal(actions.setPromotion.assignment(initial, { data: { promotionsNo: 'P-2' } }).promotion.promotionsNo, 'P-2')
68
-
69
- assert.equal(guards.isCalculable({ selectedAmount: '100', selectedDirect: { minimum: 100, maximum: 500 } }), true)
70
- assert.equal(guards.isCalculable({ selectedAmount: '99', selectedDirect: { minimum: 100, maximum: 500 } }), false)
71
- assert.equal(guards.isCalculable({ selectedAmount: '501', selectedDirect: { minimum: 100, maximum: 500 } }), false)
72
-
73
- assert.equal(guards.isSubmittable({ selectedAmount: 100, selectedDirect: { method: 'm' }, selectedUserBank: { bankCode: 'B1' } }).bankCode, 'B1')
74
- assert.equal(guards.isSubmittable({ selectedAmount: 100, selectedDirect: null, selectedUserBank: { bankCode: 'B1' } }), null)
75
-
76
- const noDirectBanks = await services.fetchBanksList({ selectedDirect: null, bankMap: {} })
77
- assert.deepEqual(noDirectBanks, [])
78
-
79
- const cachedBanks = await services.fetchBanksList({ selectedDirect: { method: 'direct_cash_1' }, bankMap: { direct_cash_1: [{ bankCode: 'BC' }] } })
80
- assert.equal(cachedBanks[0].bankCode, 'BC')
81
-
82
- const remoteBanks = await services.fetchBanksList({ selectedDirect: { method: 'direct_cash_1' }, bankMap: {} })
83
- assert.equal(remoteBanks.data.length, 2)
84
-
85
- const calcResult = await services.fetchCalculation({
86
- selectedDirect: { method: 'direct_cash_1' },
87
- selectedAmount: '450',
88
- promotion: { promotionsNo: 'P-3' },
89
- })
90
- assert.equal(calcResult.data.bonus, 3)
91
-
92
- const submitResult = await services.submitDeposit({
93
- selectedDirect: { method: 'direct_cash_1' },
94
- selectedAmount: 460,
95
- selectedUserBank: { bankCode: 'B1' },
96
- promotion: { promotionsNo: 'P-4' },
97
- })
98
- assert.equal(submitResult.applyId, 'TX-1')
99
-
100
- const calcReq = sent.find((entry) => entry.url === 'payment/v2/direct_cash_1/expected/result')
101
- assert.equal(calcReq.params.amount, 450)
102
- assert.equal(calcReq.params.promotionsNo, 'P-3')
103
-
104
- const submitReq = sent.find((entry) => entry.url === 'payment/v2/direct_cash_1/transaction')
105
- assert.equal(submitReq.params.amount, 460)
106
- assert.equal(submitReq.params.applyerBankCode, 'B1')
107
- assert.equal(submitReq.params.promotionsNo, 'P-4')
108
- })
@@ -1,37 +0,0 @@
1
- import test from 'node:test'
2
- import assert from 'node:assert/strict'
3
-
4
- import { State } from 'xstate'
5
- import errorFactory from '../src/machine/error.js'
6
-
7
- test('error machine actions, guards, services and routing branches', async () => {
8
- const request = {
9
- config: { appSecret: 'secret' },
10
- send: async (req) => ({ data: [{ gameCode: req.params.gameCodes[0], name: 'Demo Game' }] }),
11
- }
12
- const machine = errorFactory(request)
13
- const actions = machine.options.actions
14
- const guards = machine.options.guards
15
- const services = machine.options.services
16
- const ctx = machine.initialState.context
17
-
18
- assert.equal(actions.setError.assignment(ctx, { data: { code: 'ERR_G106' } }).error.code, 'ERR_G106')
19
- assert.equal(actions.solveError.assignment.error, null)
20
- assert.equal(actions.setUnfinishedGame.assignment({ ...ctx, error: { extend: 'unfinished_CODE123' } }, {}).gameCode, 'CODE123')
21
- assert.equal(actions.setGame.assignment(ctx, { data: { data: [{ id: 9 }] } }).game.id, 9)
22
- assert.equal(actions.setGame.assignment(ctx, { data: {} }).game, undefined)
23
-
24
- assert.equal(guards.isLogout({ ...ctx, error: { code: 'ERR_A201' } }, {}), true)
25
- assert.equal(guards.isNoBalance({ ...ctx, error: { code: 'ERR_G106' } }, {}), true)
26
- assert.equal(guards.isUnfinishedGame({ ...ctx, error: { extend: 'unfinished_ABC' } }, {}), true)
27
- assert.equal(guards.isFreeGameSettle({ ...ctx, error: { code: 'ERR_G124' } }, {}), true)
28
- assert.equal(guards.isFreeGameGiveUp({ ...ctx, error: { code: 'ERR_G125' } }, {}), true)
29
-
30
- const info = await services.getGameInfo({ ...ctx, gameCode: 'G001' }, {})
31
- assert.equal(info.data[0].gameCode, 'G001')
32
-
33
- const toLogout = machine.transition(State.from({ error: 'unknown' }, { ...ctx, error: { code: 'ERR_A201' } }), { type: 'xstate.null' })
34
- assert.equal(toLogout.value.error, 'logout')
35
- const toDeposit = machine.transition(State.from({ error: 'unknown' }, { ...ctx, error: { code: 'ERR_G106' } }), { type: 'xstate.null' })
36
- assert.equal(toDeposit.value.error, 'deposit')
37
- })
@@ -1,126 +0,0 @@
1
- import test from 'node:test'
2
- import assert from 'node:assert/strict'
3
-
4
- import machine from '../src/machine/index.js'
5
- import { createLocalStorageMock } from './helpers.js'
6
-
7
- function collectEventsFromStates(states, output) {
8
- if (!states || typeof states !== 'object') return
9
-
10
- for (const stateNode of Object.values(states)) {
11
- if (stateNode?.on && typeof stateNode.on === 'object') {
12
- for (const eventType of Object.keys(stateNode.on)) {
13
- output.add(eventType)
14
- }
15
- }
16
- collectEventsFromStates(stateNode?.states, output)
17
- }
18
- }
19
-
20
- function collectMachineEvents(m) {
21
- const events = new Set()
22
-
23
- if (m.config?.on && typeof m.config.on === 'object') {
24
- for (const eventType of Object.keys(m.config.on)) {
25
- events.add(eventType)
26
- }
27
- }
28
-
29
- collectEventsFromStates(m.config?.states, events)
30
- return [...events].filter((eventType) => typeof eventType === 'string' && !eventType.startsWith('xstate.'))
31
- }
32
-
33
- function buildEvent(type) {
34
- return {
35
- type,
36
- data: {
37
- callback: () => {},
38
- locale: 'en-US',
39
- site: 'test',
40
- walletType: 'MAIN',
41
- categoryId: 1,
42
- game: {
43
- providerId: 'P1',
44
- gameId: 'G1',
45
- gameTypeId: 'GT1',
46
- mappingId: 'M1',
47
- portrait: 0,
48
- gameCode: 'CODE',
49
- name: 'Name',
50
- gameName: 'Game Name',
51
- },
52
- list: [{ id: 1, i18n: 'slot' }],
53
- amount: 10,
54
- label: 'USDT',
55
- value: 'TRC20',
56
- network: 'TRC20',
57
- channel: 'USDT',
58
- method: 'manual',
59
- activityNo: 1,
60
- requestId: 'req',
61
- target: 'phone',
62
- code: '1234',
63
- uid_site: 'uid',
64
- uidSite: 'uid',
65
- provider_id: 'P1',
66
- seqNo: 'S1',
67
- appSecret: 'secret',
68
- index: 0,
69
- row: 10,
70
- page: 1,
71
- type: 'DEPOSIT',
72
- transferType: 'DEPOSIT',
73
- paymentMethod: 'manual',
74
- promotion: { activityNo: 'none' },
75
- },
76
- }
77
- }
78
-
79
- const requestStub = {
80
- config: {
81
- apiURL: 'https://api.example.com',
82
- apiVersion: 'v1',
83
- clientId: 'client',
84
- appSecret: 'secret',
85
- platform: 'web',
86
- version: '1.0.0',
87
- fpToken: 'fp-token',
88
- sentry: { captureException: () => {}, setTag: () => {} },
89
- defaultChannel: 'web',
90
- defaultSubchannel: 'home',
91
- socketURL: 'wss://socket.example.com',
92
- bucketName: 'bucket',
93
- },
94
- send: async () => ({}),
95
- getToken: () => null,
96
- }
97
-
98
- global.localStorage = createLocalStorageMock()
99
- global.window = {
100
- location: {
101
- search: '',
102
- href: 'https://example.com/path',
103
- origin: 'https://example.com',
104
- protocol: 'https:',
105
- host: 'example.com',
106
- },
107
- atob: (value) => Buffer.from(value, 'base64').toString('binary'),
108
- CC_JSB: false,
109
- }
110
- global.document = { cookie: '' }
111
-
112
- for (const [machineName, machineFactory] of Object.entries(machine)) {
113
- test(`machine events do not throw: ${machineName}`, () => {
114
- const m = machineFactory(requestStub, {})
115
- const events = collectMachineEvents(m)
116
-
117
- let state = m.initialState
118
- for (const eventType of events) {
119
- const event = buildEvent(eventType)
120
- assert.doesNotThrow(() => {
121
- state = m.transition(state, event)
122
- }, `${machineName} should handle event ${eventType} without throwing`)
123
- assert.ok(state)
124
- }
125
- })
126
- }
@@ -1,82 +0,0 @@
1
- import test from 'node:test'
2
- import assert from 'node:assert/strict'
3
-
4
- import favoriteFactory from '../src/machine/game_favorite_v2.js'
5
- import jackpotFactory from '../src/machine/activity/jackpot.js'
6
-
7
- test('game_favorite_v2 covers list actions, guards and service branches', async () => {
8
- let hasToken = true
9
- const request = {
10
- getToken: () => (hasToken ? 'token' : null),
11
- send: async (req) => {
12
- if (req.url === 'game/list/v3/myFavorite') return { data: [{ gameCode: 'G1' }] }
13
- if (req.url === 'game/list/v3/addMyFavorite') {
14
- if (req.params.games[0] === 'ERR') throw new Error('boom')
15
- return { ok: true }
16
- }
17
- if (req.url === 'game/list/v3/removeMyFavorite') {
18
- if (req.params.games[0] === 'ERR') throw new Error('boom')
19
- return { ok: true }
20
- }
21
- return {}
22
- },
23
- }
24
-
25
- const machine = favoriteFactory(request)
26
- const actions = machine.options.actions
27
- const guards = machine.options.guards
28
- const services = machine.options.services
29
- const ctx = machine.initialState.context
30
-
31
- assert.equal(actions.setList.assignment(ctx, { data: [{ gameCode: 'G1' }] }).list.length, 1)
32
- assert.equal(actions.clearList.assignment({ ...ctx, list: [{ gameCode: 'G1' }] }, {}).list.length, 0)
33
- assert.equal(actions.addToList.assignment(ctx, { data: { gameCode: 'G2' } }).list[0].gameCode, 'G2')
34
- assert.equal(
35
- actions.removeFromList.assignment({ ...ctx, list: [{ gameCode: 'G1' }, { gameCode: 'G2' }] }, { data: { gameCode: 'G1' } }).list.length,
36
- 1
37
- )
38
- assert.equal(actions.setAuth.assignment(ctx, { data: 1 }).auth, true)
39
-
40
- assert.equal(guards.isExist({ ...ctx, list: [{ gameCode: 'G1' }] }, { data: { gameCode: 'G1' } }), true)
41
- assert.equal(guards.isNotExist({ ...ctx, list: [{ gameCode: 'G1' }] }, { data: { gameCode: 'G2' } }), true)
42
- assert.equal(guards.isAuthChanged({ ...ctx, auth: false }, { data: 1 }), true)
43
- assert.equal(guards.hasAuth({ ...ctx, auth: true }, {}), true)
44
-
45
- const addOk = await services.add(ctx, { data: { gameCode: 'G2' } })
46
- assert.equal(addOk.gameCode, 'G2')
47
- await assert.rejects(() => services.add(ctx, { data: { gameCode: 'ERR' } }), { gameCode: 'ERR' })
48
- const removeOk = await services.remove(ctx, { data: { gameCode: 'G2' } })
49
- assert.equal(removeOk.gameCode, 'G2')
50
- await assert.rejects(() => services.remove(ctx, { data: { gameCode: 'ERR' } }), { gameCode: 'ERR' })
51
-
52
- hasToken = true
53
- const listWithToken = await services.fetchList(ctx, {})
54
- assert.equal(listWithToken.length, 1)
55
- hasToken = false
56
- const listWithoutToken = await services.fetchList(ctx, {})
57
- assert.equal(listWithoutToken.length, 0)
58
- })
59
-
60
- test('activity jackpot covers list/enable/timeout/fetch branches', async () => {
61
- const request = {
62
- config: { appSecret: 'secret' },
63
- send: async (req) => {
64
- if (req.url === 'activities/jackpot/list') return { data: [{ id: 1 }] }
65
- return { data: [] }
66
- },
67
- }
68
-
69
- const machine = jackpotFactory(request)
70
- const actions = machine.options.actions
71
- const services = machine.options.services
72
- const ctx = machine.initialState.context
73
-
74
- assert.equal(actions.setJackpotList.assignment(ctx, { data: { jackpotList: [{ id: 1 }] } }).jackpotList.length, 1)
75
- assert.equal(actions.setJackpotEnable.assignment(ctx, { data: true }).jackpotEnable, true)
76
- assert.equal(machine.options.delays.TIMEOUT({ ...ctx, tick: 123 }, {}), 1230)
77
-
78
- const enabled = await services.fetchList({ ...ctx, jackpotEnable: true }, {})
79
- assert.equal(enabled.jackpotList.length, 1)
80
- const disabled = await services.fetchList({ ...ctx, jackpotEnable: false }, {})
81
- assert.equal(disabled.jackpotList.length, 0)
82
- })
@@ -1,136 +0,0 @@
1
- import test from 'node:test'
2
- import assert from 'node:assert/strict'
3
-
4
- import floatFactory from '../src/machine/deposit/float.js'
5
-
6
- test('float covers actions, guards, inline conds and services', async () => {
7
- const sent = []
8
- const request = {
9
- config: { appSecret: 'app-secret' },
10
- send: async (req) => {
11
- sent.push(req)
12
- if (req.url === 'payment/v2/paymentInfo') {
13
- return {
14
- bankInfo: [
15
- { bindingType: 'CRYPTO', id: 1 },
16
- { bindingType: 'EWALLET', id: 2 },
17
- { bindingType: 'BANK', id: 3 },
18
- ],
19
- }
20
- }
21
- if (req.url === 'getConfig') {
22
- return { config: 'eyJib251c1ByZXZpZXdFbmFibGUiOnRydWV9' }
23
- }
24
- if (req.url === 'payment/v2/paymentDetail') {
25
- return [{ method: 'ignored' }, { method: 'amb_float', optional: [100], minimum: 50, maximum: 500, grandTotalEnable: 1 }]
26
- }
27
- if (req.url === 'payment/v2/amb/getBankList') {
28
- return { data: [{ code: 'B1' }] }
29
- }
30
- if (req.url === 'payment/v2/amb_float/bonus/preview') {
31
- return [{ bonus: 9 }]
32
- }
33
- if (req.url === 'payment/v2/amb_float/transaction') {
34
- return { accountName: 'House', accountNumber: '123456', bankName: 'Bank', amount: 444 }
35
- }
36
- if (req.url === 'payment/v2/amb_float/expected/result') {
37
- return { data: { expectedAmount: 111 } }
38
- }
39
- return {}
40
- },
41
- }
42
-
43
- global.window = { atob: (value) => Buffer.from(value, 'base64').toString('utf8') }
44
-
45
- const machine = floatFactory(request)
46
- const { actions, guards, services } = machine.options
47
- const initial = machine.initialState.context
48
-
49
- const checkingCond = machine.config.states.checking.always[0].cond
50
- assert.equal(checkingCond({ siteConfig: { bonusPreviewEnable: true }, promotion: { activityNo: 'A1' } }), true)
51
- assert.equal(checkingCond({ siteConfig: { bonusPreviewEnable: false }, promotion: { activityNo: 'A1' } }), false)
52
- assert.equal(checkingCond({ siteConfig: { bonusPreviewEnable: true }, promotion: { activityNo: 'none' } }), false)
53
-
54
- const countdownCond = machine.config.states.countdown.after[1000][0].cond
55
- assert.equal(countdownCond({ ttl: 2 }), true)
56
- assert.equal(countdownCond({ ttl: 0 }), false)
57
-
58
- assert.equal(actions.setUserAccount.assignment(initial, { data: [{ account: 'u1' }] }).userAccount.account, 'u1')
59
- assert.equal(actions.setPromotion.assignment(initial, { data: { activityNo: 'P1' } }).promotion.activityNo, 'P1')
60
- assert.equal(actions.setBonusPreview.assignment(initial, { data: [{ bonus: 1 }] }).bonusPreviewData[0].bonus, 1)
61
-
62
- const house = actions.setHouseBank.assignment(initial, {
63
- data: { accountName: 'A', accountNumber: 'N', bankName: 'B', amount: 88 },
64
- })
65
- assert.equal(house.houseAccountName, 'A')
66
- assert.equal(house.houseAccountNumber, 'N')
67
- assert.equal(house.houseBankName, 'B')
68
- assert.equal(house.calculatedAmount, 88)
69
-
70
- const initFromData = actions.setInitialization.assignment(initial, {
71
- data: {
72
- siteConfig: { bonusPreviewEnable: true },
73
- housePayment: { optional: [100, 200], minimum: 50, maximum: 500, grandTotalEnable: 1 },
74
- bankList: { data: [{ code: 'B1' }] },
75
- },
76
- })
77
- assert.equal(initFromData.bankList[0].code, 'B1')
78
-
79
- const initFromArray = actions.setInitialization.assignment(initial, {
80
- data: {
81
- siteConfig: { bonusPreviewEnable: true },
82
- housePayment: { optional: [300], minimum: 10, maximum: 20, grandTotalEnable: 0 },
83
- bankList: [{ code: 'B2' }],
84
- },
85
- })
86
- assert.equal(initFromArray.bankList[0].code, 'B2')
87
-
88
- assert.equal(actions.addAmount.assignment({ amount: 200, maximum: 250 }, { data: 80 }).amount, 250)
89
- assert.equal(actions.setAmount.assignment(initial, { data: 333 }).amount, 333)
90
-
91
- const calcFromV2 = actions.setCalculation.assignment(initial, { data: { data: { expectedAmount: 5 } } })
92
- assert.equal(calcFromV2.calculation.expectedAmount, 5)
93
- const calcLegacy = actions.setCalculation.assignment(initial, { data: { expectedAmount: 6 } })
94
- assert.equal(calcLegacy.calculation.expectedAmount, 6)
95
-
96
- assert.equal(actions.clearCalculation.assignment({ calculation: { ok: 1 } }, {}).calculation, null)
97
- assert.equal(actions.decreaseTtl.assignment({ ttl: 3 }, {}).ttl, 2)
98
- assert.equal(actions.decreaseTtl.assignment({ ttl: 0 }, {}).ttl, 0)
99
-
100
- assert.equal(guards.hasUserAccount(initial, { data: [] }), undefined)
101
- assert.equal(guards.hasUserAccount(initial, { data: [{ id: 9 }] }).id, 9)
102
- assert.equal(guards.isGrandTotalEnable({ grandTotalEnable: 1 }), true)
103
- assert.equal(guards.isGrandTotalEnable({ grandTotalEnable: 0 }), false)
104
-
105
- const filtered = await services.fetchPaymentInfo(initial)
106
- assert.equal(filtered.length, 1)
107
- assert.equal(filtered[0].id, 3)
108
-
109
- const initialized = await services.initialize({ method: 'amb_float' })
110
- assert.equal(initialized.siteConfig.bonusPreviewEnable, true)
111
- assert.equal(initialized.housePayment.method, 'amb_float')
112
- assert.equal(initialized.bankList.data[0].code, 'B1')
113
-
114
- const bonusPreview = await services.fetchBonusPreview({ method: 'amb_float', promotion: { activityNo: 'P100' } })
115
- assert.equal(bonusPreview[0].bonus, 9)
116
-
117
- const submitResult = await services.submitDeposit({ method: 'amb_float', amount: 444, promotion: { activityNo: 'P9' } })
118
- assert.equal(submitResult.bankName, 'Bank')
119
-
120
- const calcResult = await services.fetchCalculation({ method: 'amb_float', amount: '45', promotion: { activityNo: 'P8' } })
121
- assert.equal(calcResult.data.expectedAmount, 111)
122
-
123
- const bonusReq = sent.find((entry) => entry.url === 'payment/v2/amb_float/bonus/preview')
124
- assert.equal(bonusReq.params.promotionsNo, 'P100')
125
-
126
- const submitReq = sent.find((entry) => entry.url === 'payment/v2/amb_float/transaction')
127
- assert.equal(submitReq.params.amount, 444)
128
- assert.equal(submitReq.params.promotionsNo, 'P9')
129
-
130
- const calcReq = sent.find((entry) => entry.url === 'payment/v2/amb_float/expected/result')
131
- assert.equal(calcReq.params.amount, 45)
132
- assert.equal(calcReq.params.promotionsNo, 'P8')
133
-
134
- const paymentDetailReq = sent.find((entry) => entry.url === 'payment/v2/paymentDetail')
135
- assert.equal(paymentDetailReq.params.transferType, 'DEPOSIT')
136
- })