Files

83 lines
3.1 KiB
TypeScript

import { processConversationalInstruction } from '../src/services/aiEngine';
import { BusinessProfile, WebsiteSection } from '../src/types';
const mockProfile: BusinessProfile = {
companyName: 'Apex Crystal Pool Solutions',
phone: '(661) 555-0149',
email: 'service@apexpools.com',
address: '24800 Avenue Tibbitts',
city: 'Valencia',
state: 'CA',
zip: '91355',
industry: 'Pool Service & Maintenance',
tagline: 'Pristine Pool Chemistry & Care',
yearsInBusiness: '12',
services: ['Weekly Chemical Balancing', 'Filter Repair'],
emergencyService: true,
theme: 'titan-navy',
};
const mockSections: WebsiteSection[] = [
{
id: 'sec-1',
sectionNumber: 1,
type: 'hero',
isVisible: true,
content: {
headline: 'Crystal Clear Waters & Flawless Pool Care You Can Trust',
subheadline: 'Certified CPO pool technicians delivering weekly maintenance.',
}
}
];
const testPrompts = [
{ prompt: 'theme black and yellow', expectedTheme: 'obsidian-gold' },
{ prompt: 'changing to black and yellow didnt work', expectedTheme: 'obsidian-gold' },
{ prompt: 'make it electric purple', expectedTheme: 'electric-violet' },
{ prompt: 'switch to lavender', expectedTheme: 'electric-violet' },
{ prompt: 'can we do an orange copper vibe', expectedTheme: 'sunset-amber' },
{ prompt: 'change to teal and cyan', expectedTheme: 'cyber-cyan' },
{ prompt: 'make it hot pink and black', expectedTheme: 'neon-rose' },
{ prompt: 'green and black theme', expectedTheme: 'emerald-slate' },
{ prompt: 'clean white theme', expectedTheme: 'alpine-clean' },
{ prompt: 'crimson red theme', expectedTheme: 'crimson-forge' },
{ prompt: 'change colors', expectedTheme: 'obsidian-gold' }, // default theme shift
{ prompt: 'why didnt it work', expectAiHelp: true },
];
console.log('--- RUNNING UNIVERSAL COLOR & THEME TESTS ---');
let allPassed = true;
for (const t of testPrompts) {
const result = processConversationalInstruction(t.prompt, mockSections, mockProfile);
if (t.expectedTheme) {
if (result.updatedTheme === t.expectedTheme) {
console.log(`✅ PASS: "${t.prompt}" -> ${result.updatedTheme}`);
} else {
console.error(`❌ FAIL: "${t.prompt}" -> got ${result.updatedTheme}, expected ${t.expectedTheme}`);
allPassed = false;
}
} else if (t.expectAiHelp) {
if (result.aiResponse.includes('AI Assistant Co-Pilot Support')) {
console.log(`✅ PASS: "${t.prompt}" -> Handled by Support Guard`);
} else {
console.error(`❌ FAIL: "${t.prompt}" -> fell through to copy editor!`);
allPassed = false;
}
}
// Verify that the prompt was NOT injected into hero headline/subheadline
if (result.updatedSections[0]?.content?.subheadline?.toLowerCase().includes('didnt work') ||
result.updatedSections[0]?.content?.headline?.toLowerCase().includes('didnt work')) {
console.error(`❌ CORRUPTION DETECTED: prompt text leaked into hero content for "${t.prompt}"`);
allPassed = false;
}
}
if (allPassed) {
console.log('\n🎉 ALL 12 TESTS PASSED PERFECTLY! ZERO COPY CORRUPTIONS!');
} else {
process.exit(1);
}