- 在 .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 组件的对话框尺寸、表单验证和分页功能
57 lines
4.4 KiB
JavaScript
57 lines
4.4 KiB
JavaScript
const assert = require('node:assert/strict')
|
||
const { chromium, frontend, backend, username, password } = require('./vue3-test-runtime.cjs')
|
||
;(async () => {
|
||
const login=await(await fetch(backend+'/login',{method:'POST',headers:{'Content-Type':'application/json'},body:JSON.stringify({username,password})})).json()
|
||
assert.equal(login.code,200)
|
||
const browser=await chromium.launch(), errors=[]
|
||
try {
|
||
const context=await browser.newContext({viewport:{width:1366,height:900}})
|
||
await context.addCookies([{name:'Admin-Token',value:login.token,url:frontend}])
|
||
const page=await context.newPage();page.setDefaultTimeout(12000)
|
||
page.on('pageerror',e=>errors.push(e.message))
|
||
await page.route('**/dev-api/**',r=>['GET','HEAD'].includes(r.request().method())?r.continue():r.abort('blockedbyclient'))
|
||
const ready=()=>page.waitForFunction(()=>document.querySelector('.desktop-viewport')&&![...document.querySelectorAll('.desktop-viewport .el-loading-mask')].some(e=>e.getClientRects().length))
|
||
async function fit(label) {
|
||
await page.waitForTimeout(120)
|
||
const geometry=await page.evaluate(()=>{
|
||
const stage=document.querySelector('.desktop-viewport'), visible=e=>e.getClientRects().length&&getComputedStyle(e).visibility!=='hidden'
|
||
const blocks=[...stage.querySelectorAll('.business-list-page__header,.el-form--inline,.el-row.mb8,.list-actions,.query-toolbar')].filter(e=>visible(e)&&!e.closest('.el-dialog,.el-table'))
|
||
const controls=[...new Set(blocks.flatMap(e=>[...e.querySelectorAll('.el-input,.el-select,.el-date-editor')]))].filter(e=>visible(e)&&!e.parentElement.closest('.el-select,.el-date-editor'))
|
||
return {overflow:blocks.filter(e=>e.scrollWidth>e.clientWidth+2).map(e=>e.className),document:document.documentElement.scrollWidth>innerWidth+2,controls:controls.filter(e=>e.getBoundingClientRect().width<130).map(e=>({class:e.className,width:e.getBoundingClientRect().width}))}
|
||
})
|
||
assert.deepEqual(geometry.overflow,[],label)
|
||
assert.equal(geometry.document,false,label)
|
||
assert.deepEqual(geometry.controls,[],label+' squeezed controls')
|
||
}
|
||
for(const route of ['/project/info','/procurement/details','/procurement/arrival','/warehouse/stock','/production/tasks','/production/operations']) {
|
||
await page.goto(frontend+route);await ready()
|
||
for(const width of [1366,1920,2560]) {
|
||
await page.setViewportSize({width,height:900})
|
||
for(const density of ['紧凑','标准','宽松']) {
|
||
await page.locator('#size-select').click();await page.getByRole('menuitem',{name:density,exact:true}).click()
|
||
await fit(route+'/'+width+'/'+density)
|
||
}
|
||
}
|
||
const more=page.getByRole('button',{name:/更多筛选/}).first()
|
||
if(await more.count()) {await more.click();await fit(route+'/expanded');await page.getByRole('button',{name:/收起/}).first().click()}
|
||
console.log('PASS '+route+' header: 3 widths × 3 densities and advanced filters')
|
||
}
|
||
await page.goto(frontend+'/procurement/arrival');await ready()
|
||
assert.equal(await page.locator('.arrival-workbench-page .el-form--inline .top-right-btn button').count(),1,'one refresh in filter bar, no duplicate search toggle')
|
||
assert.equal(await page.getByRole('button',{name:'刷新任务',exact:true}).count(),0)
|
||
const checkbox=page.locator('.el-table__body tr .el-checkbox:not(.is-disabled)').first()
|
||
if(await checkbox.count()) {
|
||
await checkbox.click()
|
||
await page.locator('.arrival-list-summary').getByText(/已选 1 项/).waitFor()
|
||
await page.locator('.arrival-list-summary').getByRole('button',{name:'清空',exact:true}).click()
|
||
await page.waitForFunction(()=>!document.querySelector('.arrival-list-summary')?.textContent.includes('已选'))
|
||
}
|
||
await page.locator('.arrival-workbench-page .el-form--inline .top-right-btn button').click();await ready()
|
||
console.log('PASS arrival selection/clear/refresh and single processing row')
|
||
await page.goto(frontend+'/procurement/details');await ready()
|
||
for(const name of ['明细搜索','待组批']) {await page.getByText(name,{exact:true}).click();await page.locator('.purchase-lookup').waitFor();await ready();await page.setViewportSize({width:1366,height:900});await fit('purchase/'+name)}
|
||
assert.deepEqual(errors,[])
|
||
console.log('HEADER LAYOUT PASS; business writes blocked')
|
||
} finally {await browser.close()}
|
||
})().catch(e=>{console.error(e);process.exitCode=1})
|