- 在页面标题栏添加操作指引图标,显示相关功能说明 - 实现登录页面连接状态提示和验证码刷新机制 - 优化盘点功能,区分账面数量和实际盘点数量 - 改进AI助手附件上传状态反馈和错误处理 - 添加BOM编辑器和采购页面操作指引 - 实现登录页面连接状态提示和验证码刷新机制
22 lines
1.9 KiB
JavaScript
22 lines
1.9 KiB
JavaScript
import test from 'node:test'
|
|
import assert from 'node:assert/strict'
|
|
import {normalizeSearchQuery,isSearchRequest,trimSearchText} from '../../src/utils/search-query.js'
|
|
test('all search boundary whitespace is ignored, but internal spaces and punctuation survive',()=>{
|
|
for(const edge of [' ','\t\r\n','\u3000','\u00a0','\u202f','\ufeff','\u200b','\u0085'])assert.equal(trimSearchText(edge+'TP-LINK 路由器 AX 5400'+edge),'TP-LINK 路由器 AX 5400')
|
|
assert.equal(trimSearchText('a b'),'a b')
|
|
assert.equal(trimSearchText(' \u3000 '),'')
|
|
})
|
|
test('normalization is immutable, recursive and preserves values and credentials',()=>{
|
|
const original={productName:' 路由器 ',params:{beginTime:' 2026-10-01 ',names:[' 物品 A ',null,0]},enabled:false,password:' secret ',fileName:' report.pdf ',token:' bearer '}
|
|
const normalized=normalizeSearchQuery(original)
|
|
assert.equal(normalized.productName,'路由器');assert.equal(original.productName,' 路由器 ')
|
|
assert.deepEqual(normalized.params,{beginTime:'2026-10-01',names:['物品 A',null,0]})
|
|
for(const key of ['password','fileName','token','enabled'])assert.equal(normalized[key],original[key])
|
|
assert.equal(normalizeSearchQuery({'params[password]':' keep '})['params[password]'],' keep ')
|
|
})
|
|
test('scope includes business searches and filtered exports, never collaboration or business writes',()=>{
|
|
for(const path of ['/warehouse/product/list','/production/products/options','/project/info/options','/project/loans','/system/user/list','/monitor/operlog/list','/prod-api/warehouse/stock/list'])assert.equal(isSearchRequest(path),true,path)
|
|
assert.equal(isSearchRequest('/warehouse/product/export','post'),true)
|
|
for(const [path,method] of [['/project/manage/projects','get'],['/warehouse/purchase','post'],['/login','post'],['/system/user/resetPwd','put'],['/common/download','get']])assert.equal(isSearchRequest(path,method),false,path)
|
|
})
|