feat: 展示 AI 资源创建人信息

- 为 Bot、工作流、知识库、插件列表补充创建人名称回填

- 在卡片中展示创建者与创建时间

- 补充后端与前端对应测试
This commit is contained in:
2026-04-13 14:58:14 +08:00
parent ae10383f17
commit 855e93ecbf
17 changed files with 642 additions and 3 deletions

View File

@@ -14,6 +14,16 @@ vi.mock('@easyflow/access', () => ({
}),
}));
vi.mock('#/locales', () => ({
$t: (key: string) => {
const labelMap: Record<string, string> = {
'aiResource.created': '创建时间',
'aiResource.createdBy': '创建者',
};
return labelMap[key] || key;
},
}));
describe('cardList', () => {
function mountCardList(props: Record<string, unknown>) {
return mount(CardList, {
@@ -110,4 +120,55 @@ describe('cardList', () => {
expect(wrapper.get('.card-item').attributes('role')).toBeUndefined();
expect(legacyAction).toHaveBeenCalledTimes(1);
});
it('同时展示创建人与创建时间', () => {
const wrapper = mountCardList({
data: [
{
id: 'bot-1',
title: '演示卡片',
description: '用于验证元信息展示',
createdByName: '管理员',
created: '2026-04-12 10:00:00',
},
],
});
const metaText = wrapper.get('.card-meta-row').text();
expect(metaText).toContain('创建者:管理员');
expect(metaText).toContain('创建时间2026-04-12 10:00:00');
});
it('缺少创建人时仅展示创建时间', () => {
const wrapper = mountCardList({
data: [
{
id: 'bot-1',
title: '演示卡片',
description: '用于验证元信息展示',
created: '2026-04-12 10:00:00',
},
],
});
const metaText = wrapper.get('.card-meta-row').text();
expect(metaText).toContain('创建时间2026-04-12 10:00:00');
expect(metaText).not.toContain('创建者:');
});
it('缺少创建信息时不渲染元信息区', () => {
const wrapper = mountCardList({
data: [
{
id: 'bot-1',
title: '演示卡片',
description: '用于验证元信息展示',
},
],
});
expect(wrapper.find('.card-meta-row').exists()).toBe(false);
});
});