WuYongJie 243cfc9825 Use furniture Z-up axes in installation demo editing
Map X to width, Y to depth, and Z to height in numeric movement, drag and rotation controls, and feedback. Preserve existing Y-up model poses and saved data, and extract transform-anchor helpers.
2026-10-19 17:54:47 +08:00

28 lines
1.6 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 { fireEvent, render, screen } from '@testing-library/react'
import { InstallationExplosionMoveInput } from './InstallationExplosionMoveInput'
describe('explosion movement inputs', () => {
it('applies one complete signed movement on submit and clears it to prevent an accidental repeat', () => {
const onTranslate = jest.fn()
render(<InstallationExplosionMoveInput disabled={false} onTranslate={onTranslate} />)
fireEvent.change(screen.getByRole('spinbutton', { name: 'Z 轴位移 mm' }), { target: { value: '200' } })
expect(onTranslate).not.toHaveBeenCalled()
fireEvent.change(screen.getByRole('spinbutton', { name: 'Y 轴位移 mm' }), { target: { value: '-12.5' } })
fireEvent.submit(screen.getByRole('form', { name: '精确移动部件' }))
expect(onTranslate).toHaveBeenCalledWith([0, 200, 12.5])
expect(screen.getByRole('status')).toHaveTextContent('已移动:Y -12.5 mm,Z +200 mm')
expect(screen.getByRole('spinbutton', { name: 'Z 轴位移 mm' })).toHaveValue(0)
expect(screen.getByRole('button', { name: '应用位移' })).toBeDisabled()
fireEvent.submit(screen.getByRole('form', { name: '精确移动部件' }))
expect(onTranslate).toHaveBeenCalledTimes(1)
})
it('prevents movement without an editable selection', () => {
const onTranslate = jest.fn()
render(<InstallationExplosionMoveInput disabled onTranslate={onTranslate} />)
expect(screen.getByRole('spinbutton', { name: 'Z 轴位移 mm' })).toBeDisabled()
fireEvent.submit(screen.getByRole('form', { name: '精确移动部件' }))
expect(onTranslate).not.toHaveBeenCalled()
})
})