@@ -92,12 +92,9 @@ describe('Chat API Utils', () => {
9292 password : 'encrypted-password' ,
9393 }
9494
95- const mockRequest = {
96- method : 'POST' ,
97- cookies : {
98- get : vi . fn ( ) . mockReturnValue ( { value : 'valid-token' } ) ,
99- } ,
100- } as any
95+ const mockRequest = createMockRequest ( 'POST' , undefined , {
96+ cookie : 'chat_auth_chat-id=valid-token' ,
97+ } )
10198
10299 const result = await validateChatAuth ( 'request-id' , deployment , mockRequest )
103100 expect ( mockReadDeploymentAuthToken ) . toHaveBeenCalledWith ( {
@@ -116,12 +113,9 @@ describe('Chat API Utils', () => {
116113 password : 'encrypted-password' ,
117114 }
118115
119- const mockRequest = {
120- method : 'GET' ,
121- cookies : {
122- get : vi . fn ( ) . mockReturnValue ( { value : 'invalid-token' } ) ,
123- } ,
124- } as any
116+ const mockRequest = createMockRequest ( 'GET' , undefined , {
117+ cookie : 'chat_auth_chat-id=invalid-token' ,
118+ } )
125119
126120 const result = await validateChatAuth ( 'request-id' , deployment , mockRequest )
127121 expect ( result . authorized ) . toBe ( false )
@@ -136,12 +130,9 @@ describe('Chat API Utils', () => {
136130 id : 'chat-id' ,
137131 authType : 'email' ,
138132 }
139- const mockRequest = {
140- method : 'POST' ,
141- cookies : {
142- get : vi . fn ( ) . mockReturnValue ( { value : 'valid-token' } ) ,
143- } ,
144- } as any
133+ const mockRequest = createMockRequest ( 'POST' , undefined , {
134+ cookie : 'chat_auth_chat-id=valid-token' ,
135+ } )
145136
146137 await expect ( validateChatAuth ( 'request-id' , deployment , mockRequest ) ) . resolves . toEqual ( {
147138 authorized : true ,
0 commit comments