wishforge-ide/tests/repository-input.test.ts
eust-w 0ef99b1e6d style: add Prettier and EditorConfig, format the codebase
Adds prettier 3.9.8 (exact) with a shared config (single quotes,
120 columns, trailing commas), .prettierignore, .editorconfig and the
`format` / `format:check` scripts, then formats all TypeScript,
JavaScript, CSS, JSON and YAML sources.

Purely mechanical: no behaviour change. Typecheck passes, the vitest
suite and the 74 IDE node tests produce the same results as before
(socket-binding tests still cannot run inside this sandbox).
Previously the longest source line was ~3000 characters; reviewing the
following semantic changes now produces readable diffs.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-10-19 13:32:43 +08:00

39 lines
1.8 KiB
TypeScript

import { beforeEach, expect, it } from 'vitest';
import type { Actor } from '@wishforge/contracts';
import { ControlPlane } from '../apps/api/src/domain/control-plane.js';
import { MemoryStore } from './helpers/memory-store.js';
const owner: Actor = { tenantId: 'alpha', userId: 'owner', kind: 'human', role: 'owner' };
let store: MemoryStore;
beforeEach(() => {
store = new MemoryStore();
store.seed('alpha');
});
it('rejects SSH/SCP at project creation before persistence and describes the HTTPS capability', async () => {
const control = new ControlPlane(store, { NODE_ENV: 'test' });
for (const repositoryUrl of ['ssh://git@github.com/org/repo.git', 'git@github.com:org/repo.git'])
await expect(control.createProject(owner, { name: 'Unsupported', repositoryUrl })).rejects.toMatchObject({
code: 'INVALID_REPOSITORY',
status: 400,
message: expect.stringContaining('SSH'),
});
expect(await control.projects(owner)).toHaveLength(0);
});
it('only accepts loopback HTTP with the explicit development switch and never in production', async () => {
const repositoryUrl = 'http://127.0.0.1:4504/fixture.git';
await expect(
new ControlPlane(store, { NODE_ENV: 'test' }).createProject(owner, { name: 'Denied', repositoryUrl }),
).rejects.toMatchObject({ code: 'INVALID_REPOSITORY' });
await expect(
new ControlPlane(store, { NODE_ENV: 'production', WF_GIT_ALLOW_LOCAL_HTTP: 'true' }).createProject(owner, {
name: 'Denied',
repositoryUrl,
}),
).rejects.toMatchObject({ code: 'INVALID_REPOSITORY' });
expect(
await new ControlPlane(store, { NODE_ENV: 'test', WF_GIT_ALLOW_LOCAL_HTTP: 'true' }).createProject(owner, {
name: 'Local fixture',
repositoryUrl,
}),
).toMatchObject({ repositoryUrl, targetBranch: 'main' });
});