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>
56 lines
2.6 KiB
JavaScript
56 lines
2.6 KiB
JavaScript
import test from 'node:test';
|
|
import assert from 'node:assert/strict';
|
|
import { renderWorkspaceResources, provisionWorkspace } from '../workspaces.mjs';
|
|
const config = {
|
|
tenantId: 'alpha',
|
|
namespace: 'wf-alpha',
|
|
controlNamespace: 'wf-control',
|
|
runtimeClass: 'wishforge-kata',
|
|
storageClass: 'test-storage',
|
|
storageSize: '10Gi',
|
|
};
|
|
const input = { tenantId: 'alpha', projectId: 'project-1', workspaceId: 'workspace-1' };
|
|
const image = `registry.invalid/theia@sha256:${'a'.repeat(64)}`;
|
|
test('workspace provisioning uses the actual Theia start contract and a private isolated endpoint', () => {
|
|
const rendered = renderWorkspaceResources(config, input, image);
|
|
const pod = rendered.resources.find(r => r.kind === 'Deployment').spec.template.spec;
|
|
assert.equal(pod.runtimeClassName, 'wishforge-kata');
|
|
assert.equal(pod.automountServiceAccountToken, false);
|
|
const env = Object.fromEntries(pod.containers[0].env.map(e => [e.name, e.value]));
|
|
assert.equal(env.WISHFORGE_IDE_PORT, '3000');
|
|
assert.equal(env.WISHFORGE_GATEWAY_ENFORCED, 'true');
|
|
assert.equal(env.WISHFORGE_WORKSPACE_PATH, '/home/theia/data/workspace');
|
|
assert.equal(env.WISHFORGE_COLLABORATION_ENABLED, 'false');
|
|
assert.equal(rendered.resources.find(r => r.kind === 'Service').spec.type, 'ClusterIP');
|
|
});
|
|
test('creating manifests does not mark an unready IDE available', async () => {
|
|
let applied = false;
|
|
const result = await provisionWorkspace(config, input, {
|
|
image,
|
|
apply: async () => {
|
|
applied = true;
|
|
},
|
|
observe: async () => false,
|
|
});
|
|
assert.ok(applied);
|
|
assert.equal(result.status, 'pending');
|
|
assert.throws(() => renderWorkspaceResources(config, { ...input, tenantId: 'beta' }, image));
|
|
});
|
|
test('scoped collaboration and coordination expose only public identity material to the workspace', () => {
|
|
const rendered = renderWorkspaceResources({ ...config, gatewayPublicKeyConfigMap: 'gateway-public' }, input, image, {
|
|
image,
|
|
gatewayBase: 'https://ide.example/',
|
|
});
|
|
const pod = rendered.resources.find(r => r.kind === 'Deployment').spec.template.spec;
|
|
{
|
|
assert.equal(pod.containers.length, 2);
|
|
assert.ok(pod.containers[0].env.some(e => e.name === 'WF_IDE_GATEWAY_PUBLIC_KEY_FILE'));
|
|
assert.ok(!JSON.stringify(pod).includes('PRIVATE_KEY'));
|
|
assert.ok(pod.volumes.some(v => v.name === 'coordination-state'));
|
|
const octEnv = Object.fromEntries(pod.containers[1].env.map(e => [e.name, e.value]));
|
|
assert.equal(octEnv.WF_WORKSPACE_ID, input.workspaceId);
|
|
assert.equal(octEnv.WISHFORGE_GATEWAY_ENFORCED, 'true');
|
|
assert.ok(rendered.collaborationUpstreamUrl.endsWith(':8100'));
|
|
}
|
|
});
|