|
|
@@ -7,7 +7,17 @@ const pagesRoot = path.join(root, 'packageMRC', 'pages');
|
|
|
const demoState = require(path.join(root, 'packageMRC', 'common', 'mrcDemoState.js'));
|
|
|
const adapterSource = fs.readFileSync(path.join(root, 'packageMRC', 'common', 'mrcDemoState.js'), 'utf8');
|
|
|
const failures = [];
|
|
|
-const pageNames = ['my-applications', 'identity', 'record-config', 'record-select', 'manual-record', 'application-form', 'address-create', 'confirm-submit', 'order-detail', 'order-progress', 'settlement'];
|
|
|
+const requestedWave = process.env.MRC_SUBPAGE_WAVE || '1';
|
|
|
+const wavePages = {
|
|
|
+ '1': ['identity', 'record-config', 'record-select', 'manual-record', 'address-create'],
|
|
|
+ '2': ['application-form', 'confirm-submit'],
|
|
|
+ '3': ['my-applications', 'order-detail', 'order-progress', 'settlement']
|
|
|
+};
|
|
|
+assert.ok(Object.prototype.hasOwnProperty.call(wavePages, requestedWave) || requestedWave === 'all', 'MRC_SUBPAGE_WAVE 仅支持 1、2、3 或 all');
|
|
|
+const pageNames = requestedWave === 'all' ? Object.values(wavePages).flat() : wavePages[requestedWave];
|
|
|
+const runWave1 = requestedWave === '1' || requestedWave === 'all';
|
|
|
+const runWave2 = requestedWave === '2' || requestedWave === 'all';
|
|
|
+const runWave3 = requestedWave === '3' || requestedWave === 'all';
|
|
|
|
|
|
function expect(condition, message) {
|
|
|
if (!condition) failures.push(message);
|
|
|
@@ -91,6 +101,10 @@ function tap(key, value) {
|
|
|
return { currentTarget: { dataset: { [key]: value } } };
|
|
|
}
|
|
|
|
|
|
+function dataset(values) {
|
|
|
+ return { currentTarget: { dataset: values } };
|
|
|
+}
|
|
|
+
|
|
|
function input(key, value) {
|
|
|
return { currentTarget: { dataset: { key } }, detail: { value } };
|
|
|
}
|
|
|
@@ -123,14 +137,14 @@ global.wx = {
|
|
|
uploadFile() { calls.external.push('uploadFile'); }
|
|
|
};
|
|
|
|
|
|
-if (typeof originalCreateAnonymousAddress === 'function') {
|
|
|
+if (runWave1 && typeof originalCreateAnonymousAddress === 'function') {
|
|
|
demoState.createAnonymousAddress = function spyCreateAnonymousAddress(...args) {
|
|
|
addressAdapterCalls.push(args);
|
|
|
const result = originalCreateAnonymousAddress.apply(this, args);
|
|
|
addressAdapterReturns.push(result);
|
|
|
return result;
|
|
|
};
|
|
|
-} else {
|
|
|
+} else if (runWave1) {
|
|
|
failures.push('MRC Demo Adapter 必须提供 createAnonymousAddress,用于地址页的本地匿名回填');
|
|
|
}
|
|
|
|
|
|
@@ -149,6 +163,7 @@ try {
|
|
|
expect(calls.navigateBack.length === before + 1, `${name} 返回导航必须触发 wx.navigateBack`);
|
|
|
});
|
|
|
|
|
|
+ if (runWave3) {
|
|
|
const list = mounted['my-applications'];
|
|
|
demoState.activateScenario({ scenarioId: 'SCN-PENDING-AUDIT' });
|
|
|
invoke(list, 'onShow', {}, '我的申请刷新');
|
|
|
@@ -165,7 +180,9 @@ try {
|
|
|
const emptyApplyHandler = boundHandler('my-applications', 'empty-apply-btn', 'bindtap', '空态去申请');
|
|
|
invoke(list, emptyApplyHandler, {}, '空态去申请');
|
|
|
expect(calls.navigateTo.some((item) => item.url === '/packageMRC/pages/apply-entry/index'), '空态去申请必须返回患者申请入口');
|
|
|
+ }
|
|
|
|
|
|
+ if (runWave1) {
|
|
|
const identity = mounted.identity;
|
|
|
invoke(identity, 'onLoad', {}, '身份页初始化');
|
|
|
const identityHandler = boundHandler('identity', 'identity-option', 'bindtap', '身份选项');
|
|
|
@@ -179,7 +196,7 @@ try {
|
|
|
const agentRelationHandler = boundHandler('identity', 'agent-relation-option', 'bindtap', '代理人关系选择');
|
|
|
invoke(identity, agentNameHandler, input('agentName', 'IDENTITY_AGENT_NAME_RAW'), '代理人姓名输入');
|
|
|
invoke(identity, agentPhoneHandler, input('agentPhone', '13800138000'), '代理人手机号输入');
|
|
|
- invoke(identity, agentRelationHandler, tap('relation', 'spouse'), '代理人关系选择');
|
|
|
+ invoke(identity, agentRelationHandler, dataset({ key: 'agentRelation', relation: 'spouse' }), '代理人关系选择');
|
|
|
assertSnapshotExcludes(['IDENTITY_AGENT_NAME_RAW'], '代理人');
|
|
|
invoke(identity, materialHandler, tap('material', 'authorization'), '代理人材料点击');
|
|
|
expect(/演示材料|不支持上传/.test(identity.data.materialNotice || identity.data.noticeMessage || ''), '材料点击必须显示匿名演示或不可上传反馈');
|
|
|
@@ -193,7 +210,7 @@ try {
|
|
|
const heirRelationHandler = boundHandler('identity', 'heir-relation-option', 'bindtap', '继承人关系选择');
|
|
|
invoke(identity, heirNameHandler, input('heirName', 'IDENTITY_HEIR_NAME_RAW'), '继承人姓名输入');
|
|
|
invoke(identity, heirPhoneHandler, input('heirPhone', '13900139000'), '继承人手机号输入');
|
|
|
- invoke(identity, heirRelationHandler, tap('relation', 'child'), '继承人关系选择');
|
|
|
+ invoke(identity, heirRelationHandler, dataset({ key: 'heirRelation', relation: 'child' }), '继承人关系选择');
|
|
|
assertSnapshotExcludes(['IDENTITY_HEIR_NAME_RAW'], '继承人');
|
|
|
invoke(identity, identityNext, {}, '继承人完整下一步');
|
|
|
|
|
|
@@ -201,9 +218,9 @@ try {
|
|
|
invoke(config, 'onLoad', {}, '复印内容初始化');
|
|
|
demoState.updateDraft({ selectedRecordIds: ['demo-1'] });
|
|
|
invoke(config, 'onShow', {}, '复印内容记录回填');
|
|
|
- const modeHandler = boundHandler('record-config', 'record-package-card', 'bindtap', '套餐/自定义内容选择');
|
|
|
- invoke(config, modeHandler, tap('mode', 'custom'), '自定义内容切换');
|
|
|
- expect(config.data.mode === 'custom', '套餐/自定义选择必须更新页面本地状态');
|
|
|
+ const packageHandler = boundHandler('record-config', 'record-package-card', 'bindtap', '首条记录套餐选择');
|
|
|
+ invoke(config, packageHandler, tap('package', 'inpatient-standard'), '首条记录套餐选择');
|
|
|
+ expect((config.data.recordConfigs || [])[0] && config.data.recordConfigs[0].mode === 'package', '套餐选择必须更新首条记录的本地配置状态');
|
|
|
const recordEntryHandler = boundHandler('record-config', 'record-select-entry', 'bindtap', '选择就诊记录入口');
|
|
|
invoke(config, recordEntryHandler, {}, '选择就诊记录入口');
|
|
|
expect(calls.navigateTo.some((item) => /^\/packageMRC\/pages\/record-select\/index\?revision=\d+$/.test(item.url || '')), '复印内容页必须带 revision 进入记录选择');
|
|
|
@@ -246,20 +263,9 @@ try {
|
|
|
const manualBackBefore = calls.navigateBack.length;
|
|
|
invoke(manual, manualSaveHandler, {}, '完整手录保存');
|
|
|
expect(calls.navigateBack.length === manualBackBefore + 1, '完整手录保存必须返回复印内容页');
|
|
|
+ }
|
|
|
|
|
|
- const form = mounted['application-form'];
|
|
|
- invoke(form, 'onLoad', {}, '申请表单初始化');
|
|
|
- const purposeHandler = boundHandler('application-form', 'purpose-input', 'bindinput', '申请用途输入');
|
|
|
- const copiesHandler = boundHandler('application-form', 'copies-input', 'bindinput', '复印份数输入');
|
|
|
- const deliveryHandler = boundHandler('application-form', 'delivery-card', 'bindtap', '领取方式选择');
|
|
|
- invoke(form, purposeHandler, input('purpose', '个人留存'), '申请用途输入');
|
|
|
- invoke(form, copiesHandler, input('copies', '2'), '复印份数输入');
|
|
|
- invoke(form, deliveryHandler, tap('mode', 'express'), '快递领取方式');
|
|
|
- expect(form.data.deliveryMode === 'express' && Number(form.data.copies) === 2, '申请用途、份数和领取方式必须更新页面状态');
|
|
|
- const addressEntryHandler = boundHandler('application-form', 'address-entry', 'bindtap', '新增地址入口');
|
|
|
- invoke(form, addressEntryHandler, {}, '新增地址入口');
|
|
|
- expect(calls.navigateTo.some((item) => /^\/packageMRC\/pages\/address-create\/index\?returnTo=application-form&revision=\d+$/.test(item.url || '')), '申请表单必须带 revision 跳转新增地址页');
|
|
|
-
|
|
|
+ if (runWave1) {
|
|
|
const address = mounted['address-create'];
|
|
|
invoke(address, 'onLoad', { returnTo: 'application-form' }, '地址页初始化');
|
|
|
const addressSaveHandler = boundHandler('address-create', 'primary-action', 'bindtap', '新增并使用');
|
|
|
@@ -297,7 +303,24 @@ try {
|
|
|
expect(Boolean(result && result.ok && result.data && /匿名|演示/.test(result.data.addressLabel || '')), '匿名地址 Adapter 只能返回带匿名地址标签的成功结果');
|
|
|
});
|
|
|
assertSnapshotExcludes(Object.values(rawAddress), '地址回填后');
|
|
|
- invoke(form, 'onShow', {}, '地址回填后的表单刷新');
|
|
|
+ expect(/匿名|演示/.test((demoState.getDraft().data || {}).addressLabel || ''), '匿名地址保存后 Adapter 草稿只能保留匿名地址标签');
|
|
|
+ }
|
|
|
+
|
|
|
+ if (runWave2) {
|
|
|
+ const form = mounted['application-form'];
|
|
|
+ invoke(form, 'onLoad', {}, '申请表单初始化');
|
|
|
+ const purposeHandler = boundHandler('application-form', 'purpose-input', 'bindinput', '申请用途输入');
|
|
|
+ const copiesHandler = boundHandler('application-form', 'copies-input', 'bindinput', '复印份数输入');
|
|
|
+ const deliveryHandler = boundHandler('application-form', 'delivery-card', 'bindtap', '领取方式选择');
|
|
|
+ invoke(form, purposeHandler, input('purpose', '个人留存'), '申请用途输入');
|
|
|
+ invoke(form, copiesHandler, input('copies', '2'), '复印份数输入');
|
|
|
+ invoke(form, deliveryHandler, tap('mode', 'express'), '快递领取方式');
|
|
|
+ expect(form.data.deliveryMode === 'express' && Number(form.data.copies) === 2, '申请用途、份数和领取方式必须更新页面状态');
|
|
|
+ const addressEntryHandler = boundHandler('application-form', 'address-entry', 'bindtap', '新增地址入口');
|
|
|
+ invoke(form, addressEntryHandler, {}, '新增地址入口');
|
|
|
+ expect(calls.navigateTo.some((item) => /^\/packageMRC\/pages\/address-create\/index\?returnTo=application-form&revision=\d+$/.test(item.url || '')), '申请表单必须带 revision 跳转新增地址页');
|
|
|
+ demoState.updateDraft({ addressLabel: '演示匿名收货地址(不保存真实地址)' });
|
|
|
+ if (typeof form.onShow === 'function') form.onShow();
|
|
|
expect(/匿名|演示/.test(form.data.addressLabel || ''), '申请表单回填只能显示匿名地址标签');
|
|
|
const formNextHandler = boundHandler('application-form', 'primary-action', 'bindtap', '申请表单下一步');
|
|
|
invoke(form, formNextHandler, {}, '申请表单下一步');
|
|
|
@@ -313,8 +336,12 @@ try {
|
|
|
invoke(confirm, agreementHandler, {}, '协议确认');
|
|
|
invoke(confirm, submitHandler, {}, '同意协议提交');
|
|
|
expect(confirm.data.submitted === true && /^MRC-DEMO-/.test(confirm.data.orderId || ''), '协议确认后必须创建本地 MRC-DEMO 订单');
|
|
|
- const createdOrderId = confirm.data.orderId;
|
|
|
+ }
|
|
|
|
|
|
+ if (runWave3) {
|
|
|
+ const created = demoState.createApplication({ identityType: 'self', payMode: 'notify', deliveryMode: 'express' });
|
|
|
+ expect(created.ok && /^MRC-DEMO-/.test(created.data.order.orderId || ''), '第三波测试必须准备本地匿名订单 fixture');
|
|
|
+ const createdOrderId = created.ok ? created.data.order.orderId : '';
|
|
|
const detail = mounted['order-detail'];
|
|
|
invoke(detail, 'onLoad', { orderId: createdOrderId }, '详情初始化');
|
|
|
const progressHandler = boundHandler('order-detail', 'progress-action', 'bindtap', '详情查看进度');
|
|
|
@@ -339,6 +366,7 @@ try {
|
|
|
expect(createdOrder && createdOrder.status === 'pending_audit', '支付受限反馈不得改变订单状态');
|
|
|
const settlementBack = boundHandler('settlement', 'primary-action', 'bindtap', '结算返回详情');
|
|
|
invoke(settlement, settlementBack, {}, '结算返回详情');
|
|
|
+ }
|
|
|
|
|
|
expect(calls.external.length === 0, `全链本地 Demo 不得触发外部 API:${calls.external.join(', ')}`);
|
|
|
} finally {
|
|
|
@@ -351,4 +379,4 @@ if (failures.length) {
|
|
|
throw new Error(`MRC 子页面交互契约失败:\n- ${failures.join('\n- ')}`);
|
|
|
}
|
|
|
|
|
|
-console.log('mrc-subpage-interaction-contract.test.js: passed');
|
|
|
+console.log(`mrc-subpage-interaction-contract.test.js: wave ${requestedWave} passed`);
|