Files
docs/悦/货代SAAS平台后台/tests/verify-exception-dispatch-orders.cjs
T
2026-08-21 09:20:26 +08:00

28 lines
1.7 KiB
JavaScript

const assert = require('node:assert/strict');
const fs = require('node:fs');
const path = require('node:path');
const root = path.resolve(__dirname, '..');
const modulePath = path.join(root, 'prototype-src/modules/04-overseas-delivery.html');
const appPath = path.join(root, 'prototype-src/app.js');
const overlaysPath = path.join(root, 'prototype-src/overlays.html');
const shellPath = path.join(root, 'prototype-src/shell.html');
const manifest = JSON.parse(fs.readFileSync(path.join(root, 'prototype-src/manifest.json'), 'utf8'));
const moduleEntry = manifest.modules.find(item => item.file === 'modules/04-overseas-delivery.html');
const html = fs.readFileSync(modulePath, 'utf8');
const app = fs.readFileSync(appPath, 'utf8');
const overlays = fs.readFileSync(overlaysPath, 'utf8');
const shell = fs.readFileSync(shellPath, 'utf8');
assert.ok(moduleEntry.pages.includes('outbound-exception'), 'manifest 未登记异常订单页面');
assert.match(html, /id="page-outbound-exception"/, '海外派送模块缺少异常订单页面');
assert.match(shell, /switchPage\('outbound-exception',this\)/, '侧栏缺少异常订单入口');
assert.match(overlays, /id="modal-dispatch-return"/, '缺少退货处理弹窗');
assert.match(app, /function openDispatchReturn\(/, '缺少打开退货弹窗函数');
assert.match(app, /function confirmDispatchReturn\(/, '缺少保存退货处理函数');
assert.match(app, /function renderDispatchExceptions\(/, '缺少异常订单渲染函数');
assert.match(app, /abnormalType|returnStatus|rejectionReason/, '派送数据缺少异常字段');
assert.match(html, /退货|拒收/, '异常订单页缺少退货或拒收处理文案');
console.log('异常订单契约验证通过');