910862fd06
稳定工作台与窗口标题栏状态同步,消除重复更新循环 支持画布右键平移并保留左键框选及资源拖动,完善中断清理 解耦运行不可用提示与资源选中状态 复用原生UI状态校验区分UI设计JSON和普通JSON,接入现有编辑器与代码预览 补充前端和原生回归测试、规范及待验收记录,明确对话历史分页尚未修复
88 lines
2.3 KiB
TypeScript
88 lines
2.3 KiB
TypeScript
import { describe, expect, it } from 'vitest';
|
|
|
|
import {
|
|
type ProjectResourceCardPreviewState,
|
|
projectResourceJsonPresentation,
|
|
} from '../src/view/project-development/resourceCardPreviewModel';
|
|
import type { ProjectResource } from '../src/view/project-development/resourceProjectionModel';
|
|
|
|
const resource: ProjectResource = {
|
|
id: 'asset:json',
|
|
manifestAssetId: 'json',
|
|
path: 'ui/design.json',
|
|
label: '设计',
|
|
mediaType: 'application/json',
|
|
subtype: 'UI',
|
|
category: 'document',
|
|
sourceLabel: '',
|
|
taskTitle: null,
|
|
producerTaskId: null,
|
|
externalResourceId: null,
|
|
referenceResourceIds: [],
|
|
dependencies: [],
|
|
dependencyDepth: 0,
|
|
};
|
|
const verified: ProjectResourceCardPreviewState = {
|
|
status: 'loaded',
|
|
preview: {
|
|
path: resource.path,
|
|
mediaType: 'application/json',
|
|
byteLen: 2,
|
|
content: '{}',
|
|
uiDesignAssetId: 'json',
|
|
},
|
|
};
|
|
|
|
describe('JSON 卡片呈现', () => {
|
|
it.each(['UI', 'ui', 'ui-design', 'document'])(
|
|
'合法识别不依赖 %s 标签',
|
|
(subtype) => {
|
|
expect(
|
|
projectResourceJsonPresentation({ ...resource, subtype }, verified),
|
|
).toBe('ui-design');
|
|
expect(
|
|
projectResourceJsonPresentation(
|
|
{ ...resource, subtype },
|
|
{
|
|
...verified,
|
|
preview: { ...verified.preview, uiDesignAssetId: undefined },
|
|
},
|
|
),
|
|
).toBe('json');
|
|
},
|
|
);
|
|
it('原生读取未完成、失败或身份不匹配时保持普通 JSON,不推断编辑能力', () => {
|
|
for (const preview of [
|
|
null,
|
|
{ status: 'loading' },
|
|
{ status: 'failed', error: '读取失败', retryable: true },
|
|
] as const) {
|
|
expect(projectResourceJsonPresentation(resource, preview)).toBe('json');
|
|
}
|
|
expect(
|
|
projectResourceJsonPresentation(
|
|
{ ...resource, manifestAssetId: 'other' },
|
|
verified,
|
|
),
|
|
).toBe('json');
|
|
expect(
|
|
projectResourceJsonPresentation(
|
|
{ ...resource, path: 'other.json' },
|
|
verified,
|
|
),
|
|
).toBe('json');
|
|
expect(
|
|
projectResourceJsonPresentation(
|
|
{ ...resource, manifestAssetId: null },
|
|
verified,
|
|
),
|
|
).toBe('json');
|
|
expect(
|
|
projectResourceJsonPresentation(
|
|
{ ...resource, path: 'image.png', mediaType: 'image/png' },
|
|
verified,
|
|
),
|
|
).toBeNull();
|
|
});
|
|
});
|