216407d93e
冻结资源画布布局数据与 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>
28 lines
1.2 KiB
TypeScript
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);
|
|
});
|
|
});
|