7ea463ed08
保留 SpacetimeDB 历史表、迁移白名单与最小兼容读取定义 移除旧创作前后端、worker、业务过程及纯业务 crate 的编译依赖 恢复现役创作、项目、我的入口及桌面移动导航 收紧 Vite、TypeScript、ESLint、Vitest 与静态资源退役边界 补齐开发栈、网关、原生壳和文档退役约束
64 lines
2.2 KiB
JavaScript
64 lines
2.2 KiB
JavaScript
import path from 'node:path';
|
|
|
|
import { describe, expect, test } from 'vitest';
|
|
|
|
import { HOST_BRIDGE_WECHAT_MINI_PROGRAM_CAPABILITIES } from '../../packages/shared/src/contracts/hostBridge.ts';
|
|
import { loadCommonJsModule } from '../test-utils/loadCommonJsModule.js';
|
|
|
|
const protocolPath = path.resolve(
|
|
process.cwd(),
|
|
'miniprogram/host-bridge/protocol.js',
|
|
);
|
|
const dispatchPath = path.resolve(
|
|
process.cwd(),
|
|
'miniprogram/host-bridge/dispatch.js',
|
|
);
|
|
const paymentPath = path.resolve(
|
|
process.cwd(),
|
|
'miniprogram/host-bridge/payment.js',
|
|
);
|
|
const shareGridPath = path.resolve(
|
|
process.cwd(),
|
|
'miniprogram/host-bridge/shareGrid.js',
|
|
);
|
|
const webViewPath = path.resolve(
|
|
process.cwd(),
|
|
'miniprogram/host-bridge/webView.js',
|
|
);
|
|
|
|
describe('wechat mini program host bridge protocol index', () => {
|
|
test('keeps native page routes and result keys centralized', () => {
|
|
const protocol = loadCommonJsModule(protocolPath);
|
|
|
|
expect(protocol.WECHAT_HOST_CAPABILITIES).toEqual(
|
|
HOST_BRIDGE_WECHAT_MINI_PROGRAM_CAPABILITIES,
|
|
);
|
|
expect(protocol.WECHAT_AUTH_PAGE_URL).toBe(
|
|
'/pages/web-view/index?authAction=login&returnTo=previous',
|
|
);
|
|
expect(protocol.WECHAT_PAY_PAGE_URL).toBe('/pages/wechat-pay/index');
|
|
expect(protocol.WECHAT_SHARE_GRID_PAGE_URL).toBe('/pages/share-grid/index');
|
|
expect(protocol.WECHAT_PAY_RESULT_HASH_KEY).toBe('wx_pay_result');
|
|
});
|
|
|
|
test('dispatch index exposes current bridge ability modules', () => {
|
|
const payment = loadCommonJsModule(paymentPath);
|
|
const protocol = loadCommonJsModule(protocolPath);
|
|
const shareGrid = loadCommonJsModule(shareGridPath);
|
|
const webView = loadCommonJsModule(webViewPath);
|
|
const dispatch = loadCommonJsModule(dispatchPath, {
|
|
'./payment': payment,
|
|
'./protocol': protocol,
|
|
'./shareGrid': shareGrid,
|
|
'./webView': webView,
|
|
});
|
|
|
|
expect(dispatch.protocol.WECHAT_PAY_PAGE_URL).toBe('/pages/wechat-pay/index');
|
|
expect(typeof dispatch.webView.resolveWebViewUrlFromRuntimeConfig).toBe(
|
|
'function',
|
|
);
|
|
expect(typeof dispatch.payment.requestWechatPayment).toBe('function');
|
|
expect(typeof dispatch.shareGrid.buildShareGridTilePlan).toBe('function');
|
|
});
|
|
});
|