diff --git a/packages/design/src/Tooltip.vue b/packages/design/src/Tooltip.vue index 6afbc530..2a3716fd 100644 --- a/packages/design/src/Tooltip.vue +++ b/packages/design/src/Tooltip.vue @@ -1,5 +1,11 @@ diff --git a/packages/form/src/containers/GroupListItem.vue b/packages/form/src/containers/GroupListItem.vue index 35582591..371f81f4 100644 --- a/packages/form/src/containers/GroupListItem.vue +++ b/packages/form/src/containers/GroupListItem.vue @@ -80,9 +80,9 @@ - + +
+ { expect(item.props('model')).toEqual({}); }); - test('对比模式隐藏底部操作栏与复制/移动按钮', async () => { + test('对比模式隐藏底部操作栏与复制/移动/删除按钮,且不触发 ElOnlyChild 警告', async () => { + const warn = vi.spyOn(console, 'warn').mockImplementation(() => {}); const wrapper = mountForm( compareConfig, { list: [{ text: 'a' }, { text: 'b' }] }, @@ -192,9 +193,14 @@ describe('GroupList container', () => { await nextTick(); await nextTick(); expect(wrapper.find('.m-fields-group-list-footer').exists()).toBe(false); + expect(wrapper.find('.delete-button').exists()).toBe(false); expect(wrapper.text()).not.toContain('复制'); expect(wrapper.text()).not.toContain('上移'); expect(wrapper.text()).not.toContain('下移'); + expect( + warn.mock.calls.some((args) => args.some((arg) => String(arg?.message ?? arg).includes('ElOnlyChild'))), + ).toBe(false); + warn.mockRestore(); }); }); diff --git a/packages/form/tests/unit/containers/Table.spec.ts b/packages/form/tests/unit/containers/Table.spec.ts index 81f17dff..62e20ddc 100644 --- a/packages/form/tests/unit/containers/Table.spec.ts +++ b/packages/form/tests/unit/containers/Table.spec.ts @@ -3,7 +3,7 @@ * * Copyright (C) 2025 Tencent. */ -import { describe, expect, test } from 'vitest'; +import { describe, expect, test, vi } from 'vitest'; import { nextTick } from 'vue'; import { mount } from '@vue/test-utils'; import ElementPlus from 'element-plus'; @@ -41,4 +41,14 @@ describe('Table container —— 对比模式', () => { await nextTick(); expect(wrapper.text()).not.toContain('清空'); }); + + test('model 为空时不渲染表格,且不触发 ElOnlyChild 警告', async () => { + const warn = vi.spyOn(console, 'warn').mockImplementation(() => {}); + mountTable({ model: { list: undefined } }); + await nextTick(); + expect( + warn.mock.calls.some((args) => args.some((arg) => String(arg?.message ?? arg).includes('ElOnlyChild'))), + ).toBe(false); + warn.mockRestore(); + }); });