88 lines
4.3 KiB
TypeScript
88 lines
4.3 KiB
TypeScript
import { generateWebsiteBlueprint, processConversationalInstruction, INDUSTRY_PRESETS } from '../src/services/aiEngine';
|
|
import { BusinessProfile } from '../src/types';
|
|
|
|
console.log('--- TEST 1: GENERATE BLUEPRINT SECTION 0 ---');
|
|
const poolPreset = INDUSTRY_PRESETS['pool-service'];
|
|
const profile: BusinessProfile = {
|
|
companyName: 'Crystal Clear Pools',
|
|
phone: '(661) 555-1234',
|
|
email: 'test@aipilots.site',
|
|
address: '123 Main St',
|
|
city: 'Valencia',
|
|
state: 'CA',
|
|
zip: '91355',
|
|
industry: 'Pool Service',
|
|
tagline: 'Crystal Clear Always',
|
|
yearsInBusiness: '10',
|
|
services: ['Pool Cleaning', 'Pump Repair'],
|
|
emergencyService: true,
|
|
theme: 'titan-navy',
|
|
};
|
|
|
|
const sections = generateWebsiteBlueprint(profile);
|
|
console.log('Total sections generated:', sections.length);
|
|
const sec0 = sections.find(s => s.sectionNumber === 0);
|
|
console.log('Section 0 found:', !!sec0);
|
|
console.log('Section 0 title:', sec0?.title);
|
|
console.log('Section 0 variant:', sec0?.content.headerVariant);
|
|
console.log('Section 0 announcement:', sec0?.content.topBarAnnouncement);
|
|
console.log('Section 0 CTA:', sec0?.content.headerCtaText);
|
|
|
|
if (!sec0 || sec0.sectionNumber !== 0 || sec0.type !== 'header') {
|
|
throw new Error('Section 0 failed blueprint check');
|
|
}
|
|
|
|
console.log('\n--- TEST 2: AI INSTRUCTION -> 5-STAR CLEAN HEADER ---');
|
|
const resModern = processConversationalInstruction('make the header modern clean with 5-star rating', sections, profile);
|
|
const modSec0 = resModern.updatedSections.find(s => s.sectionNumber === 0);
|
|
console.log('AI Response:', resModern.aiResponse);
|
|
console.log('Updated Variant:', modSec0?.content.headerVariant);
|
|
console.log('Updated Announcement:', modSec0?.content.topBarAnnouncement);
|
|
console.log('Updated CTA:', modSec0?.content.headerCtaText);
|
|
|
|
if (modSec0?.content.headerVariant !== 'modern-clean') {
|
|
throw new Error('Modern clean header update failed');
|
|
}
|
|
|
|
console.log('\n--- TEST 3: AI INSTRUCTION -> EMERGENCY DISPATCH HEADER ---');
|
|
const resEmerg = processConversationalInstruction('make the header emergency dispatch with 24/7 response', resModern.updatedSections, profile);
|
|
const emergSec0 = resEmerg.updatedSections.find(s => s.sectionNumber === 0);
|
|
console.log('AI Response:', resEmerg.aiResponse);
|
|
console.log('Updated Variant:', emergSec0?.content.headerVariant);
|
|
|
|
if (emergSec0?.content.headerVariant !== 'emergency-trade') {
|
|
throw new Error('Emergency header update failed');
|
|
}
|
|
|
|
console.log('\n--- TEST 4: CUSTOM LICENSE AND TOP BAR TOGGLE ---');
|
|
const resLic = processConversationalInstruction('set header license to lic #C-53-998811', emergSec0 ? [emergSec0, ...sections.slice(1)] : sections, profile);
|
|
const licSec0 = resLic.updatedSections.find(s => s.sectionNumber === 0);
|
|
console.log('License badge:', licSec0?.content.licenseBadge);
|
|
|
|
console.log('\n--- TEST 5: USER EXACT PROMPT "ok i need a green and black landscaping app" ---');
|
|
const resLandscaping = processConversationalInstruction('ok i need a green and black landscaping app', sections, profile);
|
|
console.log('AI Response:', resLandscaping.aiResponse);
|
|
console.log('Updated Industry:', resLandscaping.updatedProfile?.industry);
|
|
console.log('Updated Company:', resLandscaping.updatedProfile?.companyName);
|
|
console.log('Updated Theme:', resLandscaping.updatedTheme);
|
|
const heroSec = resLandscaping.updatedSections.find(s => s.sectionNumber === 1);
|
|
console.log('Hero Headline:', heroSec?.content.headline);
|
|
|
|
if (!resLandscaping.updatedProfile?.industry?.includes('Landscaping')) {
|
|
throw new Error('Expected industry to contain Landscaping');
|
|
}
|
|
if (!heroSec?.content.headline?.toLowerCase().includes('landscape') && !heroSec?.content.headline?.toLowerCase().includes('outdoor')) {
|
|
throw new Error('Expected hero headline to be about landscaping');
|
|
}
|
|
|
|
console.log('\n--- TEST 6: USER FOLLOWUP PROMPT "it didnt change the wording to landscapping" ---');
|
|
const resTypo = processConversationalInstruction('it didnt change the wording to landscapping', sections, profile);
|
|
console.log('AI Response:', resTypo.aiResponse);
|
|
console.log('Updated Industry:', resTypo.updatedProfile?.industry);
|
|
console.log('Updated Company:', resTypo.updatedProfile?.companyName);
|
|
if (!resTypo.updatedProfile?.industry?.includes('Landscaping')) {
|
|
throw new Error('Expected typo landscapping to trigger landscaping overhaul');
|
|
}
|
|
|
|
console.log('\nALL 6 TESTS PASSED PERFECTLY!');
|