@@ -2,7 +2,8 @@ import { MockAgent } from 'undici';
22import { ApiClient } from '../lib/api-client' ;
33import { MONDAY_API_ENDPOINT } from '../lib/constants' ;
44
5- const MONDAY_API_ORIGIN = MONDAY_API_ENDPOINT . replace ( '/v2' , '' ) ;
5+ const MONDAY_API_SUFFIX = '/v2' ;
6+ const MONDAY_API_ORIGIN = MONDAY_API_ENDPOINT . replace ( MONDAY_API_SUFFIX , '' ) ;
67
78describe ( 'ApiClient timeout integration' , ( ) => {
89 let mockAgent : MockAgent ;
@@ -33,7 +34,7 @@ describe('ApiClient timeout integration', () => {
3334 it ( 'should abort request when timeout is exceeded' , async ( ) => {
3435 const mockPool = mockAgent . get ( MONDAY_API_ORIGIN ) ;
3536 mockPool
36- . intercept ( { path : '/v2' , method : 'POST' } )
37+ . intercept ( { path : MONDAY_API_SUFFIX , method : 'POST' } )
3738 . reply ( 200 , { data : { users : [ ] } } , { headers : jsonHeaders } )
3839 . delay ( 2000 ) ;
3940
@@ -46,7 +47,7 @@ describe('ApiClient timeout integration', () => {
4647 it ( 'should complete successfully when response arrives before timeout' , async ( ) => {
4748 const mockPool = mockAgent . get ( MONDAY_API_ORIGIN ) ;
4849 mockPool
49- . intercept ( { path : '/v2' , method : 'POST' } )
50+ . intercept ( { path : MONDAY_API_SUFFIX , method : 'POST' } )
5051 . reply ( 200 , { data : { users : [ { id : '1' } ] } } , { headers : jsonHeaders } ) ;
5152
5253 const apiClient = createMockedApiClient ( ) ;
@@ -59,7 +60,7 @@ describe('ApiClient timeout integration', () => {
5960 it ( 'should work without timeout option' , async ( ) => {
6061 const mockPool = mockAgent . get ( MONDAY_API_ORIGIN ) ;
6162 mockPool
62- . intercept ( { path : '/v2' , method : 'POST' } )
63+ . intercept ( { path : MONDAY_API_SUFFIX , method : 'POST' } )
6364 . reply ( 200 , { data : { users : [ { id : '1' , name : 'John' } ] } } , { headers : jsonHeaders } ) ;
6465
6566 const apiClient = createMockedApiClient ( ) ;
@@ -74,7 +75,7 @@ describe('ApiClient timeout integration', () => {
7475 it ( 'should abort rawRequest when timeout is exceeded' , async ( ) => {
7576 const mockPool = mockAgent . get ( MONDAY_API_ORIGIN ) ;
7677 mockPool
77- . intercept ( { path : '/v2' , method : 'POST' } )
78+ . intercept ( { path : MONDAY_API_SUFFIX , method : 'POST' } )
7879 . reply ( 200 , { data : { users : [ ] } } , { headers : jsonHeaders } )
7980 . delay ( 2000 ) ;
8081
@@ -87,7 +88,7 @@ describe('ApiClient timeout integration', () => {
8788 it ( 'should complete rawRequest successfully when response arrives before timeout' , async ( ) => {
8889 const mockPool = mockAgent . get ( MONDAY_API_ORIGIN ) ;
8990 mockPool
90- . intercept ( { path : '/v2' , method : 'POST' } )
91+ . intercept ( { path : MONDAY_API_SUFFIX , method : 'POST' } )
9192 . reply ( 200 , { data : { users : [ { id : '1' } ] } } , { headers : jsonHeaders } ) ;
9293
9394 const apiClient = createMockedApiClient ( ) ;
@@ -136,7 +137,7 @@ describe('ApiClient file upload integration', () => {
136137 it ( 'should convert request with single file to multipart/form-data' , async ( ) => {
137138 const mockPool = mockAgent . get ( MONDAY_API_ORIGIN ) ;
138139 mockPool
139- . intercept ( { path : '/v2' , method : 'POST' } )
140+ . intercept ( { path : MONDAY_API_SUFFIX , method : 'POST' } )
140141 . reply ( 200 , { data : { add_file_to_column : { id : '123' } } } , { headers : jsonHeaders } ) ;
141142
142143 const apiClient = createMockedApiClient ( ) ;
@@ -166,7 +167,7 @@ describe('ApiClient file upload integration', () => {
166167 it ( 'should convert request with multiple files in array to multipart/form-data' , async ( ) => {
167168 const mockPool = mockAgent . get ( MONDAY_API_ORIGIN ) ;
168169 mockPool
169- . intercept ( { path : '/v2' , method : 'POST' } )
170+ . intercept ( { path : MONDAY_API_SUFFIX , method : 'POST' } )
170171 . reply ( 200 , { data : { upload_files : { success : true } } } , { headers : jsonHeaders } ) ;
171172
172173 const apiClient = createMockedApiClient ( ) ;
@@ -197,7 +198,7 @@ describe('ApiClient file upload integration', () => {
197198 it ( 'should handle nested files in objects' , async ( ) => {
198199 const mockPool = mockAgent . get ( MONDAY_API_ORIGIN ) ;
199200 mockPool
200- . intercept ( { path : '/v2' , method : 'POST' } )
201+ . intercept ( { path : MONDAY_API_SUFFIX , method : 'POST' } )
201202 . reply ( 200 , { data : { upload : { id : '456' } } } , { headers : jsonHeaders } ) ;
202203
203204 const apiClient = createMockedApiClient ( ) ;
@@ -237,7 +238,7 @@ describe('ApiClient file upload integration', () => {
237238 it ( 'should remove Content-Type header for multipart requests' , async ( ) => {
238239 const mockPool = mockAgent . get ( MONDAY_API_ORIGIN ) ;
239240 mockPool
240- . intercept ( { path : '/v2' , method : 'POST' } )
241+ . intercept ( { path : MONDAY_API_SUFFIX , method : 'POST' } )
241242 . reply ( 200 , { data : { upload : { id : '789' } } } , { headers : jsonHeaders } ) ;
242243
243244 const apiClient = createMockedApiClient ( ) ;
@@ -255,7 +256,7 @@ describe('ApiClient file upload integration', () => {
255256 it ( 'should keep request as JSON when no files are present' , async ( ) => {
256257 const mockPool = mockAgent . get ( MONDAY_API_ORIGIN ) ;
257258 mockPool
258- . intercept ( { path : '/v2' , method : 'POST' } )
259+ . intercept ( { path : MONDAY_API_SUFFIX , method : 'POST' } )
259260 . reply ( 200 , { data : { users : [ { id : '1' } ] } } , { headers : jsonHeaders } ) ;
260261
261262 const apiClient = createMockedApiClient ( ) ;
@@ -272,7 +273,7 @@ describe('ApiClient file upload integration', () => {
272273 it ( 'should work with rawRequest method for file uploads' , async ( ) => {
273274 const mockPool = mockAgent . get ( MONDAY_API_ORIGIN ) ;
274275 mockPool
275- . intercept ( { path : '/v2' , method : 'POST' } )
276+ . intercept ( { path : MONDAY_API_SUFFIX , method : 'POST' } )
276277 . reply ( 200 , { data : { add_file_to_column : { id : '999' } } } , { headers : jsonHeaders } ) ;
277278
278279 const apiClient = createMockedApiClient ( ) ;
@@ -288,7 +289,7 @@ describe('ApiClient file upload integration', () => {
288289 it ( 'should handle mixed files and regular variables' , async ( ) => {
289290 const mockPool = mockAgent . get ( MONDAY_API_ORIGIN ) ;
290291 mockPool
291- . intercept ( { path : '/v2' , method : 'POST' } )
292+ . intercept ( { path : MONDAY_API_SUFFIX , method : 'POST' } )
292293 . reply ( 200 , { data : { create_item : { id : '111' } } } , { headers : jsonHeaders } ) ;
293294
294295 const apiClient = createMockedApiClient ( ) ;
0 commit comments