feat: implement database schema with Prisma ORM
Add PostgreSQL schema with 8 models (User, Session, McpServer, McpProfile,
Project, ProjectMcpProfile, McpInstance, AuditLog), comprehensive model
tests (31 passing), seed data for default MCP servers, and package exports.
Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
2026-02-21 04:10:40 +00:00
|
|
|
import { describe, it, expect, beforeAll, afterAll, beforeEach } from 'vitest';
|
|
|
|
|
import type { PrismaClient } from '@prisma/client';
|
|
|
|
|
import { setupTestDb, cleanupTestDb, clearAllTables } from './helpers.js';
|
|
|
|
|
import { seedMcpServers, defaultServers } from '../src/seed/index.js';
|
|
|
|
|
|
|
|
|
|
let prisma: PrismaClient;
|
|
|
|
|
|
|
|
|
|
beforeAll(async () => {
|
|
|
|
|
prisma = await setupTestDb();
|
|
|
|
|
}, 30_000);
|
|
|
|
|
|
|
|
|
|
afterAll(async () => {
|
|
|
|
|
await cleanupTestDb();
|
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
beforeEach(async () => {
|
|
|
|
|
await clearAllTables(prisma);
|
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
describe('seedMcpServers', () => {
|
|
|
|
|
it('seeds all default servers', async () => {
|
|
|
|
|
const count = await seedMcpServers(prisma);
|
|
|
|
|
expect(count).toBe(defaultServers.length);
|
|
|
|
|
|
|
|
|
|
const servers = await prisma.mcpServer.findMany({ orderBy: { name: 'asc' } });
|
|
|
|
|
expect(servers).toHaveLength(defaultServers.length);
|
|
|
|
|
|
|
|
|
|
const names = servers.map((s) => s.name);
|
|
|
|
|
expect(names).toContain('slack');
|
|
|
|
|
expect(names).toContain('github');
|
|
|
|
|
expect(names).toContain('jira');
|
|
|
|
|
expect(names).toContain('terraform');
|
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
it('is idempotent (upsert)', async () => {
|
|
|
|
|
await seedMcpServers(prisma);
|
|
|
|
|
const count = await seedMcpServers(prisma);
|
|
|
|
|
expect(count).toBe(defaultServers.length);
|
|
|
|
|
|
|
|
|
|
const servers = await prisma.mcpServer.findMany();
|
|
|
|
|
expect(servers).toHaveLength(defaultServers.length);
|
|
|
|
|
});
|
|
|
|
|
|
feat: replace profiles with kubernetes-style secrets
Replace the confused Profile abstraction with a dedicated Secret resource
following Kubernetes conventions. Servers now have env entries with inline
values or secretRef references. Env vars are resolved and passed to
containers at startup (fixes existing gap).
- Add Secret CRUD (model, repo, service, routes, CLI commands)
- Server env: {name, value} or {name, valueFrom: {secretRef: {name, key}}}
- Add env-resolver utility shared by instance startup and config generation
- Remove all profile-related code (models, services, routes, CLI, tests)
- Update backup/restore for secrets instead of profiles
- describe secret masks values by default, --show-values to reveal
Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
2026-02-22 18:40:58 +00:00
|
|
|
it('seeds env correctly', async () => {
|
feat: implement database schema with Prisma ORM
Add PostgreSQL schema with 8 models (User, Session, McpServer, McpProfile,
Project, ProjectMcpProfile, McpInstance, AuditLog), comprehensive model
tests (31 passing), seed data for default MCP servers, and package exports.
Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
2026-02-21 04:10:40 +00:00
|
|
|
await seedMcpServers(prisma);
|
|
|
|
|
const slack = await prisma.mcpServer.findUnique({ where: { name: 'slack' } });
|
feat: replace profiles with kubernetes-style secrets
Replace the confused Profile abstraction with a dedicated Secret resource
following Kubernetes conventions. Servers now have env entries with inline
values or secretRef references. Env vars are resolved and passed to
containers at startup (fixes existing gap).
- Add Secret CRUD (model, repo, service, routes, CLI commands)
- Server env: {name, value} or {name, valueFrom: {secretRef: {name, key}}}
- Add env-resolver utility shared by instance startup and config generation
- Remove all profile-related code (models, services, routes, CLI, tests)
- Update backup/restore for secrets instead of profiles
- describe secret masks values by default, --show-values to reveal
Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
2026-02-22 18:40:58 +00:00
|
|
|
const env = slack!.env as Array<{ name: string; value?: string }>;
|
|
|
|
|
expect(env).toEqual([]);
|
feat: implement database schema with Prisma ORM
Add PostgreSQL schema with 8 models (User, Session, McpServer, McpProfile,
Project, ProjectMcpProfile, McpInstance, AuditLog), comprehensive model
tests (31 passing), seed data for default MCP servers, and package exports.
Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
2026-02-21 04:10:40 +00:00
|
|
|
});
|
|
|
|
|
|
|
|
|
|
it('accepts custom server list', async () => {
|
|
|
|
|
const custom = [
|
|
|
|
|
{
|
|
|
|
|
name: 'custom-server',
|
|
|
|
|
description: 'Custom test server',
|
|
|
|
|
packageName: '@test/custom',
|
|
|
|
|
transport: 'STDIO' as const,
|
|
|
|
|
repositoryUrl: 'https://example.com',
|
feat: replace profiles with kubernetes-style secrets
Replace the confused Profile abstraction with a dedicated Secret resource
following Kubernetes conventions. Servers now have env entries with inline
values or secretRef references. Env vars are resolved and passed to
containers at startup (fixes existing gap).
- Add Secret CRUD (model, repo, service, routes, CLI commands)
- Server env: {name, value} or {name, valueFrom: {secretRef: {name, key}}}
- Add env-resolver utility shared by instance startup and config generation
- Remove all profile-related code (models, services, routes, CLI, tests)
- Update backup/restore for secrets instead of profiles
- describe secret masks values by default, --show-values to reveal
Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
2026-02-22 18:40:58 +00:00
|
|
|
env: [],
|
feat: implement database schema with Prisma ORM
Add PostgreSQL schema with 8 models (User, Session, McpServer, McpProfile,
Project, ProjectMcpProfile, McpInstance, AuditLog), comprehensive model
tests (31 passing), seed data for default MCP servers, and package exports.
Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
2026-02-21 04:10:40 +00:00
|
|
|
},
|
|
|
|
|
];
|
|
|
|
|
const count = await seedMcpServers(prisma, custom);
|
|
|
|
|
expect(count).toBe(1);
|
|
|
|
|
|
|
|
|
|
const servers = await prisma.mcpServer.findMany();
|
|
|
|
|
expect(servers).toHaveLength(1);
|
|
|
|
|
expect(servers[0].name).toBe('custom-server');
|
|
|
|
|
});
|
|
|
|
|
});
|