#!/usr/bin/env node
/**
* Simple functionality test for MCP Tailwind Gemini
* Tests core features without external dependencies
*/
import { readFileSync, existsSync } from 'fs';
import { join } from 'path';
class FunctionalityTester {
constructor() {
this.projectRoot = process.cwd();
}
/**
* Test if all core files exist
*/
testCoreFiles() {
console.log('π Testing core files...');
const coreFiles = [
'src/index.ts',
'src/utils/gemini-helper.ts',
'src/adapters/framework-adapter.ts',
'src/integrations/build-tools.ts',
'src/integrations/external-apis.ts',
'src/platforms/multi-platform.ts',
'package.json',
'tsconfig.json'
];
let allExist = true;
for (const file of coreFiles) {
const fullPath = join(this.projectRoot, file);
if (existsSync(fullPath)) {
console.log(` β
${file}`);
} else {
console.log(` β ${file} - Missing`);
allExist = false;
}
}
return allExist;
}
/**
* Test package.json configuration
*/
testPackageConfig() {
console.log('\nπ¦ Testing package configuration...');
try {
const packagePath = join(this.projectRoot, 'package.json');
const packageContent = JSON.parse(readFileSync(packagePath, 'utf-8'));
// Check required scripts
const requiredScripts = ['build', 'start', 'dev'];
const hasAllScripts = requiredScripts.every(script =>
packageContent.scripts && packageContent.scripts[script]
);
if (hasAllScripts) {
console.log(' β
All required scripts present');
} else {
console.log(' β Missing required scripts');
return false;
}
// Check dependencies
const requiredDeps = ['@google/generative-ai', '@modelcontextprotocol/sdk'];
const hasAllDeps = requiredDeps.every(dep =>
(packageContent.dependencies && packageContent.dependencies[dep]) ||
(packageContent.devDependencies && packageContent.devDependencies[dep])
);
if (hasAllDeps) {
console.log(' β
All required dependencies present');
} else {
console.log(' β Missing required dependencies');
return false;
}
return true;
} catch (error) {
console.log(` β Package.json error: ${error.message}`);
return false;
}
}
/**
* Test TypeScript configuration
*/
testTypeScriptConfig() {
console.log('\nπ§ Testing TypeScript configuration...');
try {
const tsconfigPath = join(this.projectRoot, 'tsconfig.json');
const tsconfigContent = JSON.parse(readFileSync(tsconfigPath, 'utf-8'));
// Check compiler options
const requiredOptions = ['target', 'module', 'outDir', 'rootDir'];
const hasAllOptions = requiredOptions.every(option =>
tsconfigContent.compilerOptions && tsconfigContent.compilerOptions[option]
);
if (hasAllOptions) {
console.log(' β
All required compiler options present');
} else {
console.log(' β Missing required compiler options');
return false;
}
// Check if ES modules are configured
const isESModules = tsconfigContent.compilerOptions.module === 'ESNext' ||
tsconfigContent.compilerOptions.module === 'ES2022';
if (isESModules) {
console.log(' β
ES modules configured');
} else {
console.log(' β ES modules not configured');
return false;
}
return true;
} catch (error) {
console.log(` β TypeScript config error: ${error.message}`);
return false;
}
}
/**
* Test MCP configuration
*/
testMCPConfig() {
console.log('\nπ€ Testing MCP configuration...');
try {
const mcpConfigPath = join(this.projectRoot, 'mcp.json');
if (!existsSync(mcpConfigPath)) {
console.log(' β mcp.json not found');
return false;
}
const mcpConfig = JSON.parse(readFileSync(mcpConfigPath, 'utf-8'));
// Check required fields
const requiredFields = ['name', 'version', 'description'];
const hasAllFields = requiredFields.every(field => mcpConfig[field]);
if (hasAllFields) {
console.log(' β
All required MCP fields present');
} else {
console.log(' β Missing required MCP fields');
return false;
}
return true;
} catch (error) {
console.log(` β MCP config error: ${error.message}`);
return false;
}
}
/**
* Test framework adapter structure
*/
testFrameworkAdapters() {
console.log('\nποΈ Testing framework adapters...');
try {
const adapterPath = join(this.projectRoot, 'src/adapters/framework-adapter.ts');
const adapterContent = readFileSync(adapterPath, 'utf-8');
// Check for required adapters
const requiredAdapters = ['ReactAdapter', 'VueAdapter', 'SvelteAdapter', 'AngularAdapter'];
const hasAllAdapters = requiredAdapters.every(adapter =>
adapterContent.includes(adapter)
);
if (hasAllAdapters) {
console.log(' β
All framework adapters present');
} else {
console.log(' β Missing framework adapters');
return false;
}
// Check for AdapterFactory
if (adapterContent.includes('AdapterFactory')) {
console.log(' β
AdapterFactory present');
} else {
console.log(' β AdapterFactory missing');
return false;
}
return true;
} catch (error) {
console.log(` β Framework adapter error: ${error.message}`);
return false;
}
}
/**
* Test build tool integrations
*/
testBuildTools() {
console.log('\nπ¨ Testing build tool integrations...');
try {
const buildToolsPath = join(this.projectRoot, 'src/integrations/build-tools.ts');
const buildToolsContent = readFileSync(buildToolsPath, 'utf-8');
// Check for required build tools
const requiredTools = ['ViteIntegration', 'WebpackIntegration', 'NextJSIntegration'];
const hasAllTools = requiredTools.every(tool =>
buildToolsContent.includes(tool)
);
if (hasAllTools) {
console.log(' β
All build tool integrations present');
} else {
console.log(' β Missing build tool integrations');
return false;
}
return true;
} catch (error) {
console.log(` β Build tools error: ${error.message}`);
return false;
}
}
/**
* Test documentation
*/
testDocumentation() {
console.log('\nπ Testing documentation...');
const docFiles = [
'README.md',
'docs/CROSS_PLATFORM_GUIDE.md',
'docs/CROSS_PLATFORM_SUMMARY.md'
];
let allExist = true;
for (const file of docFiles) {
const fullPath = join(this.projectRoot, file);
if (existsSync(fullPath)) {
console.log(` β
${file}`);
} else {
console.log(` β ${file} - Missing`);
allExist = false;
}
}
return allExist;
}
/**
* Run all functionality tests
*/
runAllTests() {
console.log('π§ͺ Starting Functionality Tests for MCP Tailwind Gemini\n');
const tests = [
{ name: 'Core Files', test: () => this.testCoreFiles() },
{ name: 'Package Config', test: () => this.testPackageConfig() },
{ name: 'TypeScript Config', test: () => this.testTypeScriptConfig() },
{ name: 'MCP Config', test: () => this.testMCPConfig() },
{ name: 'Framework Adapters', test: () => this.testFrameworkAdapters() },
{ name: 'Build Tools', test: () => this.testBuildTools() },
{ name: 'Documentation', test: () => this.testDocumentation() }
];
let passed = 0;
let failed = 0;
for (const { name, test } of tests) {
if (test()) {
passed++;
} else {
failed++;
}
}
console.log('\nπ Functionality Test Summary:');
console.log(`Total Tests: ${tests.length}`);
console.log(`β
Passed: ${passed}`);
console.log(`β Failed: ${failed}`);
console.log(`Success Rate: ${((passed / tests.length) * 100).toFixed(1)}%`);
if (failed === 0) {
console.log('\nπ All functionality tests passed! Core features are working correctly.');
console.log('β¨ Cross-platform integration system is ready for use.');
} else {
console.log('\nβ οΈ Some functionality tests failed. Please check the issues above.');
console.log('π‘ Focus on fixing core functionality before running advanced tests.');
}
// Provide next steps
console.log('\nπ Next Steps:');
console.log('1. Fix any failing tests above');
console.log('2. Run `npm run build` to check TypeScript compilation');
console.log('3. Run `npm test` for unit tests');
console.log('4. Test MCP server with Claude Desktop');
console.log('5. Validate cross-platform features with real projects');
}
}
// Run tests if this file is executed directly
if (import.meta.url === `file://${process.argv[1]}`) {
const tester = new FunctionalityTester();
tester.runAllTests();
}
export { FunctionalityTester };