@@ -179,6 +179,32 @@ describe('OdpSegmentApiManager', () => {
179
179
} ) ;
180
180
181
181
it ( 'should handle error with invalid identifier' , async ( ) => {
182
+ const INVALID_USER_ID = 'invalid-user' ;
183
+ const errorJsonResponse =
184
+ '{"errors":[{"message":' +
185
+ '"Exception while fetching data (/customer) : ' +
186
+ `Exception: could not resolve _fs_user_id = ${ INVALID_USER_ID } ",` +
187
+ '"locations":[{"line":1,"column":8}],"path":["customer"],' +
188
+ '"extensions":{"code": "INVALID_IDENTIFIER_EXCEPTION","classification":"DataFetchingException"}}],' +
189
+ '"data":{"customer":null}}' ;
190
+ when ( mockRequestHandler . makeRequest ( anything ( ) , anything ( ) , anything ( ) , anything ( ) ) ) . thenReturn (
191
+ abortableRequest ( 200 , errorJsonResponse )
192
+ ) ;
193
+ const manager = managerInstance ( ) ;
194
+
195
+ const segments = await manager . fetchSegments (
196
+ API_key ,
197
+ GRAPHQL_ENDPOINT ,
198
+ USER_KEY ,
199
+ INVALID_USER_ID ,
200
+ SEGMENTS_TO_CHECK
201
+ ) ;
202
+
203
+ expect ( segments ) . toBeNull ( ) ;
204
+ verify ( mockLogger . log ( LogLevel . ERROR , 'Audience segments fetch failed (invalid identifier)' ) ) . once ( ) ;
205
+ } ) ;
206
+
207
+ it ( 'should handle other fetch error responses' , async ( ) => {
182
208
const INVALID_USER_ID = 'invalid-user' ;
183
209
const errorJsonResponse =
184
210
'{"errors":[{"message":' +
@@ -201,7 +227,7 @@ describe('OdpSegmentApiManager', () => {
201
227
) ;
202
228
203
229
expect ( segments ) . toBeNull ( ) ;
204
- verify ( mockLogger . log ( anything ( ) , anyString ( ) ) ) . once ( ) ;
230
+ verify ( mockLogger . log ( LogLevel . ERROR , 'Audience segments fetch failed (DataFetchingException)' ) ) . once ( ) ;
205
231
} ) ;
206
232
207
233
it ( 'should handle unrecognized JSON responses' , async ( ) => {
0 commit comments