Files
Genarrative/apps/ai-game-creator-shell/tests/resourceCanvasLayoutContract.test.ts
T
menghao 216407d93e
Project CI / Frontend tests (push) Failing after 20s
Project CI / Repository checks (push) Successful in 1m2s
Project CI / Backend tests (push) Successful in 2m59s
Project CI / Native shell tests (push) Successful in 11m58s
实现资源画布布局持久化 (#116)
冻结资源画布布局数据与 CAS 合同
实现双模式本地 sidecar 安全读写
接入二维拖动、默认排版和跨重启恢复
补齐并发冲突、安全边界和界面测试
同步技术文档与共享决策

Reviewed-on: http://192.168.35.82/git/GenarrativeAI/Genarrative/pulls/116
Reviewed-by: 段舒康 <kdletters@qq.com>
Co-authored-by: menghao <mh18530625731@163.com>
Co-committed-by: menghao <mh18530625731@163.com>
2026-07-31 12:00:48 +08:00

28 lines
1.2 KiB
TypeScript

import { describe, expect, it } from 'vitest';
import {
GAME_CREATION_RESOURCE_LAYOUT_MAX_SAFE_REVISION,
isSafeProjectResourceCanvasLayoutRevision,
} from '../../../packages/shared/src/contracts/gameCreationApp';
describe('resource canvas layout contract', () => {
it('keeps revisions inside the JSON safe integer range', () => {
const maxRevision = GAME_CREATION_RESOURCE_LAYOUT_MAX_SAFE_REVISION;
expect(JSON.parse(JSON.stringify({ revision: maxRevision }))).toEqual({
revision: maxRevision,
});
expect(isSafeProjectResourceCanvasLayoutRevision(0)).toBe(true);
expect(isSafeProjectResourceCanvasLayoutRevision(maxRevision)).toBe(true);
expect(isSafeProjectResourceCanvasLayoutRevision(maxRevision + 1)).toBe(
false,
);
expect(isSafeProjectResourceCanvasLayoutRevision(-1)).toBe(false);
expect(isSafeProjectResourceCanvasLayoutRevision(1.5)).toBe(false);
expect(isSafeProjectResourceCanvasLayoutRevision(Number.NaN)).toBe(false);
expect(
isSafeProjectResourceCanvasLayoutRevision(Number.POSITIVE_INFINITY),
).toBe(false);
expect(isSafeProjectResourceCanvasLayoutRevision('1')).toBe(false);
});
});