import { expect, it, vi } from 'vitest' import { defineComponent, effectScope, nextTick, reactive } from 'vue' import { mount, shallowMount, flushPromises } from '@vue/test-utils' import ElementPlus from 'element-plus' import { useAssistantPagination } from '@/utils/assistant-pagination' import Preview from '@/components/BusinessAssistant/AssistantReferencePricePreview.vue' import Draft from '@/components/BusinessAssistant/AssistantDraft.vue' vi.mock('@/components/BusinessAssistant/AssistantField.vue',()=>({default:{template:''}})) it('defaults to 50 rows, supports 20/50/100, resets on resizing, and clamps after exclusions',()=>{ const scope=effectScope(),rows=reactive(Array.from({length:121},(_,id)=>({id}))) try{ const pager=scope.run(()=>useAssistantPagination(()=>rows)) expect(pager.pageRows.value).toHaveLength(50);expect(pager.pageSizes).toEqual([20,50,100]) pager.page.value=3;expect(pager.pageRows.value).toHaveLength(21) pager.pageSize.value=100;expect(pager.page.value).toBe(1);expect(pager.pageRows.value).toHaveLength(100) pager.page.value=2;rows.splice(10);expect(pager.page.value).toBe(1);expect(pager.pageRows.value).toHaveLength(10) }finally{scope.stop()} }) it('a real AI price preview displays all 34 quote items on its first page',async()=>{ const wrapper=mount(Preview,{props:{rows:Array.from({length:34},(_,id)=>({name:`报价物品${id+1}`,quantity:1,newActualPrice:id,newActualAmount:id}))},global:{plugins:[ElementPlus]}}) try{await flushPromises();expect(wrapper.findAll('.el-table__body tbody tr')).toHaveLength(34);expect(wrapper.find('.el-pagination').text()).toContain('34')} finally{wrapper.unmount()} }) it('the AI confirmation table renders 50 rows and changing to 100 resets the page without losing rows',async()=>{ const table=defineComponent({props:['data'],template:'