wishforge-ide/tests/source-branch.test.ts
eust-w da1cfcea13 🔥 Remove the cloud IDE
The cluster never ran Theia or the IDE gateway, so every workspace stayed
"未配置" forever. The feature is gone instead of half-present:

- API: workspace, launch and lifecycle endpoints, the gateway identity and
  its internal routes, the dispatcher's workspace provisioning and the
  lifecycle worker. Migration 003 deletes stored workspaces and settles
  their pending outbox items.
- Provisioner: workspace provisioning and lifecycle for both backends.
- Web: the 云 IDE panel, the launch route, the start-branch picker that
  listed IDE branches, and the workspace count on usage.
- apps/ide, infra/oct, dev:ide and the CI job; IDE parts of local k3s,
  network policies, RBAC, docs and the architecture diagram.

A wish can still start from a pushed branch through the API (sourceBranch).
Plan files and stored entitlements may still carry maxWorkspaces; it is
accepted and ignored.

Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
2026-11-04 12:43:02 +08:00

53 lines
2.3 KiB
TypeScript
Raw Permalink Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

import { afterEach, beforeEach, describe, expect, it, vi } from 'vitest';
import type { Actor, Project } from '@wishforge/contracts';
import { ControlPlane } from '../apps/api/src/domain/control-plane.js';
import { MemoryStore } from './helpers/memory-store.js';
// A wish may start from a branch people pushed with their own changes.
const env = {
NODE_ENV: 'test',
WF_DISPATCH_TENANTS: 'demo',
WF_GIT_SERVICE_URL: 'http://127.0.0.1:4504',
WF_GIT_ADMIN_TOKEN: 'git-admin-token-for-tests-only-0001',
};
const owner: Actor = { tenantId: 'demo', userId: 'owner', role: 'owner', kind: 'human' };
let store: MemoryStore;
let project: Project;
beforeEach(async () => {
vi.stubGlobal('fetch', async (input: string | URL, init: RequestInit) => {
const body = JSON.parse(String(init.body));
if (new URL(String(input)).pathname === '/repos')
return Response.json({
repositoryUrl: `https://git.test/git/${body.tenantId}/${body.projectId}.git`,
initialCommit: 'a'.repeat(40),
defaultBranch: 'main',
});
return Response.json({ token: 'payload.signature', expiresAt: new Date(Date.now() + 900_000).toISOString() });
});
store = new MemoryStore();
store.seed('demo');
project = await new ControlPlane(store, env).createProject(owner, { name: 'Todo App' });
});
afterEach(() => vi.unstubAllGlobals());
describe('wishes that start from another branch', () => {
it('records the branch on the run and refuses the target branch or the platform’s own branches', async () => {
const control = new ControlPlane(store, env);
const submit = (sourceBranch: string, key: string) =>
control.submit(
owner,
project.id,
{ goal: 'Merge the pushed work', acceptanceCriteria: ['Checks pass'], sourceBranch },
key,
);
await expect(submit('main', 'source-branch-0001')).rejects.toMatchObject({ code: 'INVALID_SOURCE_BRANCH' });
await expect(submit('wishforge/run/abc', 'source-branch-0002')).rejects.toMatchObject({
code: 'INVALID_SOURCE_BRANCH',
});
await expect(submit('../main', 'source-branch-0003')).rejects.toThrow('A safe Git branch name is required');
const { run_id } = await submit('feature/work', 'source-branch-0004');
expect(await control.run(owner, run_id)).toMatchObject({ sourceBranch: 'feature/work' });
});
});