优化
This commit is contained in:
@@ -75,6 +75,40 @@ describe('ContainersView', () => {
|
||||
expect(wrapper.text()).not.toContain('报空预警')
|
||||
})
|
||||
|
||||
it('shows one direct empty-return action only when permission and server actions allow it', async () => {
|
||||
const router = createTestRouter()
|
||||
await router.push('/'); await router.isReady()
|
||||
const wrapper = mount(ContainersView, { props: { workbench: 'OVERSEAS' }, attachTo: document.body, global: { plugins: [ElementPlus, router] } })
|
||||
await flushPromises()
|
||||
const buttons = wrapper.findAll('button').filter((item) => item.text().includes('确认还柜/还空'))
|
||||
expect(buttons).toHaveLength(1)
|
||||
await buttons[0].trigger('click')
|
||||
await flushPromises()
|
||||
const confirm = [...document.body.querySelectorAll('button')].filter((item) => item.textContent?.includes('确认还柜')).at(-1) as HTMLButtonElement
|
||||
confirm.click()
|
||||
await flushPromises()
|
||||
expect(recordTerminalDrayageEmptyReturn).toHaveBeenCalledTimes(1)
|
||||
expect(recordTerminalDrayageEmptyReturn).toHaveBeenCalledWith('9001', expect.objectContaining({ expectedVersion: 3, actualAt: expect.any(String) }))
|
||||
expect(wrapper.text()).toContain('已还柜')
|
||||
})
|
||||
|
||||
it('hides the direct empty-return action without permission or without the server action', async () => {
|
||||
const router = createTestRouter()
|
||||
await router.push('/'); await router.isReady()
|
||||
accessCan.mockImplementation((code) => code !== 'platform:firstleg:terminal-drayage:empty-return:confirm')
|
||||
const wrapper = mount(ContainersView, { props: { workbench: 'OVERSEAS' }, global: { plugins: [ElementPlus, router] } })
|
||||
await flushPromises()
|
||||
expect(wrapper.findAll('button').some((item) => item.text().includes('确认还柜/还空'))).toBe(false)
|
||||
wrapper.unmount()
|
||||
accessCan.mockReturnValue(true)
|
||||
const allowedWrapper = mount(ContainersView, { props: { workbench: 'OVERSEAS' }, global: { plugins: [ElementPlus, router] } })
|
||||
await flushPromises()
|
||||
const vm = allowedWrapper.vm as unknown as { rows: Array<{ allowedActions?: string[] }> }
|
||||
vm.rows[0].allowedActions = vm.rows[0].allowedActions?.filter((action) => action !== 'RECORD_EMPTY_RETURN')
|
||||
await allowedWrapper.vm.$nextTick()
|
||||
expect(allowedWrapper.findAll('button').some((item) => item.text().includes('确认还柜/还空'))).toBe(false)
|
||||
})
|
||||
|
||||
it('defers form options until their dialogs open and caches successful loads', async () => {
|
||||
const router = createTestRouter()
|
||||
await router.push('/'); await router.isReady()
|
||||
|
||||
Reference in New Issue
Block a user