fix(core): comprehensive fix for state loss across activity, ticket, workspace, favorites and community

这个提交包含在:
xcbyy
2026-10-13 16:01:19 +08:00
父节点 497fb65359
当前提交 1853e653fb
共有 7 个文件被更改,包括 242 次插入 和 61 次删除

查看文件

@@ -999,6 +999,75 @@ describe('ContentSecurityService & Compliance Architecture (TDD 微信内容安
expect(emojiRegex.test(fs.readFileSync(communityPath, 'utf-8'))).toBe(false);
});
});
describe('23. 全模块状态持久化与跨页面状态同步健壮性规范验证 (组局/门票/工作台/收藏/搭子)', () => {
it('API 层 normalizeUserId 与收藏/组局方法必须优先支持 Storage 用户ID', () => {
const apiPath = path.join(rootDir, 'pwuniapp', 'common', 'api.js');
const content = fs.readFileSync(apiPath, 'utf-8');
expect(content).toContain("uni.getStorageSync('userId')");
expect(content).toContain('function normalizeUserId');
expect(content).toContain('export async function getFavorites(userId)');
expect(content).toContain('export async function checkFavorite(expertId, userId)');
});
it('组局详情页必须动态响应当前用户并在 onShow 中拉取最新数据', () => {
const actDetailPath = path.join(rootDir, 'pwuniapp', 'pages', 'activity', 'detail.vue');
const content = fs.readFileSync(actDetailPath, 'utf-8');
expect(content).toContain('currentUserId');
expect(content).toContain('currentActId');
expect(content).toContain('loadLiveDetail(currentActId.value)');
expect(content).not.toContain('const CURRENT_USER_ID = 1001;');
});
it('我的门票页面必须注册 onShow 并在退票与核销时绑定动态用户', () => {
const ticketPath = path.join(rootDir, 'pwuniapp', 'pages', 'activity', 'my-ticket.vue');
const content = fs.readFileSync(ticketPath, 'utf-8');
expect(content).toContain('onShow');
expect(content).toContain('currentUserId');
expect(content).toContain('loadTicketData()');
expect(content).toContain('leaveActivity(actId, currentUserId.value)');
});
it('大神工作台接单状态必须持久化 EXPERT_RECEIVING_STATUS 并在 onShow 恢复', () => {
const wsPath = path.join(rootDir, 'pwuniapp', 'pages', 'expert', 'workspace.vue');
const content = fs.readFileSync(wsPath, 'utf-8');
expect(content).toContain('EXPERT_RECEIVING_STATUS');
expect(content).toContain("uni.setStorageSync('EXPERT_RECEIVING_STATUS'");
});
it('大神主页必须在 onShow 中刷新当前用户的收藏状态', () => {
const expertDetailPath = path.join(rootDir, 'pwuniapp', 'pages', 'expert', 'detail.vue');
const content = fs.readFileSync(expertDetailPath, 'utf-8');
expect(content).toContain('onShow');
expect(content).toContain('refreshFavoriteState');
expect(content).toContain('currentExpertTargetId');
});
it('友圈页面必须通过 COMMUNITY_APPLIED_POST_IDS 持久化申请上车状态并防重', () => {
const communityPath = path.join(rootDir, 'pwuniapp', 'pages', 'community', 'index.vue');
const content = fs.readFileSync(communityPath, 'utf-8');
expect(content).toContain('COMMUNITY_APPLIED_POST_IDS');
expect(content).toContain('btn-applied');
expect(content).toContain('syncInitialPostStates');
});
it('所有状态持久化修复代码与测试严禁包含任何系统 Emoji 违规字符', () => {
const actDetailPath = path.join(rootDir, 'pwuniapp', 'pages', 'activity', 'detail.vue');
const ticketPath = path.join(rootDir, 'pwuniapp', 'pages', 'activity', 'my-ticket.vue');
const wsPath = path.join(rootDir, 'pwuniapp', 'pages', 'expert', 'workspace.vue');
const expertDetailPath = path.join(rootDir, 'pwuniapp', 'pages', 'expert', 'detail.vue');
const communityPath = path.join(rootDir, 'pwuniapp', 'pages', 'community', 'index.vue');
const apiPath = path.join(rootDir, 'pwuniapp', 'common', 'api.js');
const emojiRegex = /(?:\p{Extended_Pictographic}|\p{Emoji_Presentation}|[\u2600-\u27BF])/u;
expect(emojiRegex.test(fs.readFileSync(actDetailPath, 'utf-8'))).toBe(false);
expect(emojiRegex.test(fs.readFileSync(ticketPath, 'utf-8'))).toBe(false);
expect(emojiRegex.test(fs.readFileSync(wsPath, 'utf-8'))).toBe(false);
expect(emojiRegex.test(fs.readFileSync(expertDetailPath, 'utf-8'))).toBe(false);
expect(emojiRegex.test(fs.readFileSync(communityPath, 'utf-8'))).toBe(false);
expect(emojiRegex.test(fs.readFileSync(apiPath, 'utf-8'))).toBe(false);
});
});
});