105 lines
3.1 KiB
JavaScript
105 lines
3.1 KiB
JavaScript
/**
|
|
* FmsModuleListPage 冒烟测试(V2:元数据来自 s_field + s_module_schema JSON)。
|
|
* 验证:按模块编码加载字段与 view/query 界面配置后,能正常渲染数据列、无配置错误。
|
|
*/
|
|
import { mount } from '@vue/test-utils'
|
|
import { beforeEach, describe, expect, it, vi } from 'vitest'
|
|
import { createPinia, setActivePinia } from 'pinia'
|
|
import { nextTick } from 'vue'
|
|
import { registerFeature, useAreaSelection } from 'stk-table-vue'
|
|
|
|
registerFeature(useAreaSelection)
|
|
|
|
vi.mock('vue-router', () => ({
|
|
useRoute: () => ({ path: '/module/i18n-type', meta: {} }),
|
|
}))
|
|
|
|
vi.mock('@/services/api', () => ({
|
|
loadDataApi: vi.fn(async (viewName) => {
|
|
if (viewName === 's_module') {
|
|
return {
|
|
data: [
|
|
{
|
|
b_id: 's_i18n_type',
|
|
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: 'view',
|
|
b_schema_json: JSON.stringify({
|
|
schemaVersion: 1,
|
|
columns: [
|
|
{ field: 'b_id', width: 120 },
|
|
{ field: 'b_name', width: 180 },
|
|
],
|
|
}),
|
|
},
|
|
{
|
|
b_module_id: 's_i18n_type',
|
|
b_schema_type: 'query',
|
|
b_schema_json: JSON.stringify({
|
|
schemaVersion: 1,
|
|
quick: ['b_name'],
|
|
groups: [{ logic: 'and', conditions: [{ field: 'b_name', operator: 'like' }] }],
|
|
}),
|
|
},
|
|
],
|
|
}
|
|
}
|
|
return { data: [] }
|
|
}),
|
|
pageDataApi: vi.fn(async () => ({
|
|
data: { rows: [{ b_id: 'zh-CN', b_name: '简体中文' }], total: 1 },
|
|
})),
|
|
saveObjectApi: vi.fn(async () => ({})),
|
|
nextIdApi: vi.fn(async () => ({ data: '1' })),
|
|
loadDataBySqlApi: vi.fn(async () => ({ data: [] })),
|
|
}))
|
|
|
|
import FmsModuleListPage from '@/components/fms-module-list/FmsModuleListPage.vue'
|
|
|
|
beforeEach(() => {
|
|
setActivePinia(createPinia())
|
|
Object.defineProperty(HTMLElement.prototype, 'clientWidth', {
|
|
configurable: true,
|
|
get() {
|
|
return 5000
|
|
},
|
|
})
|
|
})
|
|
|
|
describe('FmsModuleListPage 冒烟', () => {
|
|
it('按 data-code 加载字段与界面配置后渲染列,无配置错误', async () => {
|
|
const wrapper = mount(FmsModuleListPage, {
|
|
props: { dataCode: 's_i18n_type' },
|
|
attachTo: document.body,
|
|
})
|
|
await new Promise((r) => setTimeout(r, 60))
|
|
await nextTick()
|
|
|
|
expect(wrapper.find('.module-config-error').exists()).toBe(false)
|
|
const text = wrapper.text()
|
|
expect(text).toContain('语言编码')
|
|
expect(text).toContain('语言名称')
|
|
wrapper.unmount()
|
|
})
|
|
})
|