Download scripts/e2e-test.ts from WBES/WestBocaExecutiveSuites: direct link, hf CLI and curl.
- Browser
- Download file 2.85 kB
-
https://huggingface.co/WBES/WestBocaExecutiveSuites/resolve/main/scripts/e2e-test.ts
- Command line
-
hf download hf://WBES/WestBocaExecutiveSuites/scripts/e2e-test.ts
-
curl -L -o e2e-test.ts https://huggingface.co/WBES/WestBocaExecutiveSuites/resolve/main/scripts/e2e-test.ts
2.85 kB
| import fetch from 'node-fetch'; | |
| import * as dotenv from 'dotenv'; | |
| dotenv.config(); | |
| const API_URL = process.env.API_URL || 'http://localhost:3000'; | |
| interface User { | |
| id: string; | |
| email: string; | |
| name: string; | |
| } | |
| interface Conversation { | |
| id: string; | |
| userId: string; | |
| } | |
| async function e2eTest() { | |
| console.log('🧪 Starting end-to-end tests...'); | |
| try { | |
| // Health check | |
| const healthResponse = await fetch(`${API_URL}/api/health`); | |
| if (!healthResponse.ok) { | |
| throw new Error('Health check failed'); | |
| } | |
| console.log('✅ Health check passed'); | |
| // Test user creation | |
| const userResponse = await fetch(`${API_URL}/api/users`, { | |
| method: 'POST', | |
| headers: { 'Content-Type': 'application/json' }, | |
| body: JSON.stringify({ | |
| email: 'test@example.com', | |
| name: 'Test User' | |
| }) | |
| }); | |
| if (!userResponse.ok) { | |
| throw new Error('User creation failed'); | |
| } | |
| const user = await userResponse.json() as User; | |
| console.log('✅ User creation passed'); | |
| // Test conversation creation | |
| const conversationResponse = await fetch(`${API_URL}/api/conversations`, { | |
| method: 'POST', | |
| headers: { 'Content-Type': 'application/json' }, | |
| body: JSON.stringify({ | |
| userId: user.id | |
| }) | |
| }); | |
| if (!conversationResponse.ok) { | |
| throw new Error('Conversation creation failed'); | |
| } | |
| const conversation = await conversationResponse.json() as Conversation; | |
| console.log('✅ Conversation creation passed'); | |
| // Test message creation | |
| const messageResponse = await fetch(`${API_URL}/api/messages`, { | |
| method: 'POST', | |
| headers: { 'Content-Type': 'application/json' }, | |
| body: JSON.stringify({ | |
| conversationId: conversation.id, | |
| sender: 'user', | |
| content: 'Hello, world!' | |
| }) | |
| }); | |
| if (!messageResponse.ok) { | |
| throw new Error('Message creation failed'); | |
| } | |
| console.log('✅ Message creation passed'); | |
| // Test RAG query | |
| const ragResponse = await fetch(`${API_URL}/api/rag/query`, { | |
| method: 'POST', | |
| headers: { 'Content-Type': 'application/json' }, | |
| body: JSON.stringify({ | |
| query: 'What are your office hours?' | |
| }) | |
| }); | |
| if (!ragResponse.ok) { | |
| throw new Error('RAG query failed'); | |
| } | |
| console.log('✅ RAG query passed'); | |
| console.log('✅ All end-to-end tests passed!'); | |
| } catch (error) { | |
| console.error('❌ End-to-end test failed:', error); | |
| process.exit(1); | |
| } | |
| } | |
| e2eTest(); |