- 新增 common/subscribe.js:页面预加载模板ID + 点击动作中同步请求授权(避免 await 丢失手势上下文) - 下单支付前请求订单状态/核销码模板;提现前请求到账模板;组局报名确认后请求报名模板 - 自动过滤 tmpl_ 占位模板;授权失败不阻塞业务 - 新增回归护栏 subscribe-authorization.spec.ts(80 套件/615 用例全绿)
41 行
1.8 KiB
TypeScript
41 行
1.8 KiB
TypeScript
// 已读取AGENTS.md
|
|
import * as fs from 'fs';
|
|
import * as path from 'path';
|
|
|
|
/**
|
|
* 第六十四批回归闸门:关键动作前补订阅消息授权
|
|
*/
|
|
describe('第六十四批订阅授权补请求闸门', () => {
|
|
const rootDir = path.resolve(__dirname, '../../');
|
|
const read = (rel: string) => fs.readFileSync(path.join(rootDir, rel), 'utf-8');
|
|
|
|
const subscribeUtil = read('pwuniapp/common/subscribe.js');
|
|
const orderCreate = read('pwuniapp/pages/order/create.vue');
|
|
const withdraw = read('pwuniapp/pages/user/withdraw.vue');
|
|
const activityDetail = read('pwuniapp/pages/activity/detail.vue');
|
|
|
|
it('通用订阅工具:预加载 + 按场景请求 + 过滤占位模板', () => {
|
|
expect(subscribeUtil).toContain('export async function preloadSubscribeTemplates(');
|
|
expect(subscribeUtil).toContain('export function requestSubscribeFor(');
|
|
expect(subscribeUtil).toContain("order: ['orderStatusTemplateId', 'verifyCodeTemplateId']");
|
|
expect(subscribeUtil).toContain("withdraw: ['withdrawSuccessTemplateId']");
|
|
expect(subscribeUtil).toContain("activity: ['activityJoinTemplateId']");
|
|
expect(subscribeUtil).toContain("startsWith('tmpl_')");
|
|
});
|
|
|
|
it('下单页在支付前请求授权并预加载模板', () => {
|
|
expect(orderCreate).toContain('preloadSubscribeTemplates()');
|
|
expect(orderCreate).toContain("requestSubscribeFor('order')");
|
|
});
|
|
|
|
it('提现页在提交前请求授权并预加载模板', () => {
|
|
expect(withdraw).toContain('preloadSubscribeTemplates()');
|
|
expect(withdraw).toContain("requestSubscribeFor('withdraw')");
|
|
});
|
|
|
|
it('组局报名在确认后请求授权并预加载模板', () => {
|
|
expect(activityDetail).toContain('preloadSubscribeTemplates()');
|
|
expect(activityDetail).toContain("requestSubscribeFor('activity')");
|
|
});
|
|
});
|