优化
This commit is contained in:
@@ -36,6 +36,14 @@ async function openCreate() {
|
||||
}
|
||||
function candidatePagination() { return wrapper.findAllComponents(ElPagination).find(item => item.props('total') === 7)! }
|
||||
function pageCheckbox() { return wrapper.findAllComponents(ElCheckbox).find(item => item.props('ariaLabel') === '全选本页订单')! }
|
||||
async function selectBothPages() {
|
||||
pageCheckbox().vm.$emit('change', true)
|
||||
await flushPromises()
|
||||
candidatePagination().vm.$emit('update:current-page', 2)
|
||||
await flushPromises()
|
||||
pageCheckbox().vm.$emit('change', true)
|
||||
await flushPromises()
|
||||
}
|
||||
|
||||
describe('outbound candidate search and selection', () => {
|
||||
beforeEach(() => {
|
||||
@@ -71,29 +79,40 @@ describe('outbound candidate search and selection', () => {
|
||||
}))
|
||||
})
|
||||
|
||||
it('searches on query, selects every filtered page, shows partial page selection and clears the selection', async () => {
|
||||
it('keeps searches on one row without bulk buttons and preserves filtered selection across pages', async () => {
|
||||
await openCreate()
|
||||
expect(wrapper.get('.dropship-search-row').findAll('.el-form-item')).toHaveLength(2)
|
||||
expect(wrapper.find('.candidate-selection').exists()).toBe(false)
|
||||
expect(wrapper.text()).not.toContain('全选筛选结果')
|
||||
expect(wrapper.text()).not.toContain('清空选择')
|
||||
const query = wrapper.findAllComponents(ElInput).find(item => item.props('ariaLabel') === '搜索可出库订单')!
|
||||
await query.get('input').setValue('MATCH')
|
||||
await flushPromises()
|
||||
expect(wrapper.text()).toContain('全选筛选结果(7)')
|
||||
expect(candidatePagination().props('total')).toBe(7)
|
||||
await query.get('input').trigger('keyup', { key: 'Enter' })
|
||||
await flushPromises()
|
||||
expect(wrapper.text()).toContain('全选筛选结果(6)')
|
||||
await clickButton('全选筛选结果')
|
||||
const filteredPagination = wrapper.findAllComponents(ElPagination).find(item => item.props('total') === 6)!
|
||||
expect(filteredPagination).toBeDefined()
|
||||
pageCheckbox().vm.$emit('change', true)
|
||||
await flushPromises()
|
||||
filteredPagination.vm.$emit('update:current-page', 2)
|
||||
await flushPromises()
|
||||
pageCheckbox().vm.$emit('change', true)
|
||||
await flushPromises()
|
||||
expect(wrapper.text()).toContain('已选择 6 条')
|
||||
await wrapper.get('.candidate-query').findAll('button').find(item => item.text() === '重置')!.trigger('click')
|
||||
await flushPromises()
|
||||
candidatePagination().vm.$emit('update:current-page', 2)
|
||||
await flushPromises()
|
||||
expect(pageCheckbox().props('indeterminate')).toBe(true)
|
||||
await clickButton('清空选择')
|
||||
expect(wrapper.text()).toContain('已选择 0 条')
|
||||
pageCheckbox().vm.$emit('change', false)
|
||||
await flushPromises()
|
||||
expect(wrapper.get('.candidate-pagination').text()).toContain('已选择 5 条')
|
||||
})
|
||||
|
||||
it('resets the page after page-size changes and clears selection when changing searchable warehouses', async () => {
|
||||
await openCreate()
|
||||
await clickButton('全选筛选结果')
|
||||
await selectBothPages()
|
||||
const pagination = candidatePagination()
|
||||
pagination.vm.$emit('update:current-page', 2)
|
||||
await flushPromises()
|
||||
@@ -115,7 +134,8 @@ describe('outbound candidate search and selection', () => {
|
||||
it('warns about a multi-customer bulk selection and preserves the submit restriction', async () => {
|
||||
api.candidates.mockResolvedValue([{ ...fixtures[0] }, { ...fixtures[1], customerId: 'customer-b', customerName: '客户乙' }])
|
||||
await openCreate()
|
||||
await clickButton('全选筛选结果')
|
||||
pageCheckbox().vm.$emit('change', true)
|
||||
await flushPromises()
|
||||
expect(wrapper.text()).toContain('当前选择包含多个客户')
|
||||
await wrapper.get('[data-test="submit-outbound"]').trigger('click')
|
||||
await flushPromises()
|
||||
|
||||
Reference in New Issue
Block a user