@@ -4,7 +4,6 @@ import {TeamFixture} from 'sentry-fixture/team';
4
4
import { TeamIssuesBreakdownFixture } from 'sentry-fixture/teamIssuesBreakdown' ;
5
5
import { TeamResolutionTimeFixture } from 'sentry-fixture/teamResolutionTime' ;
6
6
7
- import { initializeOrg } from 'sentry-test/initializeOrg' ;
8
7
import { render , screen , userEvent } from 'sentry-test/reactTestingLibrary' ;
9
8
10
9
import ProjectsStore from 'sentry/stores/projectsStore' ;
@@ -56,7 +55,6 @@ describe('TeamStatsIssues', () => {
56
55
projects : [ ] ,
57
56
isMember : false ,
58
57
} ) ;
59
- const { routerProps, router} = initializeOrg ( ) ;
60
58
61
59
beforeEach ( ( ) => {
62
60
TeamStore . reset ( ) ;
@@ -146,7 +144,7 @@ describe('TeamStatsIssues', () => {
146
144
147
145
TeamStore . loadInitialData ( teams , false , null ) ;
148
146
149
- return render ( < TeamStatsIssues { ... routerProps } /> , { organization} ) ;
147
+ return render ( < TeamStatsIssues /> , { organization} ) ;
150
148
}
151
149
152
150
it ( 'defaults to first team' , async ( ) => {
@@ -157,50 +155,54 @@ describe('TeamStatsIssues', () => {
157
155
} ) ;
158
156
159
157
it ( 'allows team switching as non-owner' , async ( ) => {
160
- createWrapper ( { isOrgOwner : false } ) ;
158
+ MockApiClient . addMockResponse ( {
159
+ url : `/teams/org-slug/${ team1 . slug } /issues/old/` ,
160
+ body : [ ] ,
161
+ } ) ;
162
+ MockApiClient . addMockResponse ( {
163
+ url : `/teams/org-slug/${ team1 . slug } /unresolved-issue-age/` ,
164
+ body : [ ] ,
165
+ } ) ;
166
+ const { router} = createWrapper ( { isOrgOwner : false } ) ;
161
167
162
168
expect ( screen . getByText ( '#backend' ) ) . toBeInTheDocument ( ) ;
163
169
await userEvent . type ( screen . getByText ( '#backend' ) , '{mouseDown}' ) ;
164
170
expect ( screen . getByText ( '#frontend' ) ) . toBeInTheDocument ( ) ;
165
171
// Teams user is not a member of are hidden
166
172
expect ( screen . queryByText ( '#internal' ) ) . not . toBeInTheDocument ( ) ;
167
173
await userEvent . click ( screen . getByText ( '#frontend' ) ) ;
168
- expect ( router . push ) . toHaveBeenCalledWith (
169
- expect . objectContaining ( { query : { team : team1 . id } } )
170
- ) ;
174
+ expect ( router . location ) . toEqual ( expect . objectContaining ( { query : { team : team1 . id } } ) ) ;
171
175
expect ( localStorage . setItem ) . toHaveBeenCalledWith (
172
176
'teamInsightsSelectedTeamId:org-slug' ,
173
177
team1 . id
174
178
) ;
175
179
} ) ;
176
180
177
181
it ( 'allows team switching as owner' , async ( ) => {
178
- createWrapper ( ) ;
182
+ const { router } = createWrapper ( ) ;
179
183
180
184
expect ( screen . getByText ( '#backend' ) ) . toBeInTheDocument ( ) ;
181
185
await userEvent . type ( screen . getByText ( '#backend' ) , '{mouseDown}' ) ;
182
186
expect ( screen . getByText ( '#frontend' ) ) . toBeInTheDocument ( ) ;
183
187
// Org owners can see all teams including ones they are not members of
184
188
expect ( screen . getByText ( '#internal' ) ) . toBeInTheDocument ( ) ;
185
189
await userEvent . click ( screen . getByText ( '#internal' ) ) ;
186
- expect ( router . push ) . toHaveBeenCalledWith (
187
- expect . objectContaining ( { query : { team : team3 . id } } )
188
- ) ;
190
+ expect ( router . location ) . toEqual ( expect . objectContaining ( { query : { team : team3 . id } } ) ) ;
189
191
expect ( localStorage . setItem ) . toHaveBeenCalledWith (
190
192
'teamInsightsSelectedTeamId:org-slug' ,
191
193
team3 . id
192
194
) ;
193
195
} ) ;
194
196
195
197
it ( 'can filter by environment' , async ( ) => {
196
- createWrapper ( ) ;
198
+ const { router } = createWrapper ( ) ;
197
199
198
200
// For some reason the "Environment:" is rendered via css :before
199
201
expect ( screen . getByText ( 'All' ) ) . toBeInTheDocument ( ) ;
200
202
await userEvent . type ( screen . getByText ( 'All' ) , '{mouseDown}' ) ;
201
203
expect ( screen . getByText ( env1 ) ) . toBeInTheDocument ( ) ;
202
204
await userEvent . click ( screen . getByText ( env1 ) ) ;
203
- expect ( router . push ) . toHaveBeenCalledWith (
205
+ expect ( router . location ) . toEqual (
204
206
expect . objectContaining ( { query : { environment : 'prod' } } )
205
207
) ;
206
208
} ) ;
0 commit comments