#!/usr/bin/env tsx /** * Final verification test for embed components */ import { readFileSync, existsSync } from 'fs'; import { join } from 'path'; console.log('šŸ” Final Embed Component Verification\n'); const tests = [ { name: 'Components Exist', test: () => { const files = ['YouTubeEmbed.astro', 'TwitterEmbed.astro', 'GenericEmbed.astro']; const allExist = files.every(file => existsSync(join(process.cwd(), 'src', 'components', file))); return allExist ? 'āœ… All components created' : 'āŒ Missing components'; } }, { name: 'Demo Post Exists', test: () => { const exists = existsSync(join(process.cwd(), 'src', 'pages', 'blog', 'embed-demo.astro')); return exists ? 'āœ… Demo post created' : 'āŒ Demo post missing'; } }, { name: 'Blog Posts Updated', test: () => { const content = readFileSync(join(process.cwd(), 'src', 'data', 'blogPosts.ts'), 'utf-8'); return content.includes('embed-demo') ? 'āœ… embed-demo added to blogPosts' : 'āŒ embed-demo not in blogPosts'; } }, { name: 'YouTube Component Valid', test: () => { const content = readFileSync(join(process.cwd(), 'src', 'components', 'YouTubeEmbed.astro'), 'utf-8'); const hasIssues = content.includes('IntersectionObserver') || content.includes('timeout:'); return !hasIssues ? 'āœ… YouTube component clean' : 'āš ļø YouTube has potential issues'; } }, { name: 'Twitter Component Valid', test: () => { const content = readFileSync(join(process.cwd(), 'src', 'components', 'TwitterEmbed.astro'), 'utf-8'); const hasFallback = content.includes('fallbackHtml'); const hasErrorHandling = content.includes('try') && content.includes('catch'); return hasFallback && hasErrorHandling ? 'āœ… Twitter component robust' : 'āŒ Twitter needs fixes'; } }, { name: 'Generic Component Valid', test: () => { const content = readFileSync(join(process.cwd(), 'src', 'components', 'GenericEmbed.astro'), 'utf-8'); const hasEndpoints = content.includes('oEmbedEndpoints'); const hasFallback = content.includes('fallbackHtml'); return hasEndpoints && hasFallback ? 'āœ… Generic component robust' : 'āŒ Generic needs fixes'; } } ]; let allPassed = true; tests.forEach(test => { const result = test.test(); console.log(result); if (result.includes('āŒ')) allPassed = false; }); console.log('\n' + '='.repeat(70)); if (allPassed) { console.log('šŸŽ‰ SUCCESS! All components are ready to use.'); console.log('\nšŸ“‹ WHAT WAS CREATED:'); console.log('• YouTubeEmbed.astro - YouTube videos with full styling control'); console.log('• TwitterEmbed.astro - Twitter/X tweets with oEmbed API'); console.log('• GenericEmbed.astro - Universal oEmbed support'); console.log('• embed-demo.astro - Working example post'); console.log('• Updated blogPosts.ts - Added demo to blog list'); console.log('\nšŸš€ HOW TO TEST:'); console.log('1. Start dev server: npm run dev'); console.log('2. Visit: http://localhost:4321/blog/embed-demo'); console.log('3. Or visit: http://localhost:4321/ and click "Rich Content Embedding Demo"'); console.log('\nšŸ’” USAGE EXAMPLES:'); console.log('YouTube: '); console.log('Twitter: '); console.log('Generic: '); console.log('\nšŸŽØ STYLING CONTROL:'); console.log('Use CSS variables or data attributes for full customization'); console.log('All components match your blog\'s Tailwind aesthetic'); } else { console.log('āŒ Some issues detected. Check the results above.'); } process.exit(allPassed ? 0 : 1);