import { mount } from '@vue/test-utils' import { createPinia, setActivePinia } from 'pinia' import { beforeEach, describe, expect, it } from 'vitest' import FmsQueryControl from '@/components/fms-module-list/FmsQueryControl.vue' import FmsQueryToolbar from '@/components/fms-module-list/FmsQueryToolbar.vue' import FmsAdvancedQueryPanel from '@/components/fms-module-list/FmsAdvancedQueryPanel.vue' describe('fms-module-list components', () => { beforeEach(() => setActivePinia(createPinia())) it('mounts a text query control with the new UI kit', () => { const wrapper = mount(FmsQueryControl, { props: { item: { field: { b_field: 'name', b_type: 'input' }, config: { b_operator: 'like', b_component: 'input' }, }, modelValue: '', }, }) expect(wrapper.find('input').exists()).toBe(true) }) it('mounts an empty toolbar without legacy Ant components', () => { const wrapper = mount(FmsQueryToolbar) expect(wrapper.find('.fms-query-toolbar').exists()).toBe(true) expect(wrapper.html()).not.toContain(' { const state = { nodes: [ { id: 'n1', join: 'and', field: 'name', operator: 'like', value: 'a' }, { id: 'n2', join: 'and', field: 'name', operator: 'like', value: 'b' }, ], groups: [], } const wrapper = mount(FmsAdvancedQueryPanel, { props: { open: true, items: [], modelValue: state }, }) const pill = wrapper.find('.filter-joiner .joiner-pill') expect(pill.exists()).toBe(true) expect(pill.text()).toBe('且') await pill.trigger('click') expect(state.nodes[1].join).toBe('or') expect(wrapper.find('.filter-joiner .joiner-pill').text()).toBe('或') wrapper.unmount() }) it('只有 1 个条件时不显示行间连接符(没有连接对象),条件行直接可见', () => { const wrapper = mount(FmsAdvancedQueryPanel, { props: { open: true, items: [], modelValue: { logic: 'and', nodes: [{ id: 'n1', field: 'name', operator: 'like', value: '' }], groups: [], }, }, }) expect(wrapper.find('.filter-joiner').exists()).toBe(false) expect(wrapper.find('.filter-row').exists()).toBe(true) wrapper.unmount() }) })