1- import type { Location } from 'history' ;
21import { HealthFixture } from 'sentry-fixture/health' ;
3- import { LocationFixture } from 'sentry-fixture/locationFixture' ;
42import { OrganizationFixture } from 'sentry-fixture/organization' ;
53import { ReleaseFixture } from 'sentry-fixture/release' ;
64import { ReleaseMetaFixture } from 'sentry-fixture/releaseMeta' ;
75import { ReleaseProjectFixture } from 'sentry-fixture/releaseProject' ;
8- import { RouteComponentPropsFixture } from 'sentry-fixture/routeComponentPropsFixture' ;
9- import { RouterFixture } from 'sentry-fixture/routerFixture' ;
106
117import {
128 render ,
@@ -15,13 +11,13 @@ import {
1511 userEvent ,
1612 waitFor ,
1713} from 'sentry-test/reactTestingLibrary' ;
14+ import type { RouterConfig } from 'sentry-test/reactTestingLibrary' ;
1815
1916import type { ReleaseProject } from 'sentry/types/release' ;
2017import { ReleaseStatus } from 'sentry/types/release' ;
2118import ReleaseActions from 'sentry/views/releases/detail/header/releaseActions' ;
2219
2320describe ( 'ReleaseActions' , ( ) => {
24- const router = RouterFixture ( ) ;
2521 const organization = OrganizationFixture ( ) ;
2622
2723 const project1 = ReleaseProjectFixture ( {
@@ -40,15 +36,17 @@ describe('ReleaseActions', () => {
4036 projects : [ project1 , project2 ] ,
4137 } ) ;
4238
43- const location : Location = {
44- ...LocationFixture ( ) ,
45- pathname : `/organizations/${ organization . slug } /releases/${ release . version } /` ,
46- query : {
47- project : '1' ,
48- statsPeriod : '24h' ,
49- yAxis : 'events' ,
39+ const initialRouterConfig : RouterConfig = {
40+ location : {
41+ pathname : `/organizations/${ organization . slug } /releases/${ release . version } /` ,
42+ query : {
43+ project : '1' ,
44+ statsPeriod : '24h' ,
45+ yAxis : 'events' ,
46+ } ,
5047 } ,
5148 } ;
49+
5250 let mockUpdate : ReturnType < typeof MockApiClient . addMockResponse > ;
5351
5452 beforeEach ( ( ) => {
@@ -63,21 +61,19 @@ describe('ReleaseActions', () => {
6361 } ) ;
6462
6563 it ( 'archives a release' , async ( ) => {
66- render (
64+ const { router } = render (
6765 < ReleaseActions
68- organization = { organization }
6966 projectSlug = { release . projects [ 0 ] ! . slug }
7067 release = { release }
7168 refetchData = { jest . fn ( ) }
7269 releaseMeta = { { ...ReleaseMetaFixture ( ) , projects : release . projects } }
73- location = { location }
7470 /> ,
7571 {
76- router ,
77- deprecatedRouterMocks : true ,
72+ organization ,
73+ initialRouterConfig ,
7874 }
7975 ) ;
80- renderGlobalModal ( { router , deprecatedRouterMocks : true } ) ;
76+ renderGlobalModal ( ) ;
8177
8278 await userEvent . click ( screen . getByLabelText ( 'Actions' ) ) ;
8379
@@ -106,8 +102,10 @@ describe('ReleaseActions', () => {
106102 } )
107103 ) ;
108104 await waitFor ( ( ) =>
109- expect ( router . push ) . toHaveBeenCalledWith (
110- `/organizations/${ organization . slug } /explore/releases/`
105+ expect ( router . location ) . toEqual (
106+ expect . objectContaining ( {
107+ pathname : `/organizations/${ organization . slug } /explore/releases/` ,
108+ } )
111109 )
112110 ) ;
113111 } ) ;
@@ -117,20 +115,17 @@ describe('ReleaseActions', () => {
117115
118116 render (
119117 < ReleaseActions
120- { ...RouteComponentPropsFixture ( ) }
121- organization = { organization }
122118 projectSlug = { release . projects [ 0 ] ! . slug }
123119 release = { { ...release , status : ReleaseStatus . ARCHIVED } }
124120 refetchData = { refetchDataMock }
125121 releaseMeta = { { ...ReleaseMetaFixture ( ) , projects : release . projects } }
126- location = { location }
127122 /> ,
128123 {
129- router ,
130- deprecatedRouterMocks : true ,
124+ organization ,
125+ initialRouterConfig ,
131126 }
132127 ) ;
133- renderGlobalModal ( { router } ) ;
128+ renderGlobalModal ( ) ;
134129
135130 await userEvent . click ( screen . getByLabelText ( 'Actions' ) ) ;
136131
@@ -162,19 +157,17 @@ describe('ReleaseActions', () => {
162157 await waitFor ( ( ) => expect ( refetchDataMock ) . toHaveBeenCalledTimes ( 1 ) ) ;
163158 } ) ;
164159
165- it ( 'navigates to a next/prev release' , ( ) => {
166- const { rerender } = render (
160+ it ( 'navigates to a next/prev release' , async ( ) => {
161+ const { router } = render (
167162 < ReleaseActions
168- organization = { organization }
169163 projectSlug = { release . projects [ 0 ] ! . slug }
170164 release = { release }
171165 refetchData = { jest . fn ( ) }
172166 releaseMeta = { { ...ReleaseMetaFixture ( ) , projects : release . projects } }
173- location = { location }
174167 /> ,
175168 {
176- router ,
177- deprecatedRouterMocks : true ,
169+ organization ,
170+ initialRouterConfig ,
178171 }
179172 ) ;
180173
@@ -195,19 +188,13 @@ describe('ReleaseActions', () => {
195188 `/organizations/${ organization . slug } /releases/999/?project=1&statsPeriod=24h&yAxis=events`
196189 ) ;
197190
198- rerender (
199- < ReleaseActions
200- organization = { organization }
201- projectSlug = { release . projects [ 0 ] ! . slug }
202- release = { release }
203- refetchData = { jest . fn ( ) }
204- releaseMeta = { { ...ReleaseMetaFixture ( ) , projects : release . projects } }
205- location = { {
206- ...location ,
207- pathname : `/organizations/${ organization . slug } /releases/${ release . version } /files-changed/` ,
208- } }
209- />
210- ) ;
191+ // Simulate navigation to a sub-page
192+ await waitFor ( ( ) => {
193+ router . navigate ( {
194+ pathname : `/organizations/${ organization . slug } /releases/${ release . version } /files-changed/` ,
195+ search : 'project=1&statsPeriod=24h&yAxis=events' ,
196+ } ) ;
197+ } ) ;
211198
212199 expect ( screen . getByLabelText ( 'Newer' ) ) . toHaveAttribute (
213200 'href' ,
0 commit comments