@@ -7,6 +7,7 @@ import ProjectsStore from 'sentry/stores/projectsStore';
7
7
import { useLocation } from 'sentry/utils/useLocation' ;
8
8
import usePageFilters from 'sentry/utils/usePageFilters' ;
9
9
import { useReleaseStats } from 'sentry/utils/useReleaseStats' ;
10
+ import { QueryParameterNames } from 'sentry/views/insights/common/views/queryParameters' ;
10
11
import { HTTPLandingPage } from 'sentry/views/insights/http/views/httpLandingPage' ;
11
12
12
13
jest . mock ( 'sentry/utils/useLocation' ) ;
@@ -42,15 +43,7 @@ describe('HTTPLandingPage', function () {
42
43
} ,
43
44
} ) ;
44
45
45
- jest . mocked ( useLocation ) . mockReturnValue ( {
46
- pathname : '/insights/backend/http/' ,
47
- search : '' ,
48
- query : { statsPeriod : '10d' , 'span.domain' : 'git' , project : '1' } ,
49
- hash : '' ,
50
- state : undefined ,
51
- action : 'PUSH' ,
52
- key : '' ,
53
- } ) ;
46
+ const useLocationMock = jest . mocked ( useLocation ) ;
54
47
55
48
jest . mocked ( useReleaseStats ) . mockReturnValue ( {
56
49
isLoading : false ,
@@ -63,6 +56,16 @@ describe('HTTPLandingPage', function () {
63
56
beforeEach ( function ( ) {
64
57
jest . clearAllMocks ( ) ;
65
58
59
+ useLocationMock . mockReturnValue ( {
60
+ pathname : '/insights/backend/http/' ,
61
+ search : '' ,
62
+ query : { statsPeriod : '10d' , 'span.domain' : 'git' , project : '1' } ,
63
+ hash : '' ,
64
+ state : undefined ,
65
+ action : 'PUSH' ,
66
+ key : '' ,
67
+ } ) ;
68
+
66
69
ProjectsStore . loadInitialData ( [
67
70
ProjectFixture ( {
68
71
id : '1' ,
@@ -433,4 +436,54 @@ describe('HTTPLandingPage', function () {
433
436
expect ( screen . getByRole ( 'cell' , { name : '333.54ms' } ) ) . toBeInTheDocument ( ) ;
434
437
expect ( screen . getByRole ( 'cell' , { name : '1.35wk' } ) ) . toBeInTheDocument ( ) ;
435
438
} ) ;
439
+
440
+ it ( 'sorts with query params' , async function ( ) {
441
+ useLocationMock . mockReturnValue ( {
442
+ pathname : '/insights/backend/http/' ,
443
+ search : '' ,
444
+ query : {
445
+ statsPeriod : '10d' ,
446
+ 'span.domain' : 'git' ,
447
+ project : '1' ,
448
+ [ QueryParameterNames . DOMAINS_SORT ] : '-avg(span.self_time)' ,
449
+ } ,
450
+ hash : '' ,
451
+ state : undefined ,
452
+ action : 'PUSH' ,
453
+ key : '' ,
454
+ } ) ;
455
+
456
+ render ( < HTTPLandingPage /> , { organization} ) ;
457
+
458
+ await waitForElementToBeRemoved ( ( ) => screen . queryAllByTestId ( 'loading-indicator' ) ) ;
459
+
460
+ expect ( spanListRequestMock ) . toHaveBeenCalledWith (
461
+ `/organizations/${ organization . slug } /events/` ,
462
+ expect . objectContaining ( {
463
+ method : 'GET' ,
464
+ query : {
465
+ dataset : 'spansMetrics' ,
466
+ environment : [ ] ,
467
+ field : [
468
+ 'project' ,
469
+ 'project.id' ,
470
+ 'span.domain' ,
471
+ 'epm()' ,
472
+ 'http_response_rate(3)' ,
473
+ 'http_response_rate(4)' ,
474
+ 'http_response_rate(5)' ,
475
+ 'avg(span.self_time)' ,
476
+ 'sum(span.self_time)' ,
477
+ 'time_spent_percentage()' ,
478
+ ] ,
479
+ per_page : 10 ,
480
+ project : [ ] ,
481
+ query : 'span.module:http span.op:http.client span.domain:*git*' ,
482
+ referrer : 'api.performance.http.landing-domains-list' ,
483
+ sort : '-avg(span.self_time)' ,
484
+ statsPeriod : '10d' ,
485
+ } ,
486
+ } )
487
+ ) ;
488
+ } ) ;
436
489
} ) ;
0 commit comments