roymondchen cbc4b25072 feat(editor): 字段对比模式逐项展示差异并补充历史记录面板文档
- CodeSelect/CodeSelectCol/EventSelect/DataSource 等复合字段在对比模式下
  按索引对齐前后值,逐项展示新增/删除/修改高亮,并隐藏写操作按钮
- form 容器/列表/表格支持对比模式只读展示
- 新增「历史记录面板」指南文档,完善表单对比文档及 menu props 说明
- 补充相关单元测试

Co-authored-by: Cursor <cursoragent@cursor.com>
2026-05-29 15:51:47 +08:00

44 lines
1.6 KiB
TypeScript
Raw Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

/*
* Tencent is pleased to support the open source community by making TMagicEditor available.
*
* Copyright (C) 2025 Tencent.
*/
import { describe, expect, test } from 'vitest';
import { nextTick } from 'vue';
import Table from '@form/containers/table/Table.vue';
import MagicForm from '@form/index';
import { mount } from '@vue/test-utils';
import ElementPlus from 'element-plus';
// el-table 在 happy-dom 下的 MutationObserver 会报错,这里直接 stub 掉表格本体;
// 导入 / 清空 / 新增按钮的显隐只取决于 importable & isCompare与表格渲染无关。
const mountTable = (props: any) =>
mount(Table as any, {
global: {
plugins: [ElementPlus as any, MagicForm as any],
// 设计层 TMagicTable 组件名为 TMTable底层渲染 el-table故按真实名 stub
stubs: { TMTable: true, TMagicTable: true, ElTable: true },
},
props: {
name: 'list',
prop: 'list',
config: { type: 'table', name: 'list', importable: true, items: [{ name: 'text', type: 'text' }] },
model: { list: [{ text: 'a' }] },
...props,
},
});
describe('Table container —— 对比模式', () => {
test('非对比模式展示「清空」等导入相关按钮', async () => {
const wrapper = mountTable({ isCompare: false });
await nextTick();
expect(wrapper.text()).toContain('清空');
});
test('对比模式隐藏「清空」等导入相关按钮', async () => {
const wrapper = mountTable({ isCompare: true, lastValues: { list: [{ text: 'a' }] } });
await nextTick();
expect(wrapper.text()).not.toContain('清空');
});
});