- 在 .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 组件的对话框尺寸、表单验证和分页功能
36 lines
2.0 KiB
JavaScript
36 lines
2.0 KiB
JavaScript
import test from 'node:test'
|
|
import assert from 'node:assert/strict'
|
|
import { assistantFloatingRect, assistantMoveWindow } from '../../src/utils/assistant-window.js'
|
|
|
|
test('a fallback rectangle is fully visible when no existing panel can be measured', () => {
|
|
assert.deepEqual(assistantFloatingRect(null, { width: 1440, height: 900 }), { left: 270, top: 90, width: 900, height: 720 })
|
|
})
|
|
|
|
test('detaching retains the measured docked position and size instead of centering or enlarging', () => {
|
|
const docked = { left: 744, top: 88, width: 680, height: 776 }
|
|
assert.deepEqual(assistantFloatingRect(docked, { width: 1440, height: 900 }), docked)
|
|
const short = { left: 584, top: 16, width: 680, height: 298 }
|
|
assert.deepEqual(assistantFloatingRect(short, { width: 1280, height: 350 }), short)
|
|
})
|
|
|
|
test('dragging clamps all window edges to the viewport', () => {
|
|
const viewport = { width: 1440, height: 900 }, rect = assistantFloatingRect(null, viewport)
|
|
assert.deepEqual(assistantMoveWindow(rect, { x: -9999, y: -9999 }, viewport), { ...rect, left: 16, top: 16 })
|
|
assert.deepEqual(assistantMoveWindow(rect, { x: 9999, y: 9999 }, viewport), { ...rect, left: 524, top: 164 })
|
|
})
|
|
|
|
test('viewport changes fit the restored floating window without losing its location unnecessarily', () => {
|
|
const rect = { left: 450, top: 150, width: 900, height: 720 }
|
|
assert.deepEqual(assistantFloatingRect(rect, { width: 1440, height: 900 }), rect)
|
|
const fitted = assistantFloatingRect(rect, { width: 820, height: 600 })
|
|
assert.deepEqual(fitted, { left: 16, top: 16, width: 788, height: 568 })
|
|
const narrow = assistantFloatingRect(rect, { width: 320, height: 240 })
|
|
assert.ok(narrow.left + narrow.width <= 320 && narrow.top + narrow.height <= 240)
|
|
})
|
|
|
|
test('geometry helpers do not change the original window when switching modes', () => {
|
|
const rect = { left: 80, top: 100, width: 900, height: 600 }, before = { ...rect }
|
|
assistantMoveWindow(rect, { x: 40, y: 10 }, { width: 1440, height: 900 })
|
|
assert.deepEqual(rect, before)
|
|
})
|