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