11import { GroupFixture } from 'sentry-fixture/group' ;
2+ import { OrganizationFixture } from 'sentry-fixture/organization' ;
3+ import { ProjectFixture } from 'sentry-fixture/project' ;
24
3- import { initializeOrg } from 'sentry-test/initializeOrg' ;
45import { render , screen , userEvent , waitFor } from 'sentry-test/reactTestingLibrary' ;
56
67import ProjectIssues from 'sentry/views/projectDetail/projectIssues' ;
@@ -10,11 +11,10 @@ describe('ProjectDetail > ProjectIssues', () => {
1011 filteredEndpointMock : ReturnType < typeof MockApiClient . addMockResponse > ,
1112 newIssuesEndpointMock : ReturnType < typeof MockApiClient . addMockResponse > ;
1213
13- const { organization, router, project} = initializeOrg ( {
14- organization : {
15- features : [ 'discover-basic' ] ,
16- } ,
14+ const organization = OrganizationFixture ( {
15+ features : [ 'discover-basic' ] ,
1716 } ) ;
17+ const project = ProjectFixture ( ) ;
1818
1919 beforeEach ( ( ) => {
2020 endpointMock = MockApiClient . addMockResponse ( {
@@ -62,46 +62,40 @@ describe('ProjectDetail > ProjectIssues', () => {
6262 < ProjectIssues
6363 api = { new MockApiClient ( ) }
6464 organization = { organization }
65- location = { router . location }
65+ location = { { query : { } } as any }
6666 projectId = { parseInt ( project . id , 10 ) }
6767 /> ,
6868 {
69- router,
7069 organization,
71- deprecatedRouterMocks : true ,
7270 }
7371 ) ;
7472
7573 expect ( await screen . findAllByTestId ( 'group' ) ) . toHaveLength ( 2 ) ;
7674 } ) ;
7775
7876 it ( 'renders a link to Issues' , async ( ) => {
79- render (
77+ const { router } = render (
8078 < ProjectIssues
8179 api = { new MockApiClient ( ) }
8280 organization = { organization }
8381 projectId = { parseInt ( project . id , 10 ) }
84- location = { router . location }
82+ location = { { query : { } } as any }
8583 /> ,
8684 {
87- router,
8885 organization,
89- deprecatedRouterMocks : true ,
9086 }
9187 ) ;
9288
9389 const link = screen . getByLabelText ( 'Open in Issues' ) ;
9490 expect ( link ) . toBeInTheDocument ( ) ;
9591 await userEvent . click ( link ) ;
9692
97- expect ( router . push ) . toHaveBeenCalledWith ( {
98- pathname : '/organizations/org-slug/issues/' ,
99- query : {
100- limit : '5' ,
101- query : 'error.unhandled:true is:unresolved' ,
102- sort : 'freq' ,
103- statsPeriod : '14d' ,
104- } ,
93+ expect ( router . location . pathname ) . toBe ( '/organizations/org-slug/issues/' ) ;
94+ expect ( router . location . query ) . toEqual ( {
95+ limit : '5' ,
96+ query : 'error.unhandled:true is:unresolved' ,
97+ sort : 'freq' ,
98+ statsPeriod : '14d' ,
10599 } ) ;
106100 } ) ;
107101
@@ -110,13 +104,11 @@ describe('ProjectDetail > ProjectIssues', () => {
110104 < ProjectIssues
111105 api = { new MockApiClient ( ) }
112106 organization = { organization }
113- location = { router . location }
107+ location = { { query : { } } as any }
114108 projectId = { parseInt ( project . id , 10 ) }
115109 /> ,
116110 {
117- router,
118111 organization,
119- deprecatedRouterMocks : true ,
120112 }
121113 ) ;
122114
@@ -137,53 +129,50 @@ describe('ProjectDetail > ProjectIssues', () => {
137129 } ) ;
138130
139131 it ( 'renders a link to Discover' , async ( ) => {
140- render (
132+ const { router } = render (
141133 < ProjectIssues
142134 api = { new MockApiClient ( ) }
143135 organization = { organization }
144- location = { router . location }
136+ location = { { query : { } } as any }
145137 projectId = { parseInt ( project . id , 10 ) }
146138 /> ,
147139 {
148- router,
149140 organization,
150- deprecatedRouterMocks : true ,
151141 }
152142 ) ;
153143
154144 const link = screen . getByLabelText ( 'Open in Discover' ) ;
155145 expect ( link ) . toBeInTheDocument ( ) ;
156146 await userEvent . click ( link ) ;
157147
158- expect ( router . push ) . toHaveBeenCalledWith ( {
159- pathname : `/organizations/${ organization . slug } /explore/discover/results/` ,
160- query : {
161- display : 'top5' ,
162- field : [ 'issue' , 'title' , 'count()' , 'count_unique(user)' , 'project' ] ,
163- name : 'Frequent Unhandled Issues' ,
164- query : 'event.type:error error.unhandled:true ' ,
165- queryDataset : 'error-events ' ,
166- sort : '-count ' ,
167- statsPeriod : '14d ' ,
168- } ,
148+ expect ( router . location . pathname ) . toBe (
149+ `/organizations/${ organization . slug } /explore/discover/results/`
150+ ) ;
151+ expect ( router . location . query ) . toEqual ( {
152+ display : 'top5' ,
153+ field : [ 'issue' , 'title' , 'count()' , 'count_unique(user)' , 'project' ] ,
154+ name : 'Frequent Unhandled Issues ' ,
155+ query : 'event.type: error error.unhandled:true ' ,
156+ queryDataset : 'error-events ' ,
157+ sort : '-count ' ,
158+ statsPeriod : '14d' ,
169159 } ) ;
170160 } ) ;
171161
172162 it ( 'changes according to global header' , async ( ) => {
173- render (
163+ const locationWithQuery = {
164+ query : { statsPeriod : '7d' , environment : 'staging' , somethingBad : 'nope' } ,
165+ } as any ;
166+
167+ const { router} = render (
174168 < ProjectIssues
175169 organization = { organization }
176170 api = { new MockApiClient ( ) }
177171 projectId = { parseInt ( project . id , 10 ) }
178- location = { {
179- ...router . location ,
180- query : { statsPeriod : '7d' , environment : 'staging' , somethingBad : 'nope' } ,
181- } }
172+ location = { locationWithQuery }
182173 /> ,
183174 {
184- router,
185175 organization,
186- deprecatedRouterMocks : true ,
187176 }
188177 ) ;
189178
@@ -194,15 +183,13 @@ describe('ProjectDetail > ProjectIssues', () => {
194183 expect ( link ) . toBeInTheDocument ( ) ;
195184 await userEvent . click ( link ) ;
196185
197- expect ( router . push ) . toHaveBeenCalledWith ( {
198- pathname : `/organizations/${ organization . slug } /issues/` ,
199- query : {
200- limit : '5' ,
201- environment : 'staging' ,
202- statsPeriod : '7d' ,
203- query : 'error.unhandled:true is:unresolved' ,
204- sort : 'freq' ,
205- } ,
186+ expect ( router . location . pathname ) . toBe ( `/organizations/${ organization . slug } /issues/` ) ;
187+ expect ( router . location . query ) . toEqual ( {
188+ limit : '5' ,
189+ environment : 'staging' ,
190+ statsPeriod : '7d' ,
191+ query : 'error.unhandled:true is:unresolved' ,
192+ sort : 'freq' ,
206193 } ) ;
207194 } ) ;
208195} ) ;
0 commit comments