|
|
@@ -21,9 +21,9 @@ function readOptional(filePath) {
|
|
|
}
|
|
|
|
|
|
function assertNoForbiddenCapability(source, scope) {
|
|
|
- expect(!/\bwx\.request\b/.test(source), `${scope}不得使用 wx.request 网络能力`);
|
|
|
+ expect(!/\bwx\.(?:request|downloadFile|connectSocket)\b|\bwx\.cloud\.callFunction\b/.test(source), `${scope}不得使用请求、下载、长连接或云函数网络能力`);
|
|
|
expect(!/\bwx\.\w*Storage\w*\b/i.test(source), `${scope}不得使用任意 wx.*Storage*(包括 getStorageInfo)能力`);
|
|
|
- expect(!/\bwx\.(?:upload\w*|choose(?:Image|Video|Media|MessageFile)|openDocument|saveImageToPhotosAlbum)\b/.test(source), `${scope}不得使用上传、选择图片/视频/文件等能力`);
|
|
|
+ expect(!/\bwx\.(?:upload\w*|choose(?:Image|Media|Video|MessageFile|Address|Location|Invoice|Avatar)|getLocation|openDocument|saveImageToPhotosAlbum)\b/.test(source), `${scope}不得使用上传、选择图片/视频/文件/地址/位置/发票/头像等能力`);
|
|
|
expect(!/\bconsole\.\w+\b/.test(source), `${scope}不得写入 console,避免泄漏本地输入`);
|
|
|
expect(!/(?:utils\/(?:patientMaintenance|patientSelector|homePatient)|pages\/mine\/patientEdit)/.test(source), `${scope}不得引用既有就诊人服务或页面`);
|
|
|
}
|
|
|
@@ -119,6 +119,8 @@ const adapterSource = readOptional(adapterPath);
|
|
|
expect(Boolean(applyEntryTemplate), '申请入口 WXML 必须存在');
|
|
|
expect(Boolean(patientCreateTemplate), '本地 Mock 添加就诊人页必须提供可操作表单');
|
|
|
expect(Boolean(patientCreateScript), '本地 Mock 添加就诊人页必须存在,当前交互契约应保持 RED 直至该页实现');
|
|
|
+expect(!/setPatientsForTest/.test(`${applyEntryTemplate}\n${readOptional(applyEntryScriptPath)}`), '申请入口 UI 源码不得引用仅测试可用的 setPatientsForTest');
|
|
|
+expect(!/setPatientsForTest/.test(`${patientCreateTemplate}\n${patientCreateScript}`), '添加就诊人 UI 源码不得引用仅测试可用的 setPatientsForTest');
|
|
|
|
|
|
const serviceHandler = tagBindingForClass(applyEntryTemplate, 'service-btn', '服务 CTA');
|
|
|
const applicationHandler = tagBindingForClass(applyEntryTemplate, 'my-application-card', '我的申请');
|
|
|
@@ -158,28 +160,40 @@ try {
|
|
|
const applyDefinition = loadPage(applyEntryScriptPath, '申请入口');
|
|
|
const applyPage = applyDefinition && mountPage(applyDefinition);
|
|
|
if (applyPage && typeof demoState.setPatientsForTest === 'function') {
|
|
|
- demoState.setPatientsForTest({ patients: [], currentPatientId: '' });
|
|
|
+ let unsafeFixtureRejected = false;
|
|
|
+ try {
|
|
|
+ const unsafeFixture = demoState.setPatientsForTest({
|
|
|
+ patients: [{ id: 'unsafe-patient', displayName: 'PATIENT_INPUT_NAME_MUST_NOT_PERSIST', mobile: '13800138000' }],
|
|
|
+ currentPatientId: 'unsafe-patient'
|
|
|
+ });
|
|
|
+ unsafeFixtureRejected = Boolean(unsafeFixture && unsafeFixture.ok === false);
|
|
|
+ } catch (error) {
|
|
|
+ unsafeFixtureRejected = true;
|
|
|
+ }
|
|
|
+ expect(unsafeFixtureRejected, 'setPatientsForTest 必须拒绝含患者原始信息的任意对象参数');
|
|
|
+
|
|
|
+ const emptyFixture = demoState.setPatientsForTest('EMPTY');
|
|
|
+ expect(emptyFixture && emptyFixture.ok === true, 'setPatientsForTest 只能接受固定匿名 EMPTY fixture');
|
|
|
invoke(applyPage, 'onShow', {}, '无就诊人入口刷新');
|
|
|
invoke(applyPage, serviceHandler, {}, '无就诊人服务 CTA');
|
|
|
expect(applyPage.data.showNoPatientGuide === true, '无就诊人点击“我要申请复印”必须展示本地添加引导/弹层');
|
|
|
invoke(applyPage, patientAddHandler, {}, '无就诊人添加');
|
|
|
expect(navigations.some((item) => item.url === '/packageMRC/pages/patient-create/index'), '无就诊人添加必须实际导航到本地 patient-create 页面');
|
|
|
|
|
|
- demoState.setPatientsForTest({
|
|
|
- patients: [
|
|
|
- { id: 'test-patient-a', displayName: '演示就诊人 A', tag: '默认' },
|
|
|
- { id: 'test-patient-b', displayName: '演示就诊人 B', tag: '本人' }
|
|
|
- ],
|
|
|
- currentPatientId: 'test-patient-a'
|
|
|
- });
|
|
|
+ const twoAnonymousFixture = demoState.setPatientsForTest('TWO_ANONYMOUS');
|
|
|
+ expect(twoAnonymousFixture && twoAnonymousFixture.ok === true, 'setPatientsForTest 只能接受固定匿名 TWO_ANONYMOUS fixture');
|
|
|
invoke(applyPage, 'onShow', {}, '有就诊人入口刷新');
|
|
|
- expect((applyPage.data.currentPatient || {}).id === 'test-patient-a', '入口 onShow 必须从本地 Adapter 回填当前就诊人');
|
|
|
+ expect(applyPage.data.currentPatient && /演示就诊人/.test(applyPage.data.currentPatient.displayName || ''), '入口 onShow 必须从本地 Adapter 回填匿名当前就诊人');
|
|
|
|
|
|
invoke(applyPage, patientSelectorHandler, {}, '就诊人选择');
|
|
|
expect(applyPage.data.showPatientSheet === true, '点击当前就诊人必须打开底部选择抽屉');
|
|
|
- invoke(applyPage, patientSheetHandler, { currentTarget: { dataset: { id: 'test-patient-b' } } }, '就诊人抽屉选项');
|
|
|
- expect(applyPage.data.showPatientSheet === false, '选择就诊人后必须关闭底部抽屉');
|
|
|
- expect((applyPage.data.currentPatient || {}).id === 'test-patient-b', '选择就诊人后必须回填当前就诊人卡片');
|
|
|
+ const alternativePatient = (applyPage.data.patients || []).find((patient) => patient.id !== (applyPage.data.currentPatient || {}).id);
|
|
|
+ expect(Boolean(alternativePatient), 'TWO_ANONYMOUS fixture 必须提供两名匿名就诊人');
|
|
|
+ if (alternativePatient) {
|
|
|
+ invoke(applyPage, patientSheetHandler, { currentTarget: { dataset: { id: alternativePatient.id } } }, '就诊人抽屉选项');
|
|
|
+ expect(applyPage.data.showPatientSheet === false, '选择就诊人后必须关闭底部抽屉');
|
|
|
+ expect((applyPage.data.currentPatient || {}).id === alternativePatient.id, '选择就诊人后必须回填当前就诊人卡片');
|
|
|
+ }
|
|
|
|
|
|
invoke(applyPage, demoEntryHandler, {}, 'Demo 模式入口');
|
|
|
expect(applyPage.data.showDemoMode === true, '点击 Demo 模式入口必须打开辅助面板');
|
|
|
@@ -199,9 +213,9 @@ try {
|
|
|
const originalCreate = demoState.createAnonymousPatient;
|
|
|
let createCalls = [];
|
|
|
if (typeof originalCreate === 'function') {
|
|
|
- demoState.createAnonymousPatient = (input) => {
|
|
|
- createCalls.push(input);
|
|
|
- return originalCreate(input);
|
|
|
+ demoState.createAnonymousPatient = (...args) => {
|
|
|
+ createCalls.push(args);
|
|
|
+ return originalCreate.apply(demoState, args);
|
|
|
};
|
|
|
} else {
|
|
|
failures.push('Demo Adapter 必须提供 createAnonymousPatient,且不能写入原始表单值');
|
|
|
@@ -219,6 +233,7 @@ try {
|
|
|
invoke(patientPage, patientAgreementHandler, {}, '隐私协议确认');
|
|
|
invoke(patientPage, patientSubmitHandler, {}, '有效表单提交');
|
|
|
expect(createCalls.length === 1, '有效表单提交必须恰好调用一次 createAnonymousPatient');
|
|
|
+ expect(createCalls.length === 1 && createCalls[0].length === 0, 'patient-create 调用 createAnonymousPatient 时不得传入姓名、证件号、手机号或任意表单 payload');
|
|
|
expect(backs.length > 0, '匿名就诊人创建成功后必须 navigateBack 返回申请入口');
|
|
|
invoke(applyPage, 'onShow', {}, 'patient-create 返回后的入口刷新');
|
|
|
expect(applyPage.data.currentPatient && /演示就诊人/.test(applyPage.data.currentPatient.displayName || ''), 'patient-create 返回后入口 onShow 必须回填匿名就诊人');
|
|
|
@@ -235,7 +250,7 @@ if (typeof demoState.getSnapshot === 'function') {
|
|
|
const snapshotResult = demoState.getSnapshot();
|
|
|
expect(snapshotResult && snapshotResult.ok, '匿名患者创建后必须能读取 Demo Adapter 快照');
|
|
|
const snapshotText = JSON.stringify(snapshotResult && snapshotResult.data);
|
|
|
- ['测试姓名', '110101199001011234', '13800138000'].forEach((input) => {
|
|
|
+ ['PATIENT_INPUT_NAME_MUST_NOT_PERSIST', '测试姓名', '110101199001011234', '13800138000'].forEach((input) => {
|
|
|
expect(!snapshotText.includes(input), `Adapter 快照不得包含 patient-create 的原始输入:${input}`);
|
|
|
});
|
|
|
}
|