63 lines
2.4 KiB
TypeScript
63 lines
2.4 KiB
TypeScript
import { readFileSync } from 'node:fs';
|
|
import { resolve } from 'node:path';
|
|
|
|
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 wide resource content inside an explicitly scrollable stage column', () => {
|
|
const styles = readFileSync(
|
|
resolve(process.cwd(), 'apps/ai-game-creator-shell/src/styles.css'),
|
|
'utf8',
|
|
);
|
|
const stageRule = styles.match(
|
|
/\.game-workbench-stage\s*\{([^}]*)\}/s,
|
|
);
|
|
const managerRule = styles.match(
|
|
/\.game-resource-manager\s*\{([^}]*)\}/s,
|
|
);
|
|
const canvasRule = styles.match(
|
|
/\.game-resource-canvas\s*\{([^}]*)\}/s,
|
|
);
|
|
|
|
expect(stageRule?.[1]).toContain(
|
|
'grid-template-columns: minmax(0, 1fr);',
|
|
);
|
|
expect(managerRule?.[1]).toContain('min-width: 0;');
|
|
expect(managerRule?.[1]).toContain('overflow: hidden;');
|
|
expect(canvasRule?.[1]).toContain('width: 100%;');
|
|
expect(canvasRule?.[1]).toContain('min-width: 0;');
|
|
expect(canvasRule?.[1]).toContain('overflow-x: auto;');
|
|
expect(canvasRule?.[1]).toContain('overflow-y: auto;');
|
|
expect(styles).toMatch(
|
|
/\.game-resource-canvas::-webkit-scrollbar\s*\{[^}]*height:\s*12px/s,
|
|
);
|
|
expect(styles).toMatch(
|
|
/\.game-resource-canvas::-webkit-scrollbar-thumb\s*\{[^}]*background:\s*#d5a089/s,
|
|
);
|
|
});
|
|
|
|
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);
|
|
});
|
|
});
|