合并分享链路重构到主分支

合入通用作品分享卡片与小程序直达路径
合入推荐页当前作品系统分享参数同步
合入小程序九宫切图与相关测试

# Conflicts:
#	.hermes/shared-memory/decision-log.md
#	docs/【开发运维】本地开发验证与生产运维-2026-05-15.md
#	docs/【玩法创作】平台入口与玩法链路-2026-05-15.md
#	src/components/custom-world-home/CustomWorldCreationHub.tsx
#	src/components/platform-entry/PlatformEntryFlowShellImpl.test.ts
#	src/components/platform-entry/PlatformEntryFlowShellImpl.tsx
#	src/components/rpg-entry/RpgEntryHomeView.tsx
This commit is contained in:
kdletters
2026-06-11 22:50:32 +08:00
35 changed files with 2185 additions and 244 deletions

View File

@@ -0,0 +1,66 @@
/* @vitest-environment jsdom */
import { afterEach, describe, expect, test, vi } from 'vitest';
import {
buildWechatMiniProgramShareTargetMessage,
postWechatMiniProgramShareTarget,
} from './wechatMiniProgramShareTarget';
afterEach(() => {
vi.restoreAllMocks();
Reflect.deleteProperty(window, 'wx');
window.history.replaceState(null, '', '/');
});
describe('wechatMiniProgramShareTarget', () => {
test('builds a compact share target message for mini program native share', () => {
expect(
buildWechatMiniProgramShareTargetMessage({
targetPath: '/works/detail',
work: ' BB-12345678 ',
title: ' 汪汪声浪 ',
}),
).toEqual({
type: 'genarrative:share-target',
payload: {
targetPath: '/works/detail',
work: 'BB-12345678',
title: '汪汪声浪',
},
});
});
test('posts the current recommended work to mini program web-view host', () => {
const postMessage = vi.fn();
window.history.replaceState(
null,
'',
'/?clientRuntime=wechat_mini_program',
);
window.wx = {
miniProgram: {
postMessage,
},
};
expect(
postWechatMiniProgramShareTarget({
targetPath: '/works/detail',
work: 'BB-12345678',
title: '汪汪声浪',
}),
).toBe(true);
expect(postMessage).toHaveBeenCalledWith({
data: {
type: 'genarrative:share-target',
payload: {
targetPath: '/works/detail',
work: 'BB-12345678',
title: '汪汪声浪',
},
},
});
});
});