test(chat-machine): add test for ignoring repeated user login during active session

This commit is contained in:
2026-06-29 15:49:03 +08:00
parent 207f635e7f
commit 6273cd1bbe
3 changed files with 26 additions and 14 deletions
+1 -13
View File
@@ -1,17 +1,10 @@
/**
* Chat 状态机(XState v5
*
* 鉴权解耦(事件驱动):
* chat 机器不感知鉴权 —— 由 <ChatAuthSync /> 派生 loginStatus
* ChatAuthSync 派发登录态生命周期事件:
* - `ChatGuestLogin` → 游客会话
* - `ChatUserLogin { token }` → 其他登录用户会话
* - `ChatLogout` → 正式登录用户登出
*
* 登录态流转约束:
* - 未登录:可以进入游客登录 / 其他登录。
* - 游客登录:只可以升级为其他登录,不响应退出。
* - 其他登录:可以退出,不响应游客登录。
* - 其他登录:可以退出,不响应游客登录 / 重复其他登录
*
* 状态结构(parent state 模式):
* - `idle`:屏没挂 / 登出
@@ -363,11 +356,6 @@ export const chatMachine = setup({
target: "#chat.idle",
actions: "clearChatSession",
},
ChatUserLogin: {
target: "#chat.userSession",
reenter: true,
actions: "startUserSession",
},
ChatQueuedSendStarted: {
actions: "markQueuedSendStarted",
},