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';
|
2026-02-22 22:24:35 +00:00
|
|
|
import { seedTemplates } from '../src/seed/index.js';
|
|
|
|
|
import type { SeedTemplate } from '../src/seed/index.js';
|
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
|
|
|
|
|
|
|
|
let prisma: PrismaClient;
|
|
|
|
|
|
|
|
|
|
beforeAll(async () => {
|
|
|
|
|
prisma = await setupTestDb();
|
|
|
|
|
}, 30_000);
|
|
|
|
|
|
|
|
|
|
afterAll(async () => {
|
|
|
|
|
await cleanupTestDb();
|
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
beforeEach(async () => {
|
|
|
|
|
await clearAllTables(prisma);
|
|
|
|
|
});
|
|
|
|
|
|
2026-02-22 22:24:35 +00:00
|
|
|
const testTemplates: SeedTemplate[] = [
|
|
|
|
|
{
|
|
|
|
|
name: 'github',
|
|
|
|
|
version: '1.0.0',
|
|
|
|
|
description: 'GitHub MCP server',
|
|
|
|
|
packageName: '@anthropic/github-mcp',
|
|
|
|
|
transport: 'STDIO',
|
|
|
|
|
env: [{ name: 'GITHUB_TOKEN', description: 'Personal access token', required: true }],
|
|
|
|
|
},
|
|
|
|
|
{
|
|
|
|
|
name: 'slack',
|
|
|
|
|
version: '1.0.0',
|
|
|
|
|
description: 'Slack MCP server',
|
|
|
|
|
packageName: '@anthropic/slack-mcp',
|
|
|
|
|
transport: 'STDIO',
|
|
|
|
|
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
|
|
|
|
2026-02-22 22:24:35 +00:00
|
|
|
describe('seedTemplates', () => {
|
|
|
|
|
it('seeds templates', async () => {
|
|
|
|
|
const count = await seedTemplates(prisma, testTemplates);
|
|
|
|
|
expect(count).toBe(2);
|
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
|
|
|
|
2026-02-22 22:24:35 +00:00
|
|
|
const templates = await prisma.mcpTemplate.findMany({ orderBy: { name: 'asc' } });
|
|
|
|
|
expect(templates).toHaveLength(2);
|
|
|
|
|
expect(templates.map((t) => t.name)).toEqual(['github', 'slack']);
|
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('is idempotent (upsert)', async () => {
|
2026-02-22 22:24:35 +00:00
|
|
|
await seedTemplates(prisma, testTemplates);
|
|
|
|
|
const count = await seedTemplates(prisma, testTemplates);
|
|
|
|
|
expect(count).toBe(2);
|
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
|
|
|
|
2026-02-22 22:24:35 +00:00
|
|
|
const templates = await prisma.mcpTemplate.findMany();
|
|
|
|
|
expect(templates).toHaveLength(2);
|
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
|
|
|
});
|
|
|
|
|
|
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 () => {
|
2026-02-22 22:24:35 +00:00
|
|
|
await seedTemplates(prisma, testTemplates);
|
|
|
|
|
const github = await prisma.mcpTemplate.findUnique({ where: { name: 'github' } });
|
|
|
|
|
const env = github!.env as Array<{ name: string; description?: string; required?: boolean }>;
|
|
|
|
|
expect(env).toHaveLength(1);
|
|
|
|
|
expect(env[0].name).toBe('GITHUB_TOKEN');
|
|
|
|
|
expect(env[0].required).toBe(true);
|
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
|
|
|
});
|
|
|
|
|
|
2026-02-22 22:24:35 +00:00
|
|
|
it('accepts custom template list', async () => {
|
|
|
|
|
const custom: SeedTemplate[] = [
|
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
|
|
|
{
|
2026-02-22 22:24:35 +00:00
|
|
|
name: 'custom-template',
|
|
|
|
|
version: '2.0.0',
|
|
|
|
|
description: 'Custom test template',
|
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
|
|
|
packageName: '@test/custom',
|
2026-02-22 22:24:35 +00:00
|
|
|
transport: 'STDIO',
|
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
|
|
|
},
|
|
|
|
|
];
|
2026-02-22 22:24:35 +00:00
|
|
|
const count = await seedTemplates(prisma, custom);
|
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
|
|
|
expect(count).toBe(1);
|
|
|
|
|
|
2026-02-22 22:24:35 +00:00
|
|
|
const templates = await prisma.mcpTemplate.findMany();
|
|
|
|
|
expect(templates).toHaveLength(1);
|
|
|
|
|
expect(templates[0].name).toBe('custom-template');
|
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
|
|
|
});
|
|
|
|
|
});
|