Files
docs/悦/官网头程下单/tests/create-order-requirements.test.js
T
2026-09-08 18:17:00 +08:00

39 lines
2.8 KiB
JavaScript

const assert = require('node:assert/strict');
const fs = require('node:fs');
const html = fs.readFileSync('workbench.html', 'utf8');
const pageOrder = html.match(/<div class="page-content active" id="page-order">([\s\S]*?)<\/div>\n\n<!-- ========== PAGE 2:/)?.[1] || '';
assert.ok(pageOrder, 'page-order markup should exist');
assert.match(pageOrder, /onclick="setPickupTab\(this,'truck'\)"[^>]*>自送货<\/button>/);
assert.doesNotMatch(pageOrder, />自送货-快递<\/button>|>自送货-卡车<\/button>/);
assert.match(pageOrder, /<div class="form-label">快递单号<\/div>[\s\S]*?请输入快递单号/);
assert.match(pageOrder, /class="pickup-driver-row"[\s\S]*?司机姓名[\s\S]*?司机电话/);
assert.match(html, /\.pickup-driver-row \.form-group\s*\{\s*grid-template-columns:\s*96px minmax\(0, 1fr\);/);
assert.match(pageOrder, /onclick="setDestTab\(this,'fulfillment'\)"[^>]*>一件代发<\/button>/);
const fulfillmentPanel = pageOrder.match(/<div class="dest-content" id="dest-fulfillment">([\s\S]*?)<\/div>\s*<\/div>\s*<\/section>/)?.[1] || '';
assert.ok(fulfillmentPanel, 'fulfillment destination panel should exist');
assert.match(fulfillmentPanel, /LX入库单号/);
assert.match(fulfillmentPanel, /name="lxInboundNo"/);
assert.match(fulfillmentPanel, /<span class="required">\*<\/span>LX入库单号/);
assert.doesNotMatch(fulfillmentPanel, /一件代发仓|收件人姓名|收件人电话|收件地址/);
const taxSelect = pageOrder.match(/<select name="tax"[^>]*>/)?.[0] || '';
assert.ok(taxSelect, 'tax selector should exist');
assert.match(taxSelect, /\brequired\b/);
const fullContainerSelect = pageOrder.match(/<select name="fullContainer"[^>]*>[\s\S]*?<\/select>/)?.[0] || '';
assert.ok(fullContainerSelect, 'full container selector should exist');
assert.match(fullContainerSelect, /<option value="">请选择<\/option>/);
assert.match(fullContainerSelect, /<option value="是">是<\/option>/);
assert.match(fullContainerSelect, /<option value="否">否<\/option>/);
assert.doesNotMatch(fullContainerSelect.match(/^<select[^>]*>/)?.[0] || '', /\brequired\b/);
const inspectionSelect = pageOrder.match(/<select name="inspection"[^>]*>[\s\S]*?<\/select>/)?.[0] || '';
assert.ok(inspectionSelect, 'inspection selector should exist');
assert.match(inspectionSelect, /<option value="">请选择<\/option>/);
assert.match(inspectionSelect, /<option value="是">是<\/option>/);
assert.match(inspectionSelect, /<option value="否">否<\/option>/);
assert.doesNotMatch(inspectionSelect.match(/^<select[^>]*>/)?.[0] || '', /\brequired\b/);
assert.match(pageOrder, /<div class="form-label"><span class="required">\*<\/span>买单\/退税<\/div>/);
assert.doesNotMatch(pageOrder, /<div class="form-label"><span class="required">\*<\/span>是否整柜<\/div>|<div class="form-label"><span class="required">\*<\/span>是否商检<\/div>/);
console.log('create-order requirements: ok');