cmvr-wms/ruoyi-ui-vue3/tests/unit/supplier-documents.test.mjs
lixiaolong a82258561b feat(auth): 添加认证cookie名称配置并优化表单布局
- 在 .env.production 中新增 VITE_AUTH_COOKIE_NAME 配置项用于设置认证cookie名称
- 将 AcceptanceException.vue 中的表单标签宽度从固定90px改为自动适配
- 在 ActionDialog.vue 中将多个表单项标记为必填项并调整标签宽度为自动适配
- 重构 ActionHistory.vue 中的按钮布局结构并添加表格列样式类名
- 更新 api-contract-audit.cjs 添加生产任务和BOM相关接口的契约测试
- 修改 auth.js 使用动态认证cookie键名替换硬编码的Admin-Token
- 调整系统角色授权用户页面的表单布局和表格样式类名
- 优化 ReceiptDialog Batch 组件的对话框尺寸、表单验证和分页功能
2026-10-16 15:30:10 +08:00

31 lines
2.2 KiB
JavaScript

import test from 'node:test'
import assert from 'node:assert/strict'
import { normalizeSupplier, supplierLicenseError, supplierLicenseMaxBytes, validSupplierEmail, validSupplierLicenseId } from '../../src/utils/supplier-documents.js'
test('supplier email is optional, trimmed and checked with the backend email rule', () => {
for (const email of ['', ' ', ' sales+office@example.com ', 'first.last@example.co.uk', 'a_b@example.com']) assert.equal(validSupplierEmail(email), true, email)
for (const email of ['a@localhost', 'a..b@example.com', 'a b@example.com', 'a@-example.com', 'a@example..com', '采购@example.com', '\u00a0a@example.com\u00a0', `${'a'.repeat(65)}@example.com`, `${'a'.repeat(64)}@${'b'.repeat(64)}.com`]) assert.equal(validSupplierEmail(email), false, email)
})
test('supplier edit normalization retains previous email and opaque attachment metadata', () => {
const id = '11111111-1111-4111-8111-111111111111'
const old = { id: 7, version: 2, email: 'old@example.com', business_license_id: id, businessLicenseName: '执照.pdf' }
const edited = normalizeSupplier(old)
assert.equal(edited.email, 'old@example.com')
assert.equal(edited.businessLicenseId, id)
assert.equal(edited.businessLicenseName, '执照.pdf')
assert.equal(edited.version, 2)
assert.equal(normalizeSupplier({ ...old, businessLicenseId: '' }).businessLicenseId, '')
assert.equal(normalizeSupplier().email, '')
})
test('licenses accept only nonempty images or PDFs of at most 10 MB', () => {
for (const name of ['营业执照.PNG', '营业执照.jpg', '营业执照.jpeg', '营业执照.PDF']) assert.equal(supplierLicenseError({ name, size: supplierLicenseMaxBytes }), '')
for (const file of [{ name: '执照.svg', size: 10 }, { name: '执照.html', size: 10 }, { name: '执照.png', size: 0 }, { name: '执照.pdf', size: supplierLicenseMaxBytes + 1 }]) assert.ok(supplierLicenseError(file))
})
test('license preview IDs cannot inject remote URLs or filesystem paths', () => {
assert.equal(validSupplierLicenseId('11111111-1111-4111-8111-111111111111'), true)
for (const id of ['', '../secret', 'https://example.com/a.pdf', '/profile/a.png', '11111111-1111-4111-8111-111111111111/../secret']) assert.equal(validSupplierLicenseId(id), false)
})