1+ import { OrganizationFixture } from 'sentry-fixture/organization' ;
2+ import { ProjectFixture } from 'sentry-fixture/project' ;
13import { ReleaseFixture } from 'sentry-fixture/release' ;
24import {
35 SessionUserCountByStatus2Fixture ,
46 SessionUserCountByStatusFixture ,
57} from 'sentry-fixture/sessions' ;
68
7- import { initializeOrg } from 'sentry-test/initializeOrg ' ;
8- import { act , render , screen , userEvent } from 'sentry-test/reactTestingLibrary' ;
9+ import { render , screen , userEvent } from 'sentry-test/reactTestingLibrary ' ;
10+ import type { RouterConfig } from 'sentry-test/reactTestingLibrary' ;
911
1012import type { ReleaseProject } from 'sentry/types/release' ;
1113import ReleaseComparisonChart from 'sentry/views/releases/detail/overview/releaseComparisonChart' ;
1214
1315describe ( 'Releases > Detail > Overview > ReleaseComparison' , ( ) => {
14- const { router , organization, project : rawProject } = initializeOrg ( ) ;
15- const api = new MockApiClient ( ) ;
16+ const organization = OrganizationFixture ( ) ;
17+ const rawProject = ProjectFixture ( ) ;
1618 const release = ReleaseFixture ( ) ;
19+ const initialRouterConfig : RouterConfig = {
20+ location : {
21+ pathname : `/organizations/${ organization . slug } /releases/${ release . version } /` ,
22+ query : { } ,
23+ } ,
24+ routes : [ '/organizations/:orgId/releases/:release/' ] ,
25+ } ;
26+ const api = new MockApiClient ( ) ;
1727 const releaseSessions = SessionUserCountByStatusFixture ( ) ;
1828 const allSessions = SessionUserCountByStatus2Fixture ( ) ;
1929
@@ -32,18 +42,16 @@ describe('Releases > Detail > Overview > ReleaseComparison', () => {
3242 releaseSessions = { releaseSessions }
3343 allSessions = { allSessions }
3444 platform = "javascript"
35- location = { { ...router . location , query : { } } }
3645 loading = { false }
3746 reloading = { false }
3847 errored = { false }
3948 project = { project }
40- organization = { organization }
4149 api = { api }
4250 hasHealthData
4351 /> ,
4452 {
45- router ,
46- deprecatedRouterMocks : true ,
53+ organization ,
54+ initialRouterConfig ,
4755 }
4856 ) ;
4957
@@ -63,48 +71,29 @@ describe('Releases > Detail > Overview > ReleaseComparison', () => {
6371 } ) ;
6472
6573 it ( 'can change chart by clicking on a row' , async ( ) => {
66- const { rerender } = render (
74+ const { router } = render (
6775 < ReleaseComparisonChart
6876 release = { release }
6977 releaseSessions = { releaseSessions }
7078 allSessions = { allSessions }
7179 platform = "javascript"
72- location = { { ...router . location , query : { } } }
7380 loading = { false }
7481 reloading = { false }
7582 errored = { false }
7683 project = { project }
77- organization = { organization }
7884 api = { api }
7985 hasHealthData
8086 /> ,
8187 {
82- router ,
83- deprecatedRouterMocks : true ,
88+ organization ,
89+ initialRouterConfig ,
8490 }
8591 ) ;
8692
8793 await userEvent . click ( screen . getByLabelText ( / c r a s h f r e e u s e r r a t e / i) ) ;
8894
89- expect ( router . push ) . toHaveBeenCalledWith (
90- expect . objectContaining ( { query : { chart : 'crashFreeUsers' } } )
91- ) ;
92-
93- rerender (
94- < ReleaseComparisonChart
95- release = { release }
96- releaseSessions = { releaseSessions }
97- allSessions = { allSessions }
98- platform = "javascript"
99- location = { { ...router . location , query : { chart : 'crashFreeUsers' } } }
100- loading = { false }
101- reloading = { false }
102- errored = { false }
103- project = { project }
104- organization = { organization }
105- api = { api }
106- hasHealthData
107- />
95+ expect ( router . location . query ) . toEqual (
96+ expect . objectContaining ( { chart : 'crashFreeUsers' } )
10897 ) ;
10998
11099 expect ( screen . getByLabelText ( 'Chart Title' ) ) . toHaveTextContent (
@@ -120,18 +109,16 @@ describe('Releases > Detail > Overview > ReleaseComparison', () => {
120109 releaseSessions = { releaseSessions }
121110 allSessions = { allSessions }
122111 platform = "javascript"
123- location = { { ...router . location , query : { } } }
124112 loading = { false }
125113 reloading = { false }
126114 errored = { false }
127115 project = { project }
128- organization = { organization }
129116 api = { api }
130117 hasHealthData
131118 /> ,
132119 {
133- router ,
134- deprecatedRouterMocks : true ,
120+ organization ,
121+ initialRouterConfig ,
135122 }
136123 ) ;
137124
@@ -171,36 +158,31 @@ describe('Releases > Detail > Overview > ReleaseComparison', () => {
171158 url : `/organizations/${ organization . slug } /issues-count/` ,
172159 body : 0 ,
173160 } ) ;
161+ const noHealthDataOrganization = OrganizationFixture ( {
162+ features : [ ...organization . features , 'discover-basic' ] ,
163+ } ) ;
174164
175165 render (
176166 < ReleaseComparisonChart
177167 release = { release }
178168 releaseSessions = { null }
179169 allSessions = { null }
180170 platform = "javascript"
181- location = { { ...router . location , query : { } } }
182171 loading = { false }
183172 reloading = { false }
184173 errored = { false }
185174 project = { project }
186- organization = { {
187- ...organization ,
188- features : [ ...organization . features , 'discover-basic' ] ,
189- } }
190175 api = { api }
191176 hasHealthData = { false }
192177 /> ,
193178 {
194- router ,
195- deprecatedRouterMocks : true ,
179+ organization : noHealthDataOrganization ,
180+ initialRouterConfig ,
196181 }
197182 ) ;
198183
199- expect ( screen . getAllByRole ( 'radio' ) ) . toHaveLength ( 1 ) ;
184+ expect ( await screen . findAllByRole ( 'radio' ) ) . toHaveLength ( 1 ) ;
200185 expect ( screen . queryByLabelText ( / t o g g l e c h a r t / i) ) . not . toBeInTheDocument ( ) ;
201186 expect ( screen . queryByLabelText ( / t o g g l e a d d i t i o n a l / i) ) . not . toBeInTheDocument ( ) ;
202-
203- // Wait for api requests to propegate
204- await act ( tick ) ;
205187 } ) ;
206188} ) ;
0 commit comments