20260825173027

This commit is contained in:
oneao committed 2026-08-25 17:30:28 +08:00
1 parent 7421019ef2
commit a509f93f34
11 files changed
+615 -934

No files matched your search

@@ -1150,8 +1150,8 @@ describe('ModuleEditConfigPanel(表单设计视图)', () => {
expect(cards.length).toBe(3)
expect(wrapper.text()).toContain('基础信息')
expect(wrapper.text()).toContain('未分组')
// 属性面板初始未选中字段
expect(wrapper.text()).toContain('点击画布中的字段卡片')
// 属性面板初始未选中字段(子标题显示"未选中")
expect(wrapper.find('.mm-fdesign__inspector .mm-fdesign__subhead').text()).toContain('未选中')
// 数据视图表格默认隐藏
expect(wrapper.find('.mm-edit__data').attributes('style')).toContain('display: none')
})
@@ -1187,12 +1187,13 @@ describe('ModuleEditConfigPanel(表单设计视图)', () => {
expect(card2.classes()).toContain('is-selected')
})
it('仅桌面端设计:无设备切换按钮,画布固定桌面端 24 栅格', async () => {
it('表单设计不显示设备切换和画布提示文案', async () => {
const wrapper = mountEdit()
await nextTick()
expect(wrapper.find('button[data-device]').exists()).toBe(false)
expect(wrapper.find('.mm-fdesign__sheet').classes()).not.toContain('is-mobile')
expect(wrapper.text()).toContain('画布 · 桌面端 24 栅格')
expect(wrapper.text()).not.toContain('画布 · 桌面端 24 栅格')
expect(wrapper.text()).not.toContain('从左侧字段库点击或拖拽,即可添加表单项')
expect(wrapper.text()).not.toContain('移动端预览')
})
@@ -1225,17 +1226,12 @@ describe('ModuleEditConfigPanel(表单设计视图)', () => {
expect(wrapper.findAll('.mm-fdesign__field').length).toBe(3)
})
it('属性面板:修改排序号与开关写入草稿并 emit update', async () => {
it('属性面板:开关写入草稿并 emit update', async () => {
const wrapper = mountEdit()
await nextTick()
await wrapper.find('.mm-fdesign__field[data-field-id="f3"]').trigger('click')
await nextTick()
const xhInput = wrapper.find('#mm-fdesign-xh')
await xhInput.setValue('35')
await xhInput.trigger('change')
await nextTick()
// 必填开关:初始关闭(f3 required=0)→ 点击打开
const requiredToggle = wrapper.findAll('.mm-fdesign__toggle')[0]
expect(requiredToggle.classes()).not.toContain('is-on')
@@ -1247,7 +1243,6 @@ describe('ModuleEditConfigPanel(表单设计视图)', () => {
expect(updates).toBeTruthy()
const last = updates[updates.length - 1][0]
const row = last.find((r) => r.b_id === 'e3')
expect(row.b_xh).toBe(35)
expect(row.b_required).toBe(1)
})
@@ -1846,7 +1841,7 @@ describe('ModuleEditConfigPanel(表单设计视图)', () => {
await wrapper.find('.mm-fdesign__sheet').trigger('click')
await nextTick()
expect(wrapper.find('.mm-fdesign__field.is-selected').exists()).toBe(false)
expect(wrapper.find('.mm-fdesign__inspector').text()).toContain('点击画布中的字段卡片')
expect(wrapper.find('.mm-fdesign__inspector .mm-fdesign__subhead').text()).toContain('未选中')
})
// ================= 拖拽边界全量回归(补齐同行内调序 / 跨组 / 源行回收等场景) =================
@@ -2182,7 +2177,7 @@ describe('ModuleEditConfigPanel(表单设计视图)', () => {
wrapper.unmount() // 移除 window keydown 监听
})
it('头部撤销 / 重做按钮:删除字段后可撤销恢复、重做再删除', async () => {
it('删除字段后可撤销恢复、重做再删除(Ctrl+Z / Ctrl+Shift+Z)', async () => {
const wrapper = mountEdit()
await nextTick()
await wrapper.find('.mm-fdesign__field[data-field-id="f1"]').trigger('click')
@@ -2191,13 +2186,16 @@ describe('ModuleEditConfigPanel(表单设计视图)', () => {
await nextTick()
expect(wrapper.findAll('.mm-fdesign__field').length).toBe(2)
await wrapper.find('button[aria-label="撤销"]').trigger('click')
window.dispatchEvent(new KeyboardEvent('keydown', { key: 'z', ctrlKey: true, bubbles: true }))
await nextTick()
expect(wrapper.findAll('.mm-fdesign__field').length).toBe(3)
await wrapper.find('button[aria-label="重做"]').trigger('click')
window.dispatchEvent(
new KeyboardEvent('keydown', { key: 'z', ctrlKey: true, shiftKey: true, bubbles: true }),
)
await nextTick()
expect(wrapper.findAll('.mm-fdesign__field').length).toBe(2)
wrapper.unmount() // 移除 window keydown 监听
})
it('工具栏上移 / 下移:整行与相邻行整体交换', async () => {
@@ -2359,17 +2357,6 @@ describe('ModuleEditConfigPanel(表单设计视图)', () => {
expect(wrapper.findAll('.mm-fdesign__lib-item').length).toBe(6) // 4 字段 + 2 布局组件
})
it('分组方向按钮:切换单个分组并 emit updateGroups', async () => {
const wrapper = mountEdit()
await nextTick()
await wrapper.find('.mm-fdesign__section-dir').trigger('click')
await nextTick()
const updates = wrapper.emitted('updateGroups')
expect(updates).toBeTruthy()
const updatedGroups = updates.at(-1)[0]
expect(updatedGroups.find((g) => g.b_id === 'g1').b_layout_direction).toBe('horizontal')
})
it('智能偏向判定:按比例最近边缘,鼠标偏向哪条边就插到哪边', async () => {
const rows = [mkRow('a1', 'f1', 'g1', 24, 10), mkRow('a2', 'f2', 'g1', 24, 20)]
const wrapper = mountEdit({ editConfig: rows })
@@ -2752,8 +2739,8 @@ describe('ModuleEditConfigPanel(子表表格设计)', () => {
editConfig: [tableRows[0]],
})
await nextTick()
// 拖拽前:空分组显示拖入提示
expect(wrapper.find('.mm-tdesign__section-drop-hint').text()).toContain('空分组')
// 拖拽前:空分组渲染拖入占位
expect(wrapper.find('.mm-tdesign__section-drop-hint').exists()).toBe(true)
// 模拟拖拽开始(dragPayload 置位)→ 提示隐藏
const list = columnDraggableOf(wrapper)
list.vm.$emit('start', { item: itemEl('f1') })
@@ -2796,7 +2783,8 @@ describe('ModuleEditConfigPanel(子表表格设计)', () => {
await nextTick()
const titles = wrapper.findAll('.mm-tdesign__section-title').map((t) => t.text())
expect(titles.some((t) => t.includes('新分组'))).toBe(true)
expect(wrapper.find('.mm-tdesign__section-drop-hint').text()).toContain('空分组')
// 新空分区渲染拖入占位
expect(wrapper.find('.mm-tdesign__section-drop-hint').exists()).toBe(true)
})
it('字段库已添加字段标记 data-added(拖拽被 filter 拦截,已添加字段不可再拖)', async () => {