优化
This commit is contained in:
@@ -4,6 +4,7 @@ import { resolve } from 'node:path'
|
||||
import { enableAutoUnmount, flushPromises, mount } from '@vue/test-utils'
|
||||
import { afterAll, afterEach, beforeEach, describe, expect, it, vi } from 'vitest'
|
||||
import QueryToolbar, { type QueryModel } from '@/shared/components/QueryToolbar.vue'
|
||||
import LoadErrorState from '@/shared/components/LoadErrorState.vue'
|
||||
import { cancelDispatch, getDispatchBolPdf, listDispatches, removeDispatchItem, transferDispatchToDelivery, updateDispatch } from '../api/dispatches'
|
||||
import DispatchesView from './DispatchesView.vue'
|
||||
|
||||
@@ -60,9 +61,9 @@ describe('DispatchesView', () => {
|
||||
[['edit'], ['查看', '打印BOL', '编辑'], false],
|
||||
[['cancel'], ['查看', '打印BOL', '取消'], false],
|
||||
[['transfer-delivery'], ['查看', '打印BOL', '转派送'], false],
|
||||
[['edit', 'transfer-delivery'], ['查看', '打印BOL', '转派送', ''], true],
|
||||
[['edit', 'cancel'], ['查看', '打印BOL', '编辑', ''], true],
|
||||
[['edit', 'cancel', 'transfer-delivery'], ['查看', '打印BOL', '转派送', ''], true],
|
||||
[['edit', 'transfer-delivery'], ['查看', '打印BOL', '转派送', '更多'], true],
|
||||
[['edit', 'cancel'], ['查看', '打印BOL', '编辑', '更多'], true],
|
||||
[['edit', 'cancel', 'transfer-delivery'], ['查看', '打印BOL', '转派送', '更多'], true],
|
||||
])('uses the row action threshold for permissions %j', async (allowed, labels, overflow) => {
|
||||
canPermission.mockImplementation(code => allowed.some(action => code === 'platform:overseas-warehouse:dispatch:' + action))
|
||||
const wrapper = mount(DispatchesView, { global: { plugins: [ElementPlus] } })
|
||||
@@ -72,6 +73,23 @@ describe('DispatchesView', () => {
|
||||
expect(actions.find('.el-dropdown').exists()).toBe(overflow)
|
||||
})
|
||||
|
||||
it('keeps the integrated header and filters usable through failure and retry', async () => {
|
||||
vi.mocked(listDispatches).mockRejectedValueOnce(new Error('网络错误'))
|
||||
const wrapper = mount(DispatchesView, { global: { plugins: [ElementPlus] } })
|
||||
await flushPromises()
|
||||
const card = wrapper.get('.data-table--integrated')
|
||||
expect(card.get('.data-table__toolbar h1').text()).toBe('排车列表')
|
||||
expect(card.get('.data-table__toolbar button[aria-label="列设置"]').text()).toBe('字段设置')
|
||||
expect(card.get('.data-table__filters').findComponent(QueryToolbar).exists()).toBe(true)
|
||||
expect(card.find('.el-table').exists()).toBe(false)
|
||||
expect(card.find('.data-table__pagination').exists()).toBe(false)
|
||||
wrapper.findComponent(LoadErrorState).vm.$emit('retry')
|
||||
await flushPromises()
|
||||
expect(card.find('.data-table__state').exists()).toBe(false)
|
||||
expect(card.get('.el-table').text()).toContain('PC-1')
|
||||
expect(card.get('.data-table__pagination').text()).toContain('共 1 条排车记录')
|
||||
})
|
||||
|
||||
it('loads immediately and sends only supported page filters', async () => {
|
||||
const wrapper = mount(DispatchesView, { global: { plugins: [ElementPlus] } })
|
||||
await flushPromises()
|
||||
@@ -92,6 +110,13 @@ describe('DispatchesView', () => {
|
||||
expect(wrapper.text()).toContain('待发车')
|
||||
expect(wrapper.text()).toContain('FBA-1 · 已确认')
|
||||
expect(wrapper.text()).toContain('已预约')
|
||||
expect(wrapper.get('.data-table').classes()).not.toContain('admin-text-actions')
|
||||
expect(wrapper.get('.query-toolbar').classes()).not.toContain('admin-text-actions')
|
||||
expect(wrapper.get('.data-table__toolbar button[aria-label="列设置"]').find('svg').exists()).toBe(true)
|
||||
expect(wrapper.get('.query-toolbar__actions .el-button--primary').text()).toBe('查询')
|
||||
expect(wrapper.get('button[aria-label="上一页"]').find('svg').exists()).toBe(true)
|
||||
expect(wrapper.findAll('.query-toolbar__actions button svg')).toHaveLength(3)
|
||||
expect(wrapper.get('.el-table__body-wrapper .row-actions').classes()).toContain('admin-text-actions')
|
||||
})
|
||||
|
||||
it('keeps long dispatch identifiers as strings', async () => {
|
||||
|
||||
Reference in New Issue
Block a user