@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,199 +0,0 @@
1
- import test from 'node:test'
2
- import assert from 'node:assert/strict'
3
-
4
- import gameSearchV2Factory from '../src/machine/game_search_v2.js'
5
-
6
- test('game_search_v2 actions and guards cover keyword/tag/game routing branches', () => {
7
- const machine = gameSearchV2Factory({
8
- send: async () => ({}),
9
- })
10
-
11
- const actions = machine.options.actions
12
- const guards = machine.options.guards
13
- const base = machine.initialState.context
14
-
15
- const mainTagList = [{ id: 'm1' }, { id: 'm2' }]
16
- const tagList = [{ id: 't1' }, { id: 't2' }]
17
- const recentlySearch = [{ id: 'r1' }, { id: 'r2' }]
18
-
19
- assert.deepEqual(actions.setMainTagList.assignment(base, { data: mainTagList }), { mainTagList })
20
-
21
- const initialByRecent = actions.setInitialData.assignment(base, {
22
- data: {
23
- recentlySearch: [
24
- { id: 'a', i18n: 'A' },
25
- { id: null, i18n: 'B' },
26
- { id: 'c', i18n: null },
27
- ],
28
- recentlyGame: [{ gameCode: 'g1' }],
29
- youMayLike: [{ gameCode: 'g2' }],
30
- },
31
- })
32
- assert.deepEqual(initialByRecent.recentlySearch, [{ id: 'a', i18n: 'A' }])
33
- assert.deepEqual(initialByRecent.gameList, [{ gameCode: 'g1' }])
34
-
35
- const initialByLike = actions.setInitialData.assignment(base, {
36
- data: {
37
- recentlySearch: [],
38
- recentlyGame: [],
39
- youMayLike: [{ gameCode: 'g3' }],
40
- },
41
- })
42
- assert.deepEqual(initialByLike.gameList, [{ gameCode: 'g3' }])
43
-
44
- const setMainTagId = actions.setMainTagId.assignment({ ...base, mainTagList }, { data: { tagId: 'm2' } })
45
- assert.equal(setMainTagId.tagIndex, 1)
46
- assert.equal(setMainTagId.click, 1)
47
-
48
- assert.deepEqual(actions.clearMainTag.assignment(base, {}), { tagId: null })
49
-
50
- const setTagIdRecent = actions.setTagId.assignment(
51
- { ...base, mainTagList, tagList, recentlySearch },
52
- { data: { tagId: 'r2', clickTagType: 'RECENTLY SEARCH' } }
53
- )
54
- assert.equal(setTagIdRecent.tagIndex, 1)
55
- assert.equal(setTagIdRecent.click, 1)
56
-
57
- const setTagIdPopular = actions.setTagId.assignment(
58
- { ...base, mainTagList, tagList, recentlySearch },
59
- { data: { tagId: 'm1', clickTagType: 'POPULAR KEYWORDS' } }
60
- )
61
- assert.equal(setTagIdPopular.tagIndex, 0)
62
- assert.equal(setTagIdPopular.clickDefault, 1)
63
-
64
- const setTagIdPopularByEmptyTagList = actions.setTagId.assignment(
65
- { ...base, mainTagList, tagList: [], recentlySearch },
66
- { data: { tagId: 'm2', clickTagType: 'OTHER' } }
67
- )
68
- assert.equal(setTagIdPopularByEmptyTagList.tagIndex, 1)
69
- assert.equal(setTagIdPopularByEmptyTagList.clickDefault, 1)
70
-
71
- const setTagIdNormal = actions.setTagId.assignment(
72
- { ...base, mainTagList, tagList, recentlySearch },
73
- { data: { tagId: 't2', clickTagType: 'OTHER' } }
74
- )
75
- assert.equal(setTagIdNormal.tagIndex, 1)
76
- assert.equal(setTagIdNormal.click, 1)
77
-
78
- assert.deepEqual(actions.setGames.assignment(base, { data: { traceId: 'tr1', result: [{ id: 1 }] } }), {
79
- traceId: 'tr1',
80
- gameList: [{ id: 1 }],
81
- })
82
- assert.deepEqual(actions.setGames.assignment({ ...base, tagId: 'Recently', recentlyGame: [{ id: 'rg' }] }, {}), {
83
- traceId: null,
84
- gameList: [{ id: 'rg' }],
85
- })
86
- assert.deepEqual(actions.setGames.assignment({ ...base, tagId: 'You may like', youMayLike: [{ id: 'yl' }] }, {}), {
87
- traceId: null,
88
- gameList: [{ id: 'yl' }],
89
- })
90
-
91
- assert.deepEqual(
92
- actions.setTraceData.assignment(base, {
93
- data: { traceData: { isYouMayLike: true, isRecentlyGame: false, isRecentlySearch: true } },
94
- }),
95
- { isYouMayLike: true, isRecentlyGame: false, isRecentlySearch: true }
96
- )
97
- assert.deepEqual(actions.setKeyword.assignment(base, { data: { keyword: 'slot' } }), { keyword: 'slot' })
98
- assert.deepEqual(actions.setLang.assignment(base, { data: { lang: 'th-TH' } }), { lang: 'th-TH' })
99
- assert.deepEqual(actions.clearKeywords.assignment(base, {}), { keyword: '' })
100
- assert.deepEqual(actions.setTagList.assignment(base, { data: tagList }), { tagList })
101
-
102
- const setGameCode = actions.setGameCode.assignment({ ...base, gameList: [{ gameCode: 'G1' }, { gameCode: 'G2' }] }, { data: 'G2' })
103
- assert.equal(setGameCode.gameCode, 'G2')
104
- assert.equal(setGameCode.gameCodeIndex, 1)
105
-
106
- const clearExceptKeyword = actions.clearExceptKeyword.assignment({ ...base, keyword: 'fish', gameList: [{ id: 1 }], traceId: 't' }, {})
107
- assert.equal(clearExceptKeyword.query, 'fish')
108
- assert.deepEqual(clearExceptKeyword.gameList, [])
109
- assert.equal(clearExceptKeyword.tagId, null)
110
-
111
- assert.equal(guards.isRecentlyYouMayLike({ tagId: 'Recently' }, {}), true)
112
- assert.equal(guards.isRecentlyYouMayLike({ tagId: 'You may like' }, {}), true)
113
- assert.equal(guards.isRecentlyYouMayLike({ tagId: 'Other' }, {}), false)
114
- assert.equal(guards.hasTagList({ tagList: [{ id: 1 }] }, {}), true)
115
- assert.equal(guards.hasTagList({ tagList: [] }, {}), false)
116
-
117
- const pressEnterSend = machine.config.states.searching.states.searchIdle.on.PRESS_ENTER[0].actions
118
- const sendEvent = pressEnterSend.event({ ...base, tagList: [{ id: 'top-tag' }] }, {})
119
- assert.equal(sendEvent.type, 'SET_TAG_ID')
120
- assert.equal(sendEvent.data.tagId, 'top-tag')
121
- assert.deepEqual(sendEvent.data.traceData, {
122
- isYouMayLike: false,
123
- isRecentlyGame: false,
124
- isRecentlySearch: false,
125
- })
126
- })
127
-
128
- test('game_search_v2 services call expected endpoints and normalize sendTrace id', async () => {
129
- const calls = []
130
- const request = {
131
- send: async (req) => {
132
- calls.push(req)
133
- if (req.url === 'game/search') {
134
- return { result: [{ id: 'tag-1' }] }
135
- }
136
- if (req.url === 'game/search/home') {
137
- return { recentlySearch: [], recentlyGame: [], youMayLike: [] }
138
- }
139
- if (req.url === 'game/search/list') {
140
- return { traceId: 'TRACE-1', result: [{ gameCode: 'GG' }] }
141
- }
142
- if (req.url === 'game/search/trace') {
143
- return { ok: true, params: req.params }
144
- }
145
- return {}
146
- },
147
- }
148
- const machine = gameSearchV2Factory(request)
149
- const services = machine.options.services
150
-
151
- const tags = await services.fetchTags({ keyword: 'slot', lang: 'en-US' }, {})
152
- assert.deepEqual(tags, [{ id: 'tag-1' }])
153
-
154
- const home = await services.fetchInitialData({}, {})
155
- assert.deepEqual(home, { recentlySearch: [], recentlyGame: [], youMayLike: [] })
156
-
157
- const games = await services.fetchGames({ tagId: 'm1', tagIndex: 2, keyword: 'jackpot', click: 1, clickDefault: null }, {})
158
- assert.deepEqual(games, { traceId: 'TRACE-1', result: [{ gameCode: 'GG' }] })
159
-
160
- const traceNormal = await services.sendTrace(
161
- {
162
- traceId: 'T1',
163
- tagId: 'm1',
164
- tagIndex: 0,
165
- gameCode: 'G1',
166
- gameCodeIndex: 1,
167
- keyword: 'aaa',
168
- click: 1,
169
- clickDefault: null,
170
- isYouMayLike: false,
171
- isRecentlyGame: false,
172
- isRecentlySearch: false,
173
- },
174
- {}
175
- )
176
- assert.equal(traceNormal.ok, true)
177
-
178
- const traceSpecial = await services.sendTrace(
179
- {
180
- traceId: 'T2',
181
- tagId: 'Recently',
182
- tagIndex: 0,
183
- gameCode: 'G2',
184
- gameCodeIndex: 2,
185
- keyword: 'bbb',
186
- click: 1,
187
- clickDefault: null,
188
- isYouMayLike: true,
189
- isRecentlyGame: true,
190
- isRecentlySearch: true,
191
- },
192
- {}
193
- )
194
- assert.equal(traceSpecial.params.tagId, null)
195
- assert.equal(
196
- calls.some((req) => req.url === 'game/search/trace'),
197
- true
198
- )
199
- })
@@ -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,148 +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
- const dedupedAndPruned = setBroadcast(
69
- {
70
- ...machine.initialState.context,
71
- broadcastList: [{ broadcastId: 'a' }, { broadcastId: 'b' }],
72
- sentNormalBroadcastList: [{ broadcastId: 'a' }, { broadcastId: 'a' }, { broadcastId: 'stale' }],
73
- normalBroadcast: { broadcastId: 'b' },
74
- },
75
- {}
76
- )
77
- assert.equal(dedupedAndPruned.normalBroadcast, undefined)
78
- assert.deepEqual(
79
- dedupedAndPruned.sentNormalBroadcastList.map((item) => item.broadcastId),
80
- ['a', 'b']
81
- )
82
-
83
- assert.equal(resetBroadcast(machine.initialState.context, {}).isPlaying, true)
84
- assert.equal(leaveGame({ ...machine.initialState.context, isPlaying: true }, {}).isPlaying, false)
85
- assert.equal(isNotInGame({ isPlaying: false }, {}), true)
86
- assert.equal(isNotInGame({ isPlaying: true }, {}), false)
87
- assert.equal(timeout({ tick: 6 }, {}), 60)
88
-
89
- const data = await fetchHonorBoardList(machine.initialState.context, {})
90
- assert.equal(Array.isArray(data), true)
91
- assert.equal(calls.length, 1)
92
- })
93
-
94
- test('honor_board_cash: action/delay/service map all tab branches', async () => {
95
- const calls = []
96
- const request = {
97
- config: { appSecret: 'secret' },
98
- send: async (req) => {
99
- calls.push(req)
100
- return {
101
- data: [
102
- { type: 'CASH_RAIN', id: 1 },
103
- { type: 'DEPOSIT', id: 2 },
104
- { type: 'FREE_ROULETTE_SPIN', id: 3 },
105
- { type: 'JACKPOT', id: 4 },
106
- { type: 'WIN_SCORE', id: 5 },
107
- { type: 'WIN_MULTIPLIER', id: 6 },
108
- { type: 'WITHDRAW', id: 7 },
109
- { type: 'UNKNOWN', id: 8 },
110
- ],
111
- }
112
- },
113
- }
114
-
115
- const machine = honorBoardCashFactory(request)
116
- const setHonorBoardList = machine.options.actions.setHonorBoardList.assignment
117
- const timeout = machine.options.delays.TIMEOUT
118
- const fetchHonorBoardList = machine.options.services.fetchHonorBoardList
119
-
120
- const mapped = setHonorBoardList(machine.initialState.context, {
121
- data: [
122
- { type: 'CASH_RAIN', value: 1 },
123
- { type: 'DEPOSIT', value: 2 },
124
- { type: 'FREE_ROULETTE_SPIN', value: 3 },
125
- { type: 'JACKPOT', value: 4 },
126
- { type: 'WIN_SCORE', value: 5 },
127
- { type: 'WIN_MULTIPLIER', value: 6 },
128
- { type: 'WITHDRAW', value: 7 },
129
- { type: 'UNKNOWN', value: 8 },
130
- ],
131
- })
132
- assert.deepEqual(mapped.tabs, ['cashRain', 'deposit', 'roulette', 'jackpot', 'bigWin', 'maxBet', 'withdraw', undefined])
133
- assert.equal(mapped.cashRain.value, 1)
134
- assert.equal(mapped.deposit.value, 2)
135
- assert.equal(mapped.roulette.value, 3)
136
- assert.equal(mapped.jackpot.value, 4)
137
- assert.equal(mapped.bigWin.value, 5)
138
- assert.equal(mapped.maxBet.value, 6)
139
- assert.equal(mapped.withdraw.value, 7)
140
- const emptyMapped = setHonorBoardList(machine.initialState.context, { data: null })
141
- assert.deepEqual(emptyMapped.tabs, [])
142
- assert.deepEqual(emptyMapped.cashRain, {})
143
- assert.equal(timeout({ tick: 7 }, {}), 70)
144
-
145
- const data = await fetchHonorBoardList(machine.initialState.context, {})
146
- assert.equal(Array.isArray(data), true)
147
- assert.equal(calls.length, 1)
148
- })