fix: 自动恢复失效令牌并保留身份入口

This commit is contained in:
NathanAlex7
2026-09-15 11:24:52 +08:00
parent 5f49f94ca4
commit e44716b3ec
5 changed files with 32 additions and 5 deletions
+15
View File
@@ -0,0 +1,15 @@
const assert = require("node:assert/strict");
const fs = require("node:fs");
const path = require("node:path");
const root = path.resolve(__dirname, "..");
const nav = fs.readFileSync(path.join(root, "src/components/xingbang/AgentNav.tsx"), "utf8");
const selector = fs.readFileSync(path.join(root, "src/components/xingbang/IdentitySelector.tsx"), "utf8");
assert.match(nav, /response\.status===401/, "导航应识别无效访问令牌");
assert.match(nav, /removeItem\("xingbang-access-token"\)/, "无效旧令牌应自动清理");
assert.match(nav, /setItem\("xingbang-demo-role","manager"\)/, "清理后应恢复到客户经理演示身份");
assert.match(nav, /pending=\{!identity\}/, "身份连接失败时仍应显示身份选择入口");
assert.match(selector, /pending&&<option value="" disabled>选择身份<\/option>/, "待连接状态应给出明确的身份选择提示");
console.log("Identity recovery behavior checks passed");