#!/usr/bin/env node /** * SEO Best Practices Test * Verifies schema markup and meta tags are properly generated */ const fs = require('fs'); const path = require('path'); console.log('šŸ” Testing SEO Implementation...\n'); const results = { passed: 0, failed: 0, warnings: 0, tests: [] }; function test(name, condition, critical = true) { const status = condition ? 'āœ… PASS' : critical ? 'āŒ FAIL' : 'āš ļø WARN'; results.tests.push({ name, status, critical }); if (condition) { results.passed++; } else if (critical) { results.failed++; } else { results.warnings++; } console.log(`${status}: ${name}`); } // Test 1: Check if SEO modules exist console.log('šŸ“¦ Module Structure Tests:'); test('Keywords module exists', fs.existsSync('src/lib/seo/keywords/index.ts')); test('Schema module exists', fs.existsSync('src/lib/seo/schema/index.ts')); test('SEO components exist', fs.existsSync('src/components/seo/index.ts')); // Test 2: Check if all locale configs exist console.log('\nšŸŒ Locale Configuration Tests:'); const locales = ['sr', 'en', 'de', 'fr']; locales.forEach(locale => { test(`Keywords config for ${locale}`, fs.existsSync(`src/lib/seo/keywords/locales/${locale}.ts`)); }); // Test 3: Check schema generators console.log('\nšŸ—ļø Schema Generator Tests:'); test('Product schema generator exists', fs.existsSync('src/lib/seo/schema/productSchema.ts')); test('Organization schema generator exists', fs.existsSync('src/lib/seo/schema/organizationSchema.ts')); test('Breadcrumb schema generator exists', fs.existsSync('src/lib/seo/schema/breadcrumbSchema.ts')); // Test 4: Check React components console.log('\nāš›ļø React Component Tests:'); test('JsonLd component exists', fs.existsSync('src/components/seo/JsonLd.tsx')); test('ProductSchema component exists', fs.existsSync('src/components/seo/ProductSchema.tsx')); test('OrganizationSchema component exists', fs.existsSync('src/components/seo/OrganizationSchema.tsx')); // Test 5: Check page integrations console.log('\nšŸ“„ Page Integration Tests:'); test('Root layout updated with OrganizationSchema', fs.readFileSync('src/app/layout.tsx', 'utf8').includes('OrganizationSchema')); test('Product page has ProductSchema', fs.readFileSync('src/app/[locale]/products/[slug]/page.tsx', 'utf8').includes('ProductSchema')); test('Product page has enhanced metadata', fs.readFileSync('src/app/[locale]/products/[slug]/page.tsx', 'utf8').includes('openGraph')); test('Checkout has noindex layout', fs.existsSync('src/app/[locale]/checkout/layout.tsx')); // Test 6: Check TypeScript types console.log('\nšŸ“ TypeScript Type Tests:'); test('SEO types defined', fs.existsSync('src/lib/seo/keywords/types.ts')); test('Schema types defined', fs.existsSync('src/lib/seo/schema/types.ts')); // Summary console.log('\n' + '='.repeat(50)); console.log(`āœ… Passed: ${results.passed}`); console.log(`āŒ Failed: ${results.failed}`); console.log(`āš ļø Warnings: ${results.warnings}`); console.log('='.repeat(50)); if (results.failed === 0) { console.log('\nšŸŽ‰ All critical SEO tests passed!'); process.exit(0); } else { console.log(`\nāš ļø ${results.failed} critical test(s) failed.`); process.exit(1); }