#!/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);