Files
core2026/app/gateway-api/test/scenarioCatalog.test.ts
T
Hide_D 1648b6aa84 feat: 일반 사용자 오픈 건의 양식을 추가한다
활성 profile 빌드의 시나리오 catalog를 세션 기반 읽기 전용 API로 제공한다. Gateway에서 초기화 옵션을 살펴보고 Ref 예약 공지 형식의 제안 문구를 복사하되 서버 mutation은 호출하지 않도록 한다.
2026-08-22 09:07:29 +00:00

33 lines
1.3 KiB
TypeScript

import { describe, expect, it } from 'vitest';
import { listScenarioPreviews, resolveGitCommitSha } from '../src/scenario/scenarioCatalog.js';
describe('scenarioCatalog git ref support', () => {
it('resolves HEAD to a commit hash', async () => {
const commitSha = await resolveGitCommitSha('HEAD');
expect(commitSha).toMatch(/^[0-9a-f]{40}$/i);
});
it('loads scenario previews from a git ref', async () => {
const previews = await listScenarioPreviews({ gitRef: 'HEAD' });
expect(previews.length).toBeGreaterThan(0);
const ids = previews.map((scenario) => scenario.id);
const sorted = [...ids].sort((a, b) => a - b);
expect(ids).toEqual(sorted);
expect(previews.every((scenario) => scenario.defaultStatTotal > 0)).toBe(true);
expect(previews.every((scenario) => scenario.fiction === null || Number.isInteger(scenario.fiction))).toBe(
true
);
});
it('rejects without crashing when git cannot be spawned', async () => {
const originalPath = process.env.PATH;
process.env.PATH = '/nonexistent';
try {
await expect(resolveGitCommitSha('HEAD')).rejects.toThrow('git ref not found.');
} finally {
process.env.PATH = originalPath;
}
});
});