import { supabase } from '../db/client.js';
import { listStyles, getStyleDetails } from '../tools/styles.js';
import { listPalettes, getPaletteDetails } from '../tools/palettes.js';
import { recommendDesign } from '../tools/recommend.js';
describe('WebForge MCP Server', () => {
test('Database connection', async () => {
const isConnected = await supabase.testConnection();
expect(isConnected).toBe(true);
});
test('List styles', async () => {
try {
const result = await listStyles();
expect(result).toHaveProperty('styles');
expect(result).toHaveProperty('total');
expect(Array.isArray(result.styles)).toBe(true);
} catch (error) {
// Tables might not exist yet, that's ok for initial test
expect(error).toBeDefined();
}
});
test('List palettes', async () => {
try {
const result = await listPalettes();
expect(result).toHaveProperty('palettes');
expect(result).toHaveProperty('total');
expect(Array.isArray(result.palettes)).toBe(true);
} catch (error) {
// Tables might not exist yet, that's ok for initial test
expect(error).toBeDefined();
}
});
test('Style details with invalid ID', async () => {
try {
await getStyleDetails('INVALID_ID');
} catch (error) {
expect(error).toBeDefined();
}
});
test('Palette details with invalid ID', async () => {
try {
await getPaletteDetails('INVALID_ID');
} catch (error) {
expect(error).toBeDefined();
}
});
test('Recommend design', async () => {
try {
const result = await recommendDesign('restaurant');
expect(result).toHaveProperty('recommendations');
expect(result).toHaveProperty('total');
expect(Array.isArray(result.recommendations)).toBe(true);
} catch (error) {
// Tables might not exist yet, that's ok for initial test
expect(error).toBeDefined();
}
});
test('Recommend design with empty business type', async () => {
try {
await recommendDesign('');
} catch (error) {
expect(error).toBeDefined();
expect(error.message).toContain('Business type is required');
}
});
});