@@ -3,7 +3,6 @@ import {EventStacktraceExceptionFixture} from 'sentry-fixture/eventStacktraceExc
3
3
import { GroupFixture } from 'sentry-fixture/group' ;
4
4
import { OrganizationFixture } from 'sentry-fixture/organization' ;
5
5
import { ProjectFixture } from 'sentry-fixture/project' ;
6
- import { RouterFixture } from 'sentry-fixture/routerFixture' ;
7
6
8
7
import {
9
8
render ,
@@ -20,6 +19,7 @@ import ModalStore from 'sentry/stores/modalStore';
20
19
import { GroupStatus , IssueCategory } from 'sentry/types/group' ;
21
20
import * as analytics from 'sentry/utils/analytics' ;
22
21
import { GroupActions } from 'sentry/views/issueDetails/actions' ;
22
+ import { useGroup } from 'sentry/views/issueDetails/useGroup' ;
23
23
24
24
const project = ProjectFixture ( {
25
25
id : '2448' ,
@@ -68,7 +68,6 @@ describe('GroupActions', function () {
68
68
< GroupActions group = { group } project = { project } disabled = { false } event = { null } /> ,
69
69
{
70
70
organization,
71
- deprecatedRouterMocks : true ,
72
71
}
73
72
) ;
74
73
expect ( await screen . findByRole ( 'button' , { name : 'Resolve' } ) ) . toBeInTheDocument ( ) ;
@@ -90,7 +89,6 @@ describe('GroupActions', function () {
90
89
< GroupActions group = { group } project = { project } disabled = { false } event = { null } /> ,
91
90
{
92
91
organization,
93
- deprecatedRouterMocks : true ,
94
92
}
95
93
) ;
96
94
await userEvent . click ( screen . getByRole ( 'button' , { name : 'Subscribe' } ) ) ;
@@ -120,7 +118,6 @@ describe('GroupActions', function () {
120
118
< GroupActions group = { group } project = { project } disabled = { false } event = { null } /> ,
121
119
{
122
120
organization,
123
- deprecatedRouterMocks : true ,
124
121
}
125
122
) ;
126
123
@@ -148,7 +145,6 @@ describe('GroupActions', function () {
148
145
< GroupActions group = { group } project = { project } event = { event } disabled = { false } /> ,
149
146
{
150
147
organization,
151
- deprecatedRouterMocks : true ,
152
148
}
153
149
) ;
154
150
@@ -167,7 +163,6 @@ describe('GroupActions', function () {
167
163
< GroupActions group = { group } project = { project } event = { event } disabled = { false } /> ,
168
164
{
169
165
organization,
170
- deprecatedRouterMocks : true ,
171
166
}
172
167
) ;
173
168
@@ -184,7 +179,6 @@ describe('GroupActions', function () {
184
179
185
180
describe ( 'delete' , function ( ) {
186
181
it ( 'opens delete confirm modal from more actions dropdown' , async ( ) => {
187
- const router = RouterFixture ( ) ;
188
182
const org = OrganizationFixture ( {
189
183
...organization ,
190
184
access : [ ...organization . access , 'event:admin' ] ,
@@ -199,15 +193,13 @@ describe('GroupActions', function () {
199
193
method : 'DELETE' ,
200
194
body : { } ,
201
195
} ) ;
202
- render (
196
+ const { router } = render (
203
197
< Fragment >
204
198
< GlobalModal />
205
199
< GroupActions group = { group } project = { project } disabled = { false } event = { null } />
206
200
</ Fragment > ,
207
201
{
208
- router,
209
202
organization : org ,
210
- deprecatedRouterMocks : true ,
211
203
}
212
204
) ;
213
205
@@ -222,14 +214,15 @@ describe('GroupActions', function () {
222
214
await userEvent . click ( within ( modal ) . getByRole ( 'button' , { name : 'Delete' } ) ) ;
223
215
224
216
expect ( deleteMock ) . toHaveBeenCalled ( ) ;
225
- expect ( router . push ) . toHaveBeenCalledWith ( {
226
- pathname : `/organizations/${ org . slug } /issues/` ,
227
- query : { project : project . id } ,
228
- } ) ;
217
+ expect ( router . location ) . toEqual (
218
+ expect . objectContaining ( {
219
+ pathname : `/organizations/${ org . slug } /issues/` ,
220
+ query : { project : project . id } ,
221
+ } )
222
+ ) ;
229
223
} ) ;
230
224
231
225
it ( 'delete for issue platform' , async ( ) => {
232
- const router = RouterFixture ( ) ;
233
226
const org = OrganizationFixture ( {
234
227
...organization ,
235
228
access : [ ...organization . access , 'event:admin' ] ,
@@ -244,7 +237,7 @@ describe('GroupActions', function () {
244
237
method : 'DELETE' ,
245
238
body : { } ,
246
239
} ) ;
247
- render (
240
+ const { router } = render (
248
241
< Fragment >
249
242
< GlobalModal />
250
243
< GroupActions
@@ -255,9 +248,7 @@ describe('GroupActions', function () {
255
248
/>
256
249
</ Fragment > ,
257
250
{
258
- router,
259
251
organization : org ,
260
- deprecatedRouterMocks : true ,
261
252
}
262
253
) ;
263
254
@@ -272,10 +263,12 @@ describe('GroupActions', function () {
272
263
await userEvent . click ( within ( modal ) . getByRole ( 'button' , { name : 'Delete' } ) ) ;
273
264
274
265
expect ( deleteMock ) . toHaveBeenCalled ( ) ;
275
- expect ( router . push ) . toHaveBeenCalledWith ( {
276
- pathname : `/organizations/${ org . slug } /issues/` ,
277
- query : { project : project . id } ,
278
- } ) ;
266
+ expect ( router . location ) . toEqual (
267
+ expect . objectContaining ( {
268
+ pathname : `/organizations/${ org . slug } /issues/` ,
269
+ query : { project : project . id } ,
270
+ } )
271
+ ) ;
279
272
} ) ;
280
273
} ) ;
281
274
@@ -288,10 +281,7 @@ describe('GroupActions', function () {
288
281
289
282
const { rerender} = render (
290
283
< GroupActions group = { group } project = { project } disabled = { false } event = { null } /> ,
291
- {
292
- organization,
293
- deprecatedRouterMocks : true ,
294
- }
284
+ { organization}
295
285
) ;
296
286
297
287
await userEvent . click ( screen . getByRole ( 'button' , { name : 'Resolve' } ) ) ;
@@ -363,4 +353,51 @@ describe('GroupActions', function () {
363
353
} )
364
354
) ;
365
355
} ) ;
356
+
357
+ it ( 'refetches group data after resolve action using useGroup hook' , async ( ) => {
358
+ const issuesApi = MockApiClient . addMockResponse ( {
359
+ url : `/projects/${ organization . slug } /project/issues/` ,
360
+ method : 'PUT' ,
361
+ body : { ...group , status : 'resolved' } ,
362
+ } ) ;
363
+
364
+ // Mock the group fetch API that useGroup hook will call
365
+ const groupFetchApi = MockApiClient . addMockResponse ( {
366
+ url : `/organizations/${ organization . slug } /issues/${ group . id } /` ,
367
+ method : 'GET' ,
368
+ body : group ,
369
+ } ) ;
370
+
371
+ function GroupActionsWrapper ( ) {
372
+ const { data : groupData , isLoading} = useGroup ( { groupId : group . id } ) ;
373
+
374
+ if ( isLoading || ! groupData ) {
375
+ return < div > Loading...</ div > ;
376
+ }
377
+
378
+ return (
379
+ < GroupActions group = { groupData } project = { project } disabled = { false } event = { null } />
380
+ ) ;
381
+ }
382
+
383
+ render ( < GroupActionsWrapper /> , { organization} ) ;
384
+
385
+ await waitFor ( ( ) => {
386
+ expect ( groupFetchApi ) . toHaveBeenCalledTimes ( 1 ) ;
387
+ } ) ;
388
+
389
+ await userEvent . click ( screen . getByRole ( 'button' , { name : 'Resolve' } ) ) ;
390
+
391
+ expect ( issuesApi ) . toHaveBeenCalledWith (
392
+ `/projects/${ organization . slug } /project/issues/` ,
393
+ expect . objectContaining ( {
394
+ data : { status : 'resolved' , statusDetails : { } , substatus : null } ,
395
+ } )
396
+ ) ;
397
+
398
+ // Verify that the group is fetched a second time after the action to refresh data
399
+ await waitFor ( ( ) => {
400
+ expect ( groupFetchApi ) . toHaveBeenCalledTimes ( 2 ) ;
401
+ } ) ;
402
+ } ) ;
366
403
} ) ;
0 commit comments