fix(overseas): keep receiving warehouse action visible
This commit is contained in:
@@ -23,7 +23,8 @@ import {
|
||||
} from '../api/lastMileOrders'
|
||||
import LastMileOrdersView from './LastMileOrdersView.vue'
|
||||
|
||||
vi.mock('@/core/access/accessPreview', () => ({ useAccessPreviewStore: () => ({ can: () => true }) }))
|
||||
const canAccess = vi.hoisted(() => vi.fn<(permissionCode: string) => boolean>(() => true))
|
||||
vi.mock('@/core/access/accessPreview', () => ({ useAccessPreviewStore: () => ({ can: canAccess }) }))
|
||||
vi.mock('vue-router', () => ({ useRouter: () => ({ push: vi.fn() }) }))
|
||||
vi.mock('@/modules/warehouses', () => ({ listAllPlatformWarehouses: vi.fn() }))
|
||||
vi.mock('../api/lastMileOrders', () => ({
|
||||
@@ -122,6 +123,7 @@ async function chooseContainer(wrapper: Awaited<ReturnType<typeof mountView>>) {
|
||||
|
||||
describe('LastMileOrdersView pending order and container conversion', () => {
|
||||
beforeEach(() => {
|
||||
canAccess.mockReset().mockReturnValue(true)
|
||||
vi.stubGlobal('ResizeObserver', ResizeObserverStub)
|
||||
vi.stubGlobal('localStorage', memoryStorage())
|
||||
vi.mocked(listLastMileOrders).mockReset().mockResolvedValue({ records: [], page: 1, size: 10, total: 0, pages: 0 })
|
||||
@@ -416,7 +418,7 @@ describe('LastMileOrdersView pending order and container conversion', () => {
|
||||
expect(confirm.disabled).toBe(true)
|
||||
})
|
||||
|
||||
it('does not expose a receiving-warehouse edit when the server locks the container', async () => {
|
||||
it('keeps a disabled receiving-warehouse action discoverable when the server locks the container', async () => {
|
||||
vi.mocked(listContainerPlanProgress).mockResolvedValueOnce({
|
||||
records: [{ ...summary, canChangeReceivingWarehouse: false, receivingWarehouseLockReason: '海外仓已开始拆柜收货' }],
|
||||
page: 1, size: 10, total: 1, pages: 1,
|
||||
@@ -425,7 +427,24 @@ describe('LastMileOrdersView pending order and container conversion', () => {
|
||||
await wrapper.findAll('.el-radio-button').find((item) => item.text().startsWith('柜子'))!.trigger('click')
|
||||
await flushPromises()
|
||||
expect(wrapper.text()).toContain('海外仓已开始拆柜收货')
|
||||
expect(button(wrapper, '修改接柜仓')).toBeUndefined()
|
||||
const changeButton = button(wrapper, '修改接柜仓')!
|
||||
expect(changeButton.exists()).toBe(true)
|
||||
expect((changeButton.element as HTMLButtonElement).disabled).toBe(true)
|
||||
expect(changeButton.attributes('title')).toBe('海外仓已开始拆柜收货')
|
||||
expect(changeContainerReceivingWarehouse).not.toHaveBeenCalled()
|
||||
})
|
||||
|
||||
it('keeps a disabled receiving-warehouse action discoverable without edit permission', async () => {
|
||||
canAccess.mockImplementation((permissionCode: string) => permissionCode !== 'platform:overseas-warehouse:last-mile-order:edit')
|
||||
const wrapper = await mountView()
|
||||
await wrapper.findAll('.el-radio-button').find((item) => item.text().startsWith('柜子'))!.trigger('click')
|
||||
await flushPromises()
|
||||
const changeButton = button(wrapper, '修改接柜仓')!
|
||||
expect(changeButton.exists()).toBe(true)
|
||||
expect((changeButton.element as HTMLButtonElement).disabled).toBe(true)
|
||||
expect(changeButton.attributes('title')).toBe('暂无修改接柜仓权限,请联系管理员开通尾程订单编辑权限')
|
||||
await changeButton.trigger('click')
|
||||
expect(listAllPlatformWarehouses).not.toHaveBeenCalled()
|
||||
expect(changeContainerReceivingWarehouse).not.toHaveBeenCalled()
|
||||
})
|
||||
|
||||
|
||||
Reference in New Issue
Block a user