WuYongJie 5821d73291 初始提交:3D家具安装展示系统
包含:
- furniture-3d-system:Next.js 16 全栈应用(资产中心、产品管理、3D装配动画)
- autocad-plugin:AutoCAD 家具导出插件源码
- 资产中心改造:编辑弹窗化、删除功能、Toast反馈、自定义Select组件

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
2026-04-02 14:00:19 +08:00

56 lines
1.7 KiB
TypeScript
Raw Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

import { describe, expect, it } from '@jest/globals'
import {
collectRequiredPanelIds,
getPanelNodeAliases,
inferFallbackPanelSizeFromHoles,
normalizePanelNodeName,
} from '@/lib/cad-panel-linking'
describe('cad-panel-linking', () => {
it('应该规范化 panel 节点名称并生成别名', () => {
const normalized = normalizePanelNodeName(' Cabinet\\Body/Panel_01 ')
const aliases = getPanelNodeAliases(' Cabinet\\Body/Panel_01 ')
expect(normalized).toBe('cabinet/body/panel_01')
expect(aliases).toContain('cabinet/body/panel_01')
expect(aliases).toContain('panel_01')
})
it('应该在没有孔位时返回默认板件尺寸', () => {
const size = inferFallbackPanelSizeFromHoles([], 'panel_001')
expect(size).toEqual([600, 400, 18])
})
it('应该根据孔位分布推断出有效板件尺寸', () => {
const size = inferFallbackPanelSizeFromHoles(
[
{ panelId: 'panel_001', position: [100, 200, 0], normal: [0, 0, 1] },
{ panelId: 'panel_001', position: [360, 260, 0], normal: [0, 0, 1] },
{ panelId: 'panel_001', position: [160, 420, 0], normal: [0, 0, 1] },
],
'panel_001'
)
expect(size[0]).toBeGreaterThanOrEqual(size[1])
expect(size[1]).toBeGreaterThanOrEqual(size[2])
expect(size[2]).toBeGreaterThan(0)
})
it('应合并 CAD 板件和孔位里的 panelId,包含无孔位板件', () => {
const panelIds = collectRequiredPanelIds(
[
{ id: 'panel_000' },
{ id: ' panel_001 ' },
{ id: '' },
],
[
{ panelId: 'panel_001' },
{ panelId: 'panel_002' },
]
)
expect(panelIds).toEqual(['panel_000', 'panel_001', 'panel_002'])
})
})