11/**
2- * Tests for chat subdomain API route
2+ * Tests for chat identifier API route
33 *
44 * @vitest -environment node
55 */
66import { afterEach , beforeEach , describe , expect , it , vi } from 'vitest'
77import { createMockRequest } from '@/app/api/__test-utils__/utils'
88
9- describe ( 'Chat Subdomain API Route' , ( ) => {
9+ describe ( 'Chat Identifier API Route' , ( ) => {
1010 const createMockStream = ( ) => {
1111 return new ReadableStream ( {
1212 start ( controller ) {
@@ -134,11 +134,11 @@ describe('Chat Subdomain API Route', () => {
134134 } )
135135
136136 describe ( 'GET endpoint' , ( ) => {
137- it ( 'should return chat info for a valid subdomain ' , async ( ) => {
137+ it ( 'should return chat info for a valid identifier ' , async ( ) => {
138138 const req = createMockRequest ( 'GET' )
139- const params = Promise . resolve ( { subdomain : 'test-chat' } )
139+ const params = Promise . resolve ( { identifier : 'test-chat' } )
140140
141- const { GET } = await import ( '@/app/api/chat/[subdomain ]/route' )
141+ const { GET } = await import ( '@/app/api/chat/[identifier ]/route' )
142142
143143 const response = await GET ( req , { params } )
144144
@@ -152,7 +152,7 @@ describe('Chat Subdomain API Route', () => {
152152 expect ( data . customizations ) . toHaveProperty ( 'welcomeMessage' , 'Welcome to the test chat' )
153153 } )
154154
155- it ( 'should return 404 for non-existent subdomain ' , async ( ) => {
155+ it ( 'should return 404 for non-existent identifier ' , async ( ) => {
156156 vi . doMock ( '@sim/db' , ( ) => {
157157 const mockLimit = vi . fn ( ) . mockReturnValue ( [ ] )
158158 const mockWhere = vi . fn ( ) . mockReturnValue ( { limit : mockLimit } )
@@ -167,9 +167,9 @@ describe('Chat Subdomain API Route', () => {
167167 } )
168168
169169 const req = createMockRequest ( 'GET' )
170- const params = Promise . resolve ( { subdomain : 'nonexistent' } )
170+ const params = Promise . resolve ( { identifier : 'nonexistent' } )
171171
172- const { GET } = await import ( '@/app/api/chat/[subdomain ]/route' )
172+ const { GET } = await import ( '@/app/api/chat/[identifier ]/route' )
173173
174174 const response = await GET ( req , { params } )
175175
@@ -201,9 +201,9 @@ describe('Chat Subdomain API Route', () => {
201201 } )
202202
203203 const req = createMockRequest ( 'GET' )
204- const params = Promise . resolve ( { subdomain : 'inactive-chat' } )
204+ const params = Promise . resolve ( { identifier : 'inactive-chat' } )
205205
206- const { GET } = await import ( '@/app/api/chat/[subdomain ]/route' )
206+ const { GET } = await import ( '@/app/api/chat/[identifier ]/route' )
207207
208208 const response = await GET ( req , { params } )
209209
@@ -222,9 +222,9 @@ describe('Chat Subdomain API Route', () => {
222222 } ) )
223223
224224 const req = createMockRequest ( 'GET' )
225- const params = Promise . resolve ( { subdomain : 'password-protected-chat' } )
225+ const params = Promise . resolve ( { identifier : 'password-protected-chat' } )
226226
227- const { GET } = await import ( '@/app/api/chat/[subdomain ]/route' )
227+ const { GET } = await import ( '@/app/api/chat/[identifier ]/route' )
228228
229229 const response = await GET ( req , { params } )
230230
@@ -243,9 +243,9 @@ describe('Chat Subdomain API Route', () => {
243243 describe ( 'POST endpoint' , ( ) => {
244244 it ( 'should handle authentication requests without input' , async ( ) => {
245245 const req = createMockRequest ( 'POST' , { password : 'test-password' } )
246- const params = Promise . resolve ( { subdomain : 'password-protected-chat' } )
246+ const params = Promise . resolve ( { identifier : 'password-protected-chat' } )
247247
248- const { POST } = await import ( '@/app/api/chat/[subdomain ]/route' )
248+ const { POST } = await import ( '@/app/api/chat/[identifier ]/route' )
249249
250250 const response = await POST ( req , { params } )
251251
@@ -259,9 +259,9 @@ describe('Chat Subdomain API Route', () => {
259259
260260 it ( 'should return 400 for requests without input' , async ( ) => {
261261 const req = createMockRequest ( 'POST' , { } )
262- const params = Promise . resolve ( { subdomain : 'test-chat' } )
262+ const params = Promise . resolve ( { identifier : 'test-chat' } )
263263
264- const { POST } = await import ( '@/app/api/chat/[subdomain ]/route' )
264+ const { POST } = await import ( '@/app/api/chat/[identifier ]/route' )
265265
266266 const response = await POST ( req , { params } )
267267
@@ -280,9 +280,9 @@ describe('Chat Subdomain API Route', () => {
280280 } ) )
281281
282282 const req = createMockRequest ( 'POST' , { input : 'Hello' } )
283- const params = Promise . resolve ( { subdomain : 'protected-chat' } )
283+ const params = Promise . resolve ( { identifier : 'protected-chat' } )
284284
285- const { POST } = await import ( '@/app/api/chat/[subdomain ]/route' )
285+ const { POST } = await import ( '@/app/api/chat/[identifier ]/route' )
286286
287287 const response = await POST ( req , { params } )
288288
@@ -343,9 +343,9 @@ describe('Chat Subdomain API Route', () => {
343343 } )
344344
345345 const req = createMockRequest ( 'POST' , { input : 'Hello' } )
346- const params = Promise . resolve ( { subdomain : 'test-chat' } )
346+ const params = Promise . resolve ( { identifier : 'test-chat' } )
347347
348- const { POST } = await import ( '@/app/api/chat/[subdomain ]/route' )
348+ const { POST } = await import ( '@/app/api/chat/[identifier ]/route' )
349349
350350 const response = await POST ( req , { params } )
351351
@@ -358,9 +358,9 @@ describe('Chat Subdomain API Route', () => {
358358
359359 it ( 'should return streaming response for valid chat messages' , async ( ) => {
360360 const req = createMockRequest ( 'POST' , { input : 'Hello world' , conversationId : 'conv-123' } )
361- const params = Promise . resolve ( { subdomain : 'test-chat' } )
361+ const params = Promise . resolve ( { identifier : 'test-chat' } )
362362
363- const { POST } = await import ( '@/app/api/chat/[subdomain ]/route' )
363+ const { POST } = await import ( '@/app/api/chat/[identifier ]/route' )
364364
365365 const response = await POST ( req , { params } )
366366
@@ -375,9 +375,9 @@ describe('Chat Subdomain API Route', () => {
375375
376376 it ( 'should handle streaming response body correctly' , async ( ) => {
377377 const req = createMockRequest ( 'POST' , { input : 'Hello world' } )
378- const params = Promise . resolve ( { subdomain : 'test-chat' } )
378+ const params = Promise . resolve ( { identifier : 'test-chat' } )
379379
380- const { POST } = await import ( '@/app/api/chat/[subdomain ]/route' )
380+ const { POST } = await import ( '@/app/api/chat/[identifier ]/route' )
381381
382382 const response = await POST ( req , { params } )
383383
@@ -405,9 +405,9 @@ describe('Chat Subdomain API Route', () => {
405405 } )
406406
407407 const req = createMockRequest ( 'POST' , { input : 'Trigger error' } )
408- const params = Promise . resolve ( { subdomain : 'test-chat' } )
408+ const params = Promise . resolve ( { identifier : 'test-chat' } )
409409
410- const { POST } = await import ( '@/app/api/chat/[subdomain ]/route' )
410+ const { POST } = await import ( '@/app/api/chat/[identifier ]/route' )
411411
412412 const response = await POST ( req , { params } )
413413
@@ -430,9 +430,9 @@ describe('Chat Subdomain API Route', () => {
430430 json : vi . fn ( ) . mockRejectedValue ( new Error ( 'Invalid JSON' ) ) ,
431431 } as any
432432
433- const params = Promise . resolve ( { subdomain : 'test-chat' } )
433+ const params = Promise . resolve ( { identifier : 'test-chat' } )
434434
435- const { POST } = await import ( '@/app/api/chat/[subdomain ]/route' )
435+ const { POST } = await import ( '@/app/api/chat/[identifier ]/route' )
436436
437437 const response = await POST ( req , { params } )
438438
@@ -448,9 +448,9 @@ describe('Chat Subdomain API Route', () => {
448448 input : 'Hello world' ,
449449 conversationId : 'test-conversation-123' ,
450450 } )
451- const params = Promise . resolve ( { subdomain : 'test-chat' } )
451+ const params = Promise . resolve ( { identifier : 'test-chat' } )
452452
453- const { POST } = await import ( '@/app/api/chat/[subdomain ]/route' )
453+ const { POST } = await import ( '@/app/api/chat/[identifier ]/route' )
454454
455455 await POST ( req , { params } )
456456
@@ -463,9 +463,9 @@ describe('Chat Subdomain API Route', () => {
463463
464464 it ( 'should handle missing conversationId gracefully' , async ( ) => {
465465 const req = createMockRequest ( 'POST' , { input : 'Hello world' } )
466- const params = Promise . resolve ( { subdomain : 'test-chat' } )
466+ const params = Promise . resolve ( { identifier : 'test-chat' } )
467467
468- const { POST } = await import ( '@/app/api/chat/[subdomain ]/route' )
468+ const { POST } = await import ( '@/app/api/chat/[identifier ]/route' )
469469
470470 await POST ( req , { params } )
471471
0 commit comments