2026-10-23 09:49:36 +08:00
|
|
|
|
'use strict';
|
2026-12-05 07:38:51 -08:00
|
|
|
|
const { createBrowserContext } = require('./fixtures/browser-context.cjs');
|
2026-12-04 08:58:53 -08:00
|
|
|
|
const test = require('node:test'),
|
|
|
|
|
|
assert = require('node:assert/strict'),
|
|
|
|
|
|
fs = require('node:fs'),
|
|
|
|
|
|
path = require('node:path'),
|
|
|
|
|
|
vm = require('node:vm');
|
|
|
|
|
|
const { randomUUID } = require('node:crypto'),
|
|
|
|
|
|
Calc = require('../public/calculations'),
|
|
|
|
|
|
Fees = require('../public/fee-estimates'),
|
|
|
|
|
|
Templates = require('../public/order-templates'),
|
|
|
|
|
|
Copy = require('../public/order-copy');
|
|
|
|
|
|
const D = '2026-10-23',
|
|
|
|
|
|
ID = '11111111-1111-4111-8111-111111111111';
|
|
|
|
|
|
function draft(extra = {}) {
|
|
|
|
|
|
return {
|
|
|
|
|
|
date: D,
|
|
|
|
|
|
customer: '合成客户',
|
|
|
|
|
|
internal_note: '测试内部备注',
|
|
|
|
|
|
salesperson: '合成开单人',
|
|
|
|
|
|
payment_account: '助理微信',
|
|
|
|
|
|
rounding_mode: 'cent',
|
|
|
|
|
|
discount: '0',
|
|
|
|
|
|
note: '',
|
|
|
|
|
|
fee_items: [],
|
|
|
|
|
|
fee_auto_initialized: true,
|
|
|
|
|
|
lines: [
|
|
|
|
|
|
{
|
|
|
|
|
|
name: '足金999',
|
|
|
|
|
|
unit: 'g',
|
|
|
|
|
|
quantity: '1.000',
|
|
|
|
|
|
pocket: '',
|
|
|
|
|
|
payer: 'owner',
|
|
|
|
|
|
pricingMode: 'manual',
|
|
|
|
|
|
baseSale: '100',
|
|
|
|
|
|
sale: '100',
|
|
|
|
|
|
charges: [],
|
|
|
|
|
|
costParts: { material: '40', labor: '0', accessories: '0', other: '0' },
|
|
|
|
|
|
costMaterial: { mode: 'total' },
|
|
|
|
|
|
costLabor: { mode: 'total' },
|
|
|
|
|
|
costPayers: { material: 'owner', labor: 'assistant' },
|
|
|
|
|
|
},
|
|
|
|
|
|
],
|
|
|
|
|
|
...extra,
|
|
|
|
|
|
};
|
|
|
|
|
|
}
|
|
|
|
|
|
function harness() {
|
|
|
|
|
|
const nodes = new Map([
|
|
|
|
|
|
['#main', { innerHTML: '' }],
|
|
|
|
|
|
['#order-error', { innerHTML: '' }],
|
|
|
|
|
|
['#price-lock-error', { innerHTML: '' }],
|
|
|
|
|
|
]),
|
|
|
|
|
|
saved = new Map(),
|
|
|
|
|
|
calls = [];
|
2026-12-05 07:38:51 -08:00
|
|
|
|
const context = createBrowserContext({
|
2026-12-04 08:58:53 -08:00
|
|
|
|
console,
|
|
|
|
|
|
LedgerCalc: Calc,
|
|
|
|
|
|
FeeEstimates: Fees,
|
|
|
|
|
|
OrderTemplates: Templates,
|
|
|
|
|
|
OrderCopy: Copy,
|
|
|
|
|
|
crypto: { randomUUID },
|
|
|
|
|
|
setInterval() {},
|
|
|
|
|
|
setTimeout() {},
|
|
|
|
|
|
clearTimeout() {},
|
|
|
|
|
|
document: {
|
|
|
|
|
|
querySelector: selector => nodes.get(selector) || null,
|
|
|
|
|
|
querySelectorAll: () => [],
|
|
|
|
|
|
addEventListener() {},
|
|
|
|
|
|
},
|
|
|
|
|
|
window: { scrollTo() {} },
|
|
|
|
|
|
localStorage: {
|
|
|
|
|
|
getItem: key => saved.get(key) ?? null,
|
|
|
|
|
|
setItem: (key, value) => saved.set(key, String(value)),
|
|
|
|
|
|
removeItem: key => saved.delete(key),
|
|
|
|
|
|
},
|
|
|
|
|
|
sessionStorage: {
|
|
|
|
|
|
getItem() {
|
|
|
|
|
|
return null;
|
|
|
|
|
|
},
|
|
|
|
|
|
setItem() {},
|
|
|
|
|
|
},
|
|
|
|
|
|
__calls: calls,
|
|
|
|
|
|
__draft: draft(),
|
|
|
|
|
|
});
|
|
|
|
|
|
const run = code => vm.runInContext(code, context),
|
|
|
|
|
|
json = code => JSON.parse(JSON.stringify(run(code)));
|
|
|
|
|
|
for (const file of [
|
|
|
|
|
|
'order-templates-ui.js',
|
|
|
|
|
|
'price-locks-ui.js',
|
|
|
|
|
|
'material-pools-ui.js',
|
|
|
|
|
|
'order-edit-ui.js',
|
|
|
|
|
|
'app.js',
|
|
|
|
|
|
])
|
|
|
|
|
|
run(fs.readFileSync(path.join(__dirname, '../public', file), 'utf8').replace(/\ninit\(\);\s*$/, ''));
|
|
|
|
|
|
run(
|
|
|
|
|
|
`session={user:{id:'fields-owner',name:'麦麦',role:'owner'}};state={user:session.user,today:'${D}',pockets:['现货','金料']};updateTotal=function(){};updatePaperNumber=function(){};loadMaterialPoolChoices=function(){};loadOrderTemplates=function(){};syncPriceLockForm=function(){};toast=function(){};mutate=async function(url,input){__calls.push({url,input});return {id:'${ID}'};};finishOrderEditSave=async function(){};finishPriceLockSave=async function(){};`,
|
|
|
|
|
|
);
|
|
|
|
|
|
return { nodes, saved, calls, context, run, json };
|
|
|
|
|
|
}
|
|
|
|
|
|
function required(html, name) {
|
|
|
|
|
|
assert.match(html, new RegExp('<input name="' + name + '"[^>]*\\brequired\\b'));
|
2026-10-23 09:49:36 +08:00
|
|
|
|
}
|
|
|
|
|
|
|
2026-12-04 08:58:53 -08:00
|
|
|
|
test('普通开单、两种修改、锁价创建的客户与开单人都有原生必填提示', () => {
|
|
|
|
|
|
const h = harness();
|
|
|
|
|
|
h.run('editDraft=__draft;renderCreate()');
|
|
|
|
|
|
let html = h.nodes.get('#main').innerHTML;
|
|
|
|
|
|
required(html, 'customer');
|
|
|
|
|
|
required(html, 'salesperson');
|
|
|
|
|
|
assert.match(html, /客户称呼/代号(必填)/);
|
|
|
|
|
|
assert.match(html, /开单人(必填)/);
|
|
|
|
|
|
for (const financialEditable of [true, false]) {
|
|
|
|
|
|
h.context.__response = {
|
|
|
|
|
|
eligible: true,
|
|
|
|
|
|
revision: 1,
|
|
|
|
|
|
financialEditable,
|
|
|
|
|
|
inputs: draft(),
|
|
|
|
|
|
order: {
|
|
|
|
|
|
id: ID,
|
|
|
|
|
|
revision: 1,
|
|
|
|
|
|
date: D,
|
|
|
|
|
|
number: 'XS-001',
|
|
|
|
|
|
paper_number: '20261023001',
|
|
|
|
|
|
customer: '合成客户',
|
|
|
|
|
|
internal_note: '测试内部备注',
|
|
|
|
|
|
salesperson: '合成开单人',
|
|
|
|
|
|
payment_account: '助理微信',
|
|
|
|
|
|
rounding_mode: 'cent',
|
|
|
|
|
|
total: 10000,
|
|
|
|
|
|
directCost: 0,
|
|
|
|
|
|
lines: [],
|
|
|
|
|
|
},
|
|
|
|
|
|
};
|
|
|
|
|
|
h.run(`tab='order-edit';useOrderEditResponse('${ID}',__response,null);renderOrderEditForm()`);
|
|
|
|
|
|
html = h.nodes.get('#main').innerHTML;
|
|
|
|
|
|
required(html, 'customer');
|
|
|
|
|
|
required(html, 'salesperson');
|
2026-10-23 09:49:36 +08:00
|
|
|
|
}
|
2026-12-04 08:58:53 -08:00
|
|
|
|
h.run("tab='create';renderPriceLockCreate()");
|
|
|
|
|
|
html = h.nodes.get('#main').innerHTML;
|
|
|
|
|
|
required(html, 'customer');
|
|
|
|
|
|
required(html, 'salesperson');
|
|
|
|
|
|
assert.match(html, /开单人(必填)/);
|
2026-10-23 09:49:36 +08:00
|
|
|
|
});
|
|
|
|
|
|
|
2026-12-04 08:58:53 -08:00
|
|
|
|
test('客户与开单人不能只填空格,统一trim后提交且保留称呼代号内容', () => {
|
|
|
|
|
|
const h = harness();
|
|
|
|
|
|
for (const key of ['customer', 'salesperson'])
|
|
|
|
|
|
for (const blank of ['', null, ' ', '\t\n', ' ']) {
|
|
|
|
|
|
h.context.__draft = draft({ [key]: blank });
|
|
|
|
|
|
assert.throws(
|
|
|
|
|
|
() => h.run('validateIssueDraft(__draft)'),
|
|
|
|
|
|
new RegExp(key === 'customer' ? '客户称呼/代号必填' : '开单人必填'),
|
|
|
|
|
|
);
|
|
|
|
|
|
}
|
|
|
|
|
|
h.context.__draft = draft({ customer: ' 编号 001 ', internal_note: '测试内部备注', salesperson: ' 麦麦 ' });
|
|
|
|
|
|
assert.deepEqual(h.json('validateIssueDraft(__draft).customer'), '编号 001');
|
|
|
|
|
|
assert.equal(h.run('validateIssueDraft(__draft).salesperson'), '麦麦');
|
|
|
|
|
|
h.context.__draft = draft({ customer: '客'.repeat(61) });
|
|
|
|
|
|
assert.throws(() => h.run('validateIssueDraft(__draft)'), /1~60/);
|
|
|
|
|
|
h.context.__draft = draft({ internal_note: '测试内部备注', salesperson: '名'.repeat(31) });
|
|
|
|
|
|
assert.throws(() => h.run('validateIssueDraft(__draft)'), /1~30/);
|
|
|
|
|
|
assert.equal(h.calls.length, 0);
|
2026-10-23 09:49:36 +08:00
|
|
|
|
});
|
|
|
|
|
|
|
2026-12-04 08:58:53 -08:00
|
|
|
|
test('基本资料修改也拒绝空客户或空开单人,正常提交发送trim后的值', async () => {
|
|
|
|
|
|
const h = harness(),
|
|
|
|
|
|
fields = {
|
|
|
|
|
|
customer: { value: ' ' },
|
|
|
|
|
|
internal_note: { value: '测试内部备注' },
|
|
|
|
|
|
salesperson: { value: '麦麦' },
|
|
|
|
|
|
note: { value: '' },
|
|
|
|
|
|
edit_reason: { value: '补充客户称呼' },
|
|
|
|
|
|
edit_verified: { checked: true },
|
|
|
|
|
|
};
|
|
|
|
|
|
const form = {
|
|
|
|
|
|
id: 'order-edit-meta-form',
|
|
|
|
|
|
dataset: {},
|
|
|
|
|
|
querySelector: selector => fields[selector.match(/name="([^"]+)"/)?.[1]] || null,
|
|
|
|
|
|
querySelectorAll: () => [],
|
|
|
|
|
|
};
|
|
|
|
|
|
h.nodes.set('#order-edit-meta-form', form);
|
|
|
|
|
|
h.context.__form = form;
|
|
|
|
|
|
h.context.__response = {
|
|
|
|
|
|
eligible: true,
|
|
|
|
|
|
revision: 1,
|
|
|
|
|
|
financialEditable: false,
|
|
|
|
|
|
inputs: draft(),
|
|
|
|
|
|
order: { id: ID, revision: 1, lines: [] },
|
|
|
|
|
|
};
|
|
|
|
|
|
h.run(`tab='order-edit';useOrderEditResponse('${ID}',__response,null);rememberOrderEditDraft=function(){}`);
|
|
|
|
|
|
await assert.rejects(h.run('submitOrderEdit(__form)'), /客户称呼/代号必填/);
|
|
|
|
|
|
fields.customer.value = ' 客户A ';
|
|
|
|
|
|
fields.salesperson.value = ' ';
|
|
|
|
|
|
await assert.rejects(h.run('submitOrderEdit(__form)'), /开单人必填/);
|
|
|
|
|
|
assert.equal(h.calls.length, 0);
|
|
|
|
|
|
fields.salesperson.value = ' 麦麦 ';
|
|
|
|
|
|
await h.run('submitOrderEdit(__form)');
|
|
|
|
|
|
assert.equal(h.calls[0].input.customer, '客户A');
|
|
|
|
|
|
assert.equal(h.calls[0].input.salesperson, '麦麦');
|
2026-10-23 09:49:36 +08:00
|
|
|
|
});
|
|
|
|
|
|
|
2026-12-04 08:58:53 -08:00
|
|
|
|
test('锁价创建的显式空开单人不能靠默认经办人通过,旧锁价交付身份保持原逻辑', async () => {
|
|
|
|
|
|
const h = harness();
|
|
|
|
|
|
h.context.__lock = {
|
|
|
|
|
|
customer: '客户A',
|
|
|
|
|
|
internal_note: '测试内部备注',
|
|
|
|
|
|
salesperson: ' ',
|
|
|
|
|
|
line: { name: '足金999' },
|
|
|
|
|
|
};
|
|
|
|
|
|
h.run('collectPriceLockCreate=function(){return __lock}');
|
|
|
|
|
|
h.context.__form = { id: 'price-lock-create-form' };
|
|
|
|
|
|
await assert.rejects(h.run('submitPriceLockForm(__form)'), /开单人必填/);
|
|
|
|
|
|
assert.equal(h.calls.length, 0);
|
|
|
|
|
|
h.context.__draft = draft();
|
|
|
|
|
|
h.run('delete __draft.customer;delete __draft.salesperson');
|
|
|
|
|
|
assert.doesNotThrow(
|
|
|
|
|
|
() => h.run('validateIssueDraft(__draft,{requireIdentity:false})'),
|
|
|
|
|
|
'只在沿用原锁价身份的交付商品校验中跳过身份,不擅自补写旧客户',
|
|
|
|
|
|
);
|
2026-10-23 09:49:36 +08:00
|
|
|
|
});
|
|
|
|
|
|
|
2026-12-04 08:58:53 -08:00
|
|
|
|
test('模板仍可在客户与开单人未填时保存预设,套用后的新订单必须补客户', () => {
|
|
|
|
|
|
const h = harness();
|
|
|
|
|
|
h.context.__draft = draft({ customer: '', internal_note: '测试内部备注', salesperson: '' });
|
|
|
|
|
|
assert.doesNotThrow(() => h.run('OrderTemplates.fromDraft(__draft)'));
|
|
|
|
|
|
const preset = h.json('OrderTemplates.fromDraft(__draft)');
|
|
|
|
|
|
assert.equal(Object.hasOwn(preset, 'customer'), false);
|
|
|
|
|
|
h.context.__preset = preset;
|
|
|
|
|
|
h.context.__applied = h.run(
|
|
|
|
|
|
`OrderTemplates.apply(__preset,{today:'${D}',internal_note:'测试内部备注',salesperson:'麦麦'})`,
|
|
|
|
|
|
);
|
|
|
|
|
|
assert.equal(h.context.__applied.customer, '');
|
|
|
|
|
|
assert.equal(h.context.__applied.salesperson, '麦麦');
|
|
|
|
|
|
assert.throws(() => h.run('validateIssueDraft(__applied)'), /客户称呼/代号必填/);
|
2026-10-23 09:49:36 +08:00
|
|
|
|
});
|
|
|
|
|
|
|
2026-12-04 08:58:53 -08:00
|
|
|
|
test('内部成本和实际费用的强调限定屏幕样式,不修改打印资源', () => {
|
|
|
|
|
|
const css = fs
|
|
|
|
|
|
.readFileSync(path.join(__dirname, '../public/app.css'), 'utf8')
|
|
|
|
|
|
.replace(/\s+/g, ' ')
|
|
|
|
|
|
.replace(/\s*([{}:;,>])\s*/g, '$1')
|
|
|
|
|
|
.replace(/;}/g, '}');
|
|
|
|
|
|
assert.match(css, /@media screen\{\.line-item>\.internal,form>\.panel\.internal\{[^}]*border-left:4px solid/);
|
|
|
|
|
|
assert.match(css, /\.internal-title\{color:#6e4b17;font-size:17px;font-weight:700/);
|
|
|
|
|
|
assert.match(css, /\.panel\.internal>\.panel-title h2,\.panel\.internal>h2\{[^}]*font-size:20px;font-weight:700/);
|
|
|
|
|
|
const h = harness();
|
|
|
|
|
|
h.context.__draft = draft();
|
|
|
|
|
|
assert.match(h.run('feeHTML(__draft)'), /实际费用(内部)/);
|
|
|
|
|
|
assert.match(h.run('lineHTML(__draft.lines[0],1)'), /内部成本 · 客户单据不显示/);
|
2026-10-23 09:49:36 +08:00
|
|
|
|
});
|
|
|
|
|
|
|
2026-12-04 08:58:53 -08:00
|
|
|
|
test('自动手续费不会固化进模板或复制成普通费用,修改输入仍保留原元数据', () => {
|
|
|
|
|
|
const expenseId = '22222222-2222-4222-8222-222222222222',
|
|
|
|
|
|
paymentId = '33333333-3333-4333-8333-333333333333';
|
|
|
|
|
|
const auto = {
|
|
|
|
|
|
key: 'card_fee:' + paymentId,
|
|
|
|
|
|
system: 'credit_card',
|
|
|
|
|
|
source_kind: 'payment',
|
|
|
|
|
|
source_id: paymentId,
|
|
|
|
|
|
expense_id: expenseId,
|
|
|
|
|
|
note: '信用卡手续费',
|
|
|
|
|
|
amount: 400,
|
|
|
|
|
|
payer: 'owner',
|
|
|
|
|
|
status: 'recorded',
|
|
|
|
|
|
};
|
|
|
|
|
|
const source = {
|
|
|
|
|
|
id: ID,
|
|
|
|
|
|
date: D,
|
|
|
|
|
|
internal_note: '测试内部备注',
|
|
|
|
|
|
salesperson: '麦麦',
|
|
|
|
|
|
payment_account: '助理微信',
|
|
|
|
|
|
discount: 0,
|
|
|
|
|
|
note: '',
|
|
|
|
|
|
status: 'delivered',
|
|
|
|
|
|
pendingFees: [],
|
|
|
|
|
|
corrections: [],
|
|
|
|
|
|
fee_items: [auto],
|
|
|
|
|
|
expenses: [{ id: expenseId, date: D, note: auto.note, amount: 400, payer: 'owner' }],
|
|
|
|
|
|
lines: [
|
|
|
|
|
|
{
|
|
|
|
|
|
name: '足金999',
|
|
|
|
|
|
unit: 'g',
|
|
|
|
|
|
quantity: 1000,
|
|
|
|
|
|
pocket: '',
|
|
|
|
|
|
payer: 'owner',
|
|
|
|
|
|
pricingMode: 'manual',
|
|
|
|
|
|
baseSale: 10000,
|
|
|
|
|
|
sale: 10000,
|
|
|
|
|
|
charges: [],
|
|
|
|
|
|
cost: 4000,
|
|
|
|
|
|
costParts: { material: 4000, labor: 0, accessories: 0, other: 0 },
|
|
|
|
|
|
costMaterial: { mode: 'total' },
|
|
|
|
|
|
costLabor: { mode: 'total' },
|
|
|
|
|
|
},
|
|
|
|
|
|
],
|
|
|
|
|
|
};
|
|
|
|
|
|
const input = Copy.inputs(source);
|
|
|
|
|
|
assert.equal(input.fee_items[0].system, 'credit_card');
|
|
|
|
|
|
assert.equal(input.fee_items[0].expense_id, expenseId);
|
|
|
|
|
|
assert.equal(input.fee_items[0].amount, '4.00');
|
|
|
|
|
|
const copied = Copy.fromOrder(source, { today: D });
|
|
|
|
|
|
assert.equal(copied.fee_items.length, 0);
|
|
|
|
|
|
assert.equal(copied.customer, '');
|
|
|
|
|
|
assert.equal(JSON.stringify(copied).includes(expenseId), false);
|
|
|
|
|
|
const preset = Templates.fromDraft({
|
|
|
|
|
|
...draft(),
|
|
|
|
|
|
fee_items: [
|
|
|
|
|
|
{ ...auto, amount: '4.00' },
|
|
|
|
|
|
{
|
|
|
|
|
|
key: 'manual:' + randomUUID(),
|
|
|
|
|
|
expense_id: expenseId,
|
|
|
|
|
|
note: '同一自动费的旧引用',
|
|
|
|
|
|
amount: '4.00',
|
|
|
|
|
|
payer: 'owner',
|
|
|
|
|
|
},
|
|
|
|
|
|
],
|
|
|
|
|
|
});
|
|
|
|
|
|
assert.equal(preset.fee_items.length, 0);
|
|
|
|
|
|
assert.equal(JSON.stringify(preset).includes(expenseId), false);
|
2026-10-23 09:49:36 +08:00
|
|
|
|
});
|
|
|
|
|
|
|
2026-12-04 08:58:53 -08:00
|
|
|
|
test('信用卡选项随服务端账户开放,模板支持信用卡渠道且仍须补客户', () => {
|
|
|
|
|
|
const h = harness();
|
|
|
|
|
|
assert.doesNotMatch(h.run('accountFields()'), /信用卡/);
|
|
|
|
|
|
h.context.CreditCardFees = require('../public/credit-card-fees');
|
|
|
|
|
|
h.run("state.accounts=['助理微信','麦麦微信','助理信用卡','麦麦信用卡']");
|
|
|
|
|
|
assert.match(h.run('accountFields()'), /信用卡/);
|
|
|
|
|
|
const preset = Templates.fromDraft(draft({ payment_account: '麦麦信用卡' }));
|
|
|
|
|
|
assert.equal(preset.payment_account, '麦麦信用卡');
|
|
|
|
|
|
assert.equal(Templates.apply(preset, { today: D }).customer, '');
|
2026-10-23 09:49:36 +08:00
|
|
|
|
});
|
2026-10-28 18:41:14 +08:00
|
|
|
|
|
2026-12-04 08:58:53 -08:00
|
|
|
|
test('普通开单收集内部备注并恢复本地草稿,仅填内部备注不当作空白重置日期', () => {
|
|
|
|
|
|
const h = harness(),
|
|
|
|
|
|
values = {
|
|
|
|
|
|
orderId: '',
|
|
|
|
|
|
revision: '',
|
|
|
|
|
|
rounding_mode: 'yuan',
|
|
|
|
|
|
date: '2026-10-22',
|
|
|
|
|
|
customer: '',
|
2026-12-04 09:02:52 -08:00
|
|
|
|
internal_note: '待跟进\n<尺寸>',
|
2026-12-04 08:58:53 -08:00
|
|
|
|
salesperson: '麦麦',
|
|
|
|
|
|
fees_date: '2026-10-22',
|
|
|
|
|
|
discount: '0',
|
|
|
|
|
|
note: '',
|
|
|
|
|
|
},
|
|
|
|
|
|
fields = Object.fromEntries(Object.entries(values).map(([name, value]) => [name, { value }]));
|
|
|
|
|
|
const form = {
|
|
|
|
|
|
dataset: {},
|
|
|
|
|
|
querySelector: selector => fields[selector.match(/name="([^"]+)"/)?.[1]] || null,
|
|
|
|
|
|
querySelectorAll: () => [],
|
|
|
|
|
|
};
|
|
|
|
|
|
h.nodes.set('#order-form', form);
|
|
|
|
|
|
h.run('readFeeRows=function(){return [];};');
|
|
|
|
|
|
const collected = h.json('collectDraft()');
|
|
|
|
|
|
assert.equal(collected.internal_note, values.internal_note);
|
|
|
|
|
|
assert.equal(collected.note, '');
|
|
|
|
|
|
collected.lines = [{}];
|
|
|
|
|
|
h.saved.set('mm-draft-fields-owner', JSON.stringify(collected));
|
|
|
|
|
|
h.run('editDraft=null;renderCreate()');
|
|
|
|
|
|
const html = h.nodes.get('#main').innerHTML;
|
|
|
|
|
|
assert.match(html, /内部备注(客户不可见)/);
|
|
|
|
|
|
assert.match(html, /name="internal_note" maxlength="500" rows="3"/);
|
|
|
|
|
|
assert.match(html, /待跟进\n<尺寸>/);
|
|
|
|
|
|
assert.match(html, /name="date" value="2026-10-22"/);
|
|
|
|
|
|
assert.throws(
|
|
|
|
|
|
() => h.run('validateOrderIdentity({customer:"客户",salesperson:"麦麦",internal_note:"字".repeat(501)})'),
|
|
|
|
|
|
/内部备注最多填写500字/,
|
|
|
|
|
|
);
|
2026-10-28 18:41:14 +08:00
|
|
|
|
});
|
2026-11-30 15:40:40 +08:00
|
|
|
|
|
2026-12-04 08:58:53 -08:00
|
|
|
|
test('内部备注必填且至少3字符含井号,空格不能补长度;新建和修改共用字段支持标签入口', () => {
|
|
|
|
|
|
const h = harness();
|
|
|
|
|
|
for (const note of ['', '一二', '#字', ' 一 二\n']) {
|
|
|
|
|
|
h.context.__draft = draft({ internal_note: note });
|
|
|
|
|
|
assert.throws(() => h.run('validateIssueDraft(__draft)'), /至少填写3个字符/);
|
|
|
|
|
|
}
|
|
|
|
|
|
h.context.__draft = draft({ internal_note: ' #补货 ' });
|
|
|
|
|
|
assert.equal(h.run('validateIssueDraft(__draft).internal_note'), '#补货');
|
|
|
|
|
|
const html = h.run('orderInternalNoteField()');
|
|
|
|
|
|
assert.match(html, /<textarea[^>]*required[^>]*minlength="3"/);
|
|
|
|
|
|
assert.match(html, /data-order-note-tags/);
|
2026-11-30 15:40:40 +08:00
|
|
|
|
});
|