20260827173205
This commit is contained in:
1 parent
60cacfa8fb
commit
3824af0f12
38 files changed
+2398
-3552
No files matched your search
@@ -2,7 +2,7 @@ import { describe, it, expect, beforeEach } from 'vitest'
|
||||
import { mount } from '@vue/test-utils'
|
||||
import { createPinia, setActivePinia } from 'pinia'
|
||||
import { nextTick } from 'vue'
|
||||
import { registerFeature, useAreaSelection } from 'stk-table-vue'
|
||||
import { registerFeature, useAreaSelection, StkTable } from 'stk-table-vue'
|
||||
import FmsTable from '@/components/fms-table/FmsTable.vue'
|
||||
|
||||
// 与 main.js 一致:注册 stk-table 的按需 feature(行编辑依赖 area-selection)
|
||||
@@ -150,4 +150,33 @@ describe('fms-table 虚拟滚动验证', () => {
|
||||
expect(editor.exists()).toBe(true)
|
||||
wrapper.unmount()
|
||||
})
|
||||
|
||||
// 列宽拖拽回归:库 useColResize 在 mouseUp 时「原地改写」传入的列对象 width 并
|
||||
// emit update:columns(同一批对象的新数组)。未绑定 v-model:columns 的父组件
|
||||
// 不会回灌新数组,displayColumns 必须自行换新数组引用,库才能重算出新列宽。
|
||||
// 复现方式:拿到库实际收到的 displayColumns,原地改第 1 列宽度后以同批对象
|
||||
// emit update:columns,断言表头渲染出新宽度。
|
||||
it('拖拽列宽后(未绑定 v-model:columns),新列宽立即生效不丢失', async () => {
|
||||
const columns = makeColumns()
|
||||
const wrapper = mount(FmsTable, {
|
||||
props: { columns, dataSource: makeRows(20), rowKey: 'id', seq: false },
|
||||
attachTo: document.body,
|
||||
})
|
||||
await nextTick()
|
||||
await new Promise((r) => setTimeout(r, 100))
|
||||
|
||||
const stkTable = wrapper.findComponent(StkTable)
|
||||
const displayColumns = stkTable.props('columns')
|
||||
const target = displayColumns.find((c) => c.dataIndex === 'c1')
|
||||
target.width = '333px' // 模拟 useColResize mouseUp 的原地改写
|
||||
|
||||
await stkTable.vm.$emit('update:columns', displayColumns.slice())
|
||||
await nextTick()
|
||||
await new Promise((r) => setTimeout(r, 100))
|
||||
|
||||
// 表头 th 宽度经 --cw CSS 变量渲染;virtualX 模式下取自 __W__(dealColumns 重算产物)
|
||||
const th = wrapper.findAll('thead th').find((el) => el.attributes('data-col-key') === 'c1')
|
||||
expect(th.attributes('style')).toContain('333px')
|
||||
wrapper.unmount()
|
||||
})
|
||||
})
|
||||
Reference in new issue
Block a user