This commit is contained in:
2026-09-09 10:18:12 +08:00
parent e643e43828
commit 1249263b94
12 changed files with 164 additions and 28 deletions
@@ -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()