/** * FmsModuleEditModal 冒烟测试(V2:编辑配置来自 s_module_schema.edit JSON)。 * 验证:打开弹窗后按 data-code 加载字段与 edit JSON,渲染分组与字段,无配置错误。 */ import { mount } from '@vue/test-utils' import { beforeEach, describe, expect, it, vi } from 'vitest' import { createPinia, setActivePinia } from 'pinia' import { nextTick } from 'vue' vi.mock('@/services/api', () => ({ loadDataApi: vi.fn(async (viewName) => { if (viewName === 's_module') { return { data: [ { b_id: 's_i18n_type', b_name: '语言类型', b_module_type: 'data', b_canuse: 1, b_view_table: 's_i18n_type', b_save_table: 's_i18n_type', b_key_field: 'b_id', }, ], } } if (viewName === 's_field') { return { data: [ { b_field: 'b_id', b_name: '语言编码', b_type: 'input', b_canuse: 1, b_i18n: null }, { b_field: 'b_name', b_name: '语言名称', b_type: 'input', b_canuse: 1, b_i18n: null }, ], } } if (viewName === 's_module_schema') { return { data: [ { b_module_id: 's_i18n_type', b_schema_type: 'edit', b_schema_json: JSON.stringify({ schemaVersion: 2, children: [ { type: 'group', id: 'group1', title: '基础信息', children: [ { type: 'row', children: [{ field: 'b_id', span: 24, required: true }] }, { type: 'row', children: [{ field: 'b_name', span: 24 }] }, ], }, ], }), }, ], } } return { data: [] } }), saveObjectApi: vi.fn(async () => ({})), nextIdApi: vi.fn(async () => ({ data: '1' })), loadDataBySqlApi: vi.fn(async () => ({ data: [] })), })) import FmsModuleEditModal from '@/components/fms-module-edit/FmsModuleEditModal.vue' beforeEach(() => { setActivePinia(createPinia()) }) describe('FmsModuleEditModal 冒烟', () => { it('打开后按 data-code 渲染 edit JSON 的分组与字段', async () => { const wrapper = mount(FmsModuleEditModal, { props: { open: false, dataCode: 's_i18n_type', record: null }, attachTo: document.body, }) await wrapper.setProps({ open: true }) await new Promise((r) => setTimeout(r, 40)) await nextTick() expect(document.querySelector('.fme-error')).toBeNull() const text = document.body.textContent || '' expect(text).toContain('基础信息') expect(text).toContain('语言编码') expect(text).toContain('语言名称') wrapper.unmount() }) })