3d709ea1db
- 合并 feat/agc-canvas-resource-workbench-v3:资源卡改为选中+浮出工具条、支持多选、删除资源详情面板与 resourceEditorRoute - index.tsx 冲突以 C3 新结构为底:保留本包的素材重命名回调,丢弃被 C3 取消的 focusedResource 详情面板派生状态与浮层 JSX - 重命名入口从已删除的详情面板搬到选中工具条 extraActions,与「分类与标签」并列 - check-config.mjs 的 allowlist 保持主干版本(normalize_local_project_raster_resource 一行已删) - 还原 normalize_local_project_raster_resource Tauri 命令与注册:C3 已在前端接回调用方 - C7:新增 GameRunVersionPicker 运行模块右上角版本入口,无版本不渲染 - C7:版本状态收敛到 WorkspaceLauncherShell 一份,透传给资源画布与 @ 面板;换项目或版本消失时清回最新版本 - C7:currentVersionResourceBindingIds 接入 activeVersionId,复用 resolveActiveIterationVersion 口径,资源卡「当前使用」高亮随版本切换 - C7:切换版本时复用既有 onPlay 预览入口重载画面,不新增运行时资源重映射 - 新增 10 条测试覆盖版本判定口径、版本入口与切换、当前使用高亮、素材重命名链路
90 lines
2.8 KiB
TypeScript
90 lines
2.8 KiB
TypeScript
import { describe, expect, test } from 'vitest';
|
|
|
|
import {
|
|
currentVersionResourceBindingIds,
|
|
formatIterationVersionLabel,
|
|
isResourceUsedByCurrentVersion,
|
|
} from '../src/features/resource-canvas/resourceCanvasVersionBindingModel';
|
|
|
|
const versions = [
|
|
{
|
|
versionId: 'version-root',
|
|
parentVersionId: null,
|
|
projectRevision: 3,
|
|
resourceBindings: [
|
|
{ slotId: 'asset:asset-player', resourceId: 'asset-player' },
|
|
],
|
|
createdReason: 'initial' as const,
|
|
createdAt: 1_760_000_000_000,
|
|
},
|
|
{
|
|
versionId: 'version-child',
|
|
parentVersionId: 'version-root',
|
|
projectRevision: 4,
|
|
resourceBindings: [
|
|
{ slotId: 'asset:asset-town', resourceId: 'asset-town' },
|
|
// 悬空绑定的 slotId 不是恒等映射,不参与「当前使用」判定。
|
|
{ slotId: 'player', resourceId: 'asset-player' },
|
|
],
|
|
createdReason: 'agent-revision' as const,
|
|
createdAt: 1_760_003_600_000,
|
|
},
|
|
];
|
|
|
|
describe('运行模块版本绑定判定', () => {
|
|
test('falls back to the newest manifest version when no version is selected', () => {
|
|
expect(Array.from(currentVersionResourceBindingIds({ versions }))).toEqual([
|
|
'asset-town',
|
|
]);
|
|
});
|
|
|
|
test('resolves the binding ids of the explicitly selected version', () => {
|
|
expect(
|
|
Array.from(
|
|
currentVersionResourceBindingIds({ versions }, 'version-root'),
|
|
),
|
|
).toEqual(['asset-player']);
|
|
});
|
|
|
|
test('returns no bindings for a missing version or a manifest without versions', () => {
|
|
expect(
|
|
currentVersionResourceBindingIds({ versions }, 'version-missing').size,
|
|
).toBe(0);
|
|
expect(currentVersionResourceBindingIds({}).size).toBe(0);
|
|
expect(currentVersionResourceBindingIds({ versions: [] }).size).toBe(0);
|
|
});
|
|
|
|
test('marks only registered assets bound by the current version as in use', () => {
|
|
const bindingIds = currentVersionResourceBindingIds(
|
|
{ versions },
|
|
'version-root',
|
|
);
|
|
|
|
expect(
|
|
isResourceUsedByCurrentVersion(
|
|
{ manifestAssetId: 'asset-player' },
|
|
bindingIds,
|
|
),
|
|
).toBe(true);
|
|
expect(
|
|
isResourceUsedByCurrentVersion(
|
|
{ manifestAssetId: 'asset-town' },
|
|
bindingIds,
|
|
),
|
|
).toBe(false);
|
|
// 未登记为 manifest 素材的资源永远不算「当前使用」。
|
|
expect(
|
|
isResourceUsedByCurrentVersion({ manifestAssetId: null }, bindingIds),
|
|
).toBe(false);
|
|
});
|
|
|
|
test('labels a version with its Chinese created reason and creation time', () => {
|
|
expect(formatIterationVersionLabel(versions[0])).toBe(
|
|
`初始版本 · ${new Date(1_760_000_000_000).toLocaleString('zh-CN')}`,
|
|
);
|
|
expect(formatIterationVersionLabel(versions[1])).toBe(
|
|
`智能体修订 · ${new Date(1_760_003_600_000).toLocaleString('zh-CN')}`,
|
|
);
|
|
});
|
|
});
|