File tree Expand file tree Collapse file tree 2 files changed +23
-11
lines changed Expand file tree Collapse file tree 2 files changed +23
-11
lines changed Original file line number Diff line number Diff line change @@ -46,23 +46,18 @@ export const sendFeedback: SendFeedback = (
46
46
cleanup ( ) ;
47
47
48
48
// Require valid status codes, otherwise can assume feedback was not sent successfully
49
- if (
50
- response &&
51
- typeof response . statusCode === 'number' &&
52
- response . statusCode >= 200 &&
53
- response . statusCode < 300
54
- ) {
49
+ if ( response ?. statusCode && response . statusCode >= 200 && response . statusCode < 300 ) {
55
50
return resolve ( eventId ) ;
56
51
}
57
52
58
- if ( response && typeof response . statusCode === 'number' && response . statusCode === 403 ) {
53
+ if ( response ? .statusCode === 403 ) {
59
54
return reject (
60
- 'Unable to send Feedback . This could be because this domain is not in your list of allowed domains.' ,
55
+ 'Unable to send feedback . This could be because this domain is not in your list of allowed domains.' ,
61
56
) ;
62
57
}
63
58
64
59
return reject (
65
- 'Unable to send Feedback . This could be because of network issues, or because you are using an ad-blocker' ,
60
+ 'Unable to send feedback . This could be because of network issues, or because you are using an ad-blocker. ' ,
66
61
) ;
67
62
} ) ;
68
63
} ) ;
Original file line number Diff line number Diff line change @@ -280,7 +280,7 @@ describe('sendFeedback', () => {
280
280
message : 'mi' ,
281
281
} ) ,
282
282
) . rejects . toMatch (
283
- 'Unable to send Feedback . This could be because of network issues, or because you are using an ad-blocker' ,
283
+ 'Unable to send feedback . This could be because of network issues, or because you are using an ad-blocker. ' ,
284
284
) ;
285
285
} ) ;
286
286
@@ -297,7 +297,24 @@ describe('sendFeedback', () => {
297
297
message : 'mi' ,
298
298
} ) ,
299
299
) . rejects . toMatch (
300
- 'Unable to send Feedback. This is because of network issues, or because you are using an ad-blocker.' ,
300
+ 'Unable to send feedback. This could be because of network issues, or because you are using an ad-blocker.' ,
301
+ ) ;
302
+ } ) ;
303
+
304
+ it ( 'handles 403 transport error' , async ( ) => {
305
+ mockSdk ( ) ;
306
+ vi . spyOn ( getClient ( ) ! . getTransport ( ) ! , 'send' ) . mockImplementation ( ( ) => {
307
+ return Promise . resolve ( { statusCode : 403 } ) ;
308
+ } ) ;
309
+
310
+ await expect (
311
+ sendFeedback ( {
312
+ name : 'doe' ,
313
+
314
+ message : 'mi' ,
315
+ } ) ,
316
+ ) . rejects . toMatch (
317
+ 'Unable to send feedback. This could be because this domain is not in your list of allowed domains.' ,
301
318
) ;
302
319
} ) ;
303
320
You can’t perform that action at this time.
0 commit comments