fix(admin): 完善弹窗滚动与表单交互布局
This commit is contained in:
@@ -21,6 +21,7 @@ import {
|
||||
} from '../api/weightOcr'
|
||||
import type { WeightResultResource, WeightWorkspaceResource } from '../types'
|
||||
import WeightOcrPanel from './WeightOcrPanel.vue'
|
||||
import InboundMeasurementDialog from '../../measurement/InboundMeasurementDialog.vue'
|
||||
|
||||
vi.mock('../api/weightOcr', async () => {
|
||||
const actual = await vi.importActual<typeof import('../api/weightOcr')>('../api/weightOcr')
|
||||
@@ -151,6 +152,46 @@ function dialogConfirmButton(text = '确认重量') {
|
||||
}
|
||||
|
||||
describe('WeightOcrPanel confirmation behavior', () => {
|
||||
it('keeps the weight confirmation outside its measurement parent with independent fullscreen and cancel state', async () => {
|
||||
const pinia = createPinia()
|
||||
setActivePinia(pinia)
|
||||
const auth = useAuthStore()
|
||||
auth.token = 'token'
|
||||
auth.permissions = allWeightPermissions
|
||||
useAccessPreviewStore().initializeAfterLogin()
|
||||
const wrapper = mount(InboundMeasurementDialog, {
|
||||
attachTo: document.body,
|
||||
props: { modelValue: true, customerId: '10001', inboundId: '20001', inboundCode: 'RK-20001' },
|
||||
global: {
|
||||
plugins: [pinia, ElementPlus],
|
||||
stubs: { InboundMeasurementPanel: { template: '<section class="measurement-panel" />' } },
|
||||
},
|
||||
})
|
||||
await flushPromises()
|
||||
const panel = wrapper.getComponent(WeightOcrPanel)
|
||||
await openWeightDialog(panel)
|
||||
const popup = panel.getComponent(AppDialog)
|
||||
const parent = document.querySelector('.inbound-measurement-workspace-dialog')!
|
||||
const child = document.querySelector('input[aria-label="当前图片确认重量"]')!.closest('.el-dialog')!
|
||||
expect(document.body.contains(child)).toBe(true)
|
||||
expect(parent.contains(child)).toBe(false)
|
||||
expect(child.classList.contains('admin-workbench')).toBe(true)
|
||||
await dialogWeightInput().setValue('286.125')
|
||||
await new DOMWrapper(child).get('button[aria-label="展开全屏"]').trigger('click')
|
||||
expect(child.classList.contains('is-fullscreen')).toBe(true)
|
||||
expect(parent.classList.contains('is-fullscreen')).toBe(false)
|
||||
expect(dialogWeightInput().element.value).toBe('286.125')
|
||||
await new DOMWrapper(child).findAll('button').find(button => button.text() === '取消')!.trigger('click')
|
||||
await flushPromises()
|
||||
expect(popup.props('modelValue')).toBe(false)
|
||||
expect(wrapper.getComponent(AppDialog).props('modelValue')).toBe(true)
|
||||
expect(wrapper.emitted('update:modelValue')).toBeUndefined()
|
||||
await openWeightDialog(panel)
|
||||
expect(popup.props('modelValue')).toBe(true)
|
||||
expect(child.classList.contains('is-fullscreen')).toBe(false)
|
||||
expect(confirmWeightResult).not.toHaveBeenCalled()
|
||||
})
|
||||
|
||||
beforeEach(() => {
|
||||
vi.clearAllMocks()
|
||||
document.body.innerHTML = ''
|
||||
|
||||
Reference in New Issue
Block a user