@@ -8,16 +8,11 @@ import ProjectsStore from 'sentry/stores/projectsStore';
8
8
import EventView from 'sentry/utils/discover/eventView' ;
9
9
import { MEPSettingProvider } from 'sentry/utils/performance/contexts/metricsEnhancedSetting' ;
10
10
import { MutableSearch } from 'sentry/utils/tokenizeSearch' ;
11
- import { useLocation } from 'sentry/utils/useLocation' ;
12
11
import { OrganizationContext } from 'sentry/views/organizationContext' ;
13
12
import Table from 'sentry/views/performance/table' ;
14
13
15
14
const FEATURES = [ 'performance-view' ] ;
16
15
17
- jest . mock ( 'sentry/utils/useLocation' ) ;
18
-
19
- const mockUseLocation = jest . mocked ( useLocation ) ;
20
-
21
16
const initializeData = ( settings = { } , features : string [ ] = [ ] ) => {
22
17
const projects = [
23
18
ProjectFixture ( { id : '1' , slug : '1' } ) ,
@@ -37,7 +32,7 @@ function WrappedComponent({data, ...rest}: any) {
37
32
< MEPSettingProvider >
38
33
< Table
39
34
organization = { data . organization }
40
- location = { data . router . location }
35
+ location = { LocationFixture ( { ... data . initialRouterConfig . location } ) }
41
36
setError = { jest . fn ( ) }
42
37
summaryConditions = ""
43
38
{ ...data }
@@ -108,9 +103,6 @@ function mockEventView(data: ReturnType<typeof initializeData>) {
108
103
describe ( 'Performance > Table' , function ( ) {
109
104
let eventsMock : jest . Mock ;
110
105
beforeEach ( function ( ) {
111
- mockUseLocation . mockReturnValue (
112
- LocationFixture ( { pathname : '/organizations/org-slug/insights/summary' } )
113
- ) ;
114
106
MockApiClient . addMockResponse ( {
115
107
url : '/organizations/org-slug/projects/' ,
116
108
body : [ ] ,
@@ -201,7 +193,7 @@ describe('Performance > Table', function () {
201
193
202
194
ProjectsStore . loadInitialData ( data . projects ) ;
203
195
204
- render (
196
+ const { router } = render (
205
197
< WrappedComponent
206
198
data = { data }
207
199
eventView = { mockEventView ( data ) }
@@ -210,10 +202,10 @@ describe('Performance > Table', function () {
210
202
projects = { data . projects }
211
203
/> ,
212
204
{
213
- router : data . router ,
214
- deprecatedRouterMocks : true ,
205
+ initialRouterConfig : data . initialRouterConfig ,
215
206
}
216
207
) ;
208
+ const initialLocation = router . location ;
217
209
218
210
const rows = await screen . findAllByTestId ( 'grid-body-row' ) ;
219
211
const transactionCells = within ( rows [ 0 ] ! ) . getAllByTestId ( 'grid-body-cell' ) ;
@@ -243,16 +235,15 @@ describe('Performance > Table', function () {
243
235
expect ( transactionCellTrigger ) . toBeInTheDocument ( ) ;
244
236
await userEvent . click ( transactionCellTrigger ) ;
245
237
246
- expect ( data . router . push ) . toHaveBeenCalledTimes ( 0 ) ;
238
+ expect ( router . location ) . toEqual ( initialLocation ) ;
247
239
await userEvent . click ( screen . getByRole ( 'menuitemradio' , { name : 'Add to filter' } ) ) ;
248
240
249
- expect ( data . router . push ) . toHaveBeenCalledTimes ( 1 ) ;
250
- expect ( data . router . push ) . toHaveBeenNthCalledWith ( 1 , {
251
- pathname : undefined ,
252
- query : expect . objectContaining ( {
241
+ expect ( router . location ) . not . toEqual ( initialLocation ) ;
242
+ expect ( router . location . query ) . toEqual (
243
+ expect . objectContaining ( {
253
244
query : 'transaction:/apple/cart' ,
254
- } ) ,
255
- } ) ;
245
+ } )
246
+ ) ;
256
247
} ) ;
257
248
258
249
it ( 'hides cell actions when withStaticFilters is true' , async function ( ) {
@@ -268,10 +259,7 @@ describe('Performance > Table', function () {
268
259
summaryConditions = ""
269
260
projects = { data . projects }
270
261
withStaticFilters
271
- /> ,
272
- {
273
- deprecatedRouterMocks : true ,
274
- }
262
+ />
275
263
) ;
276
264
277
265
expect ( await screen . findByTestId ( 'grid-editable' ) ) . toBeInTheDocument ( ) ;
@@ -299,10 +287,7 @@ describe('Performance > Table', function () {
299
287
setError = { jest . fn ( ) }
300
288
summaryConditions = ""
301
289
projects = { data . projects }
302
- /> ,
303
- {
304
- deprecatedRouterMocks : true ,
305
- }
290
+ />
306
291
) ;
307
292
308
293
const indicatorContainer = await screen . findByTestId ( 'unparameterized-indicator' ) ;
@@ -360,10 +345,7 @@ describe('Performance > Table', function () {
360
345
summaryConditions = ""
361
346
projects = { data . projects }
362
347
isMEPEnabled
363
- /> ,
364
- {
365
- deprecatedRouterMocks : true ,
366
- }
348
+ />
367
349
) ;
368
350
369
351
expect ( await screen . findByTestId ( 'grid-editable' ) ) . toBeInTheDocument ( ) ;
0 commit comments