// Server initialization tests
import { describe, it, expect } from '@jest/globals';
import { CONFIGURATION_MODES, getServerConfig } from '../src/config/server-config';
import { getWordPressConfig, validateWordPressConfig } from '../src/config/wordpress-config';
import { LogLevel, logger } from '../src/utils/logger';
import { ErrorCategory, MCPError } from '../src/utils/error-handler';
describe('Ultimate Elementor MCP Server', () => {
it('should export configuration modes', () => {
expect(CONFIGURATION_MODES).toBeDefined();
expect(CONFIGURATION_MODES.essential).toBeDefined();
expect(CONFIGURATION_MODES.standard).toBeDefined();
expect(CONFIGURATION_MODES.advanced).toBeDefined();
expect(CONFIGURATION_MODES.full).toBeDefined();
});
it('should have proper configuration mode structure', () => {
const essentialMode = CONFIGURATION_MODES.essential;
expect(essentialMode.mode).toBe('essential');
expect(essentialMode.basicWordPressOperations).toBe(true);
expect(essentialMode.basicElementorOperations).toBe(true);
});
it('should get server config from environment', () => {
const config = getServerConfig();
expect(config).toBeDefined();
expect(config.mode).toBeDefined();
expect(['essential', 'standard', 'advanced', 'full']).toContain(config.mode);
});
it('should have logger with proper log levels', () => {
expect(LogLevel.DEBUG).toBe(0);
expect(LogLevel.INFO).toBe(1);
expect(LogLevel.WARN).toBe(2);
expect(LogLevel.ERROR).toBe(3);
});
it('should have logger instance', () => {
expect(logger).toBeDefined();
expect(logger.info).toBeDefined();
expect(logger.error).toBeDefined();
expect(logger.warn).toBeDefined();
expect(logger.debug).toBeDefined();
});
it('should have error categories defined', () => {
expect(ErrorCategory.AUTHENTICATION).toBeDefined();
expect(ErrorCategory.VALIDATION).toBeDefined();
expect(ErrorCategory.NETWORK).toBeDefined();
expect(ErrorCategory.WORDPRESS_API).toBeDefined();
expect(ErrorCategory.ELEMENTOR_DATA).toBeDefined();
expect(ErrorCategory.FILE_OPERATION).toBeDefined();
expect(ErrorCategory.CONFIGURATION).toBeDefined();
expect(ErrorCategory.INTERNAL).toBeDefined();
});
it('should create MCPError with proper structure', () => {
const error = new MCPError(
'Test error',
ErrorCategory.VALIDATION,
'TEST_ERROR',
{ detail: 'test' },
400
);
expect(error.message).toBe('Test error');
expect(error.category).toBe(ErrorCategory.VALIDATION);
expect(error.code).toBe('TEST_ERROR');
expect(error.details).toEqual({ detail: 'test' });
expect(error.statusCode).toBe(400);
});
it('should validate WordPress config correctly', () => {
const validConfig = {
baseUrl: 'https://example.com',
username: 'testuser',
applicationPassword: 'test-password'
};
expect(() => validateWordPressConfig(validConfig)).not.toThrow();
});
it('should throw error for invalid WordPress config', () => {
const invalidConfig = {
baseUrl: 'invalid-url',
username: 'testuser',
applicationPassword: 'test-password'
};
expect(() => validateWordPressConfig(invalidConfig)).toThrow();
});
});