/** * Simple test for /demos/[vertical] route * Tests that the dynamic route properly handles vertical params and redirects */ const VERTICALS = ['restaurant', 'real-estate', 'clinic', 'car-rental']; const BASE_URL = process.env.TEST_BASE_URL || 'http://localhost:1284'; async function testRoute(vertical) { const response = await fetch(`${BASE_URL}/demos/${vertical}`, { redirect: 'manual' // Don't follow redirect, just get the location }); // Should return a 307 redirect (temporary redirect in Next.js) if (response.status !== 307 && response.status !== 302) { throw new Error(`Expected 307/302 for /demos/${vertical}, got ${response.status}`); } // Should redirect to /demos?vertical= const location = response.headers.get('location'); if (!location || !location.includes(`/demos?vertical=${vertical}`)) { throw new Error(`Expected redirect to /demos?vertical=${vertical}, got ${location}`); } console.log(`✓ /demos/${vertical} redirects to ${location}`); return true; } async function runTests() { console.log('Testing /demos/[vertical] route...\n'); let passed = 0; let failed = 0; for (const vertical of VERTICALS) { try { await testRoute(vertical); passed++; } catch (error) { console.error(`✗ /demos/${vertical} failed: ${error.message}`); failed++; } } console.log(`\nResults: ${passed} passed, ${failed} failed`); if (failed > 0) { process.exit(1); } } runTests();