From 040655912cea502749e9cb615831144e311726b8 Mon Sep 17 00:00:00 2001 From: root Date: Thu, 19 Feb 2026 12:24:38 +0000 Subject: [PATCH] fix: /demos/[vertical] route with Next.js 15 params await - Fix Next.js 15 params requirement (await params) - Add minimal test for route redirect behavior - Test verifies all 4 verticals redirect correctly --- app/demos/[vertical]/page.tsx | 8 ++++++ package.json | 9 ++++-- tests/demos-vertical.test.ts | 53 +++++++++++++++++++++++++++++++++++ 3 files changed, 68 insertions(+), 2 deletions(-) create mode 100644 app/demos/[vertical]/page.tsx create mode 100644 tests/demos-vertical.test.ts diff --git a/app/demos/[vertical]/page.tsx b/app/demos/[vertical]/page.tsx new file mode 100644 index 0000000..bf6c21a --- /dev/null +++ b/app/demos/[vertical]/page.tsx @@ -0,0 +1,8 @@ +import { redirect } from 'next/navigation'; + +// Next.js 15 requires params to be awaited +export default async function DemoVerticalPage({ params }: { params: Promise<{ vertical: string }> }) { + const { vertical } = await params; + // Redirect to the main demos page with the vertical as query param + redirect(`/demos?vertical=${vertical}`); +} diff --git a/package.json b/package.json index fa9bd02..f5ae1ef 100644 --- a/package.json +++ b/package.json @@ -6,20 +6,25 @@ "scripts": { "dev": "next dev -p 1284", "build": "next build", - "start": "next start" + "start": "next start", + "test": "node --experimental-strip-types tests/demos-vertical.test.ts" }, "dependencies": { "@google/genai": "^1.39.0", "@google/generative-ai": "^0.24.1", + "@stripe/stripe-js": "^8.7.0", + "@vapi-ai/web": "^2.5.2", "framer-motion": "^12.23.12", "next": "^15.5.3", "react": "^19.1.1", - "react-dom": "^19.1.1" + "react-dom": "^19.1.1", + "stripe": "^17.5.0" }, "devDependencies": { "@types/react": "^19.1.12", "@types/react-dom": "^19.1.9", "autoprefixer": "^10.4.21", + "dotenv": "^17.3.1", "postcss": "^8.5.6", "tailwindcss": "^3.4.17", "typescript": "^5.9.2" diff --git a/tests/demos-vertical.test.ts b/tests/demos-vertical.test.ts new file mode 100644 index 0000000..f36e381 --- /dev/null +++ b/tests/demos-vertical.test.ts @@ -0,0 +1,53 @@ +/** + * 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();