import assert from 'node:assert/strict' import { readFileSync } from 'node:fs' import test from 'node:test' import { toxicArrangeBlockMessage } from '../src/utils/pl-quota-cert-waiver' const detail = readFileSync(new URL('../src/views/m/pl/plan/detail.vue', import.meta.url), 'utf8') const stopCard = readFileSync( new URL('../src/views/m/pl/plan/PlanStopReadCard.vue', import.meta.url), 'utf8' ) const loadSection = readFileSync( new URL('../src/views/m/pl/plan/MobilePlanLoadSection.vue', import.meta.url), 'utf8' ) const deliverySection = readFileSync( new URL('../src/views/m/pl/plan/MobilePlanDeliverySection.vue', import.meta.url), 'utf8' ) const certFace = readFileSync( new URL('../src/views/m/pl/plan-cert/CertFacePanel.vue', import.meta.url), 'utf8' ) const arrangeSubmit = readFileSync( new URL('../src/composables/usePlPlanArrangeSubmit.ts', import.meta.url), 'utf8' ) const formDialog = readFileSync( new URL('../src/components/business/pl-plan-form-dialog/index.vue', import.meta.url), 'utf8' ) const detailActions = readFileSync( new URL('../src/utils/mp-pl-plan-detail-actions.ts', import.meta.url), 'utf8' ) test('H5 计划详情提供查看用证入口并挂载 CertFacePanel', () => { assert.match(detail, /查看用证/) assert.match(detail, /CertFacePanel/) assert.match(detail, /quotaOpen/) }) test('H5 装送段可编辑同市,只读卡标明同市只需购买证', () => { assert.match(loadSection, /sameCity/) assert.match(deliverySection, /sameCity/) assert.match(stopCard, /同市只需购买证/) }) test('H5 用证面板新规则只读提示,且占用明细可回填证号', () => { assert.match(certFace, /客户\+品类自动选证/) assert.match(certFace, /安排不提供手工选证/) assert.match(certFace, /certNoSnapshot/) assert.match(certFace, /sourceStopProductId/) }) test('H5/共用安排提交不附带手工 quotaConfiguration', () => { assert.doesNotMatch(arrangeSubmit, /quotaConfiguration/) assert.match(formDialog, /toxicArrangeBlockMessage/) assert.match(formDialog, /buildArrangePayloadFromPlanForm/) }) test('新规则安排以服务端齐备/余量检查为准,不被本地合同绑证缺口误拦', () => { const unbound = '合同HT-1尚未绑定购买证和运输证,请先到合同中绑定后再安排运输' assert.equal( toxicArrangeBlockMessage( { certQuotaRuleVersion: 'customer_category', arrangeBlockMessage: '' }, unbound ), '' ) assert.equal( toxicArrangeBlockMessage( { certQuotaRuleVersion: 'customer_category', arrangeBlockMessage: '新规则下证书齐备只放行安排' }, unbound ), '新规则下证书齐备只放行安排' ) }) test('H5 计划详情无运输归档操作(归档在 Web;齐备完善在 plan-cert)', () => { assert.doesNotMatch(detailActions, /archive/) assert.doesNotMatch(detailActions, /归档/) assert.match(detailActions, /arrange/) })