11import { EnvironmentsFixture } from 'sentry-fixture/environments' ;
22import { EventAttachmentFixture } from 'sentry-fixture/eventAttachment' ;
33import { GroupFixture } from 'sentry-fixture/group' ;
4+ import { OrganizationFixture } from 'sentry-fixture/organization' ;
45import { ProjectFixture } from 'sentry-fixture/project' ;
56import { TagsFixture } from 'sentry-fixture/tags' ;
67import { UserFixture } from 'sentry-fixture/user' ;
78
8- import { initializeOrg } from 'sentry-test/initializeOrg' ;
99import {
1010 act ,
1111 render ,
1212 renderGlobalModal ,
1313 screen ,
1414 userEvent ,
1515 within ,
16+ type RouterConfig ,
1617} from 'sentry-test/reactTestingLibrary' ;
1718
1819import ConfigStore from 'sentry/stores/configStore' ;
@@ -25,19 +26,24 @@ import GroupEventAttachments from './groupEventAttachments';
2526describe ( 'GroupEventAttachments' , ( ) => {
2627 const groupId = 'group-id' ;
2728 const group = GroupFixture ( { id : groupId } ) ;
28- const { organization, router} = initializeOrg ( {
29- organization : {
30- features : [ 'event-attachments' ] ,
31- orgRole : 'member' ,
32- attachmentsRole : 'member' ,
33- } ,
29+ const organization = OrganizationFixture ( {
30+ features : [ 'event-attachments' ] ,
31+ orgRole : 'member' ,
32+ attachmentsRole : 'member' ,
3433 } ) ;
35- const { router : screenshotRouter } = initializeOrg ( {
36- router : {
37- params : { orgId : 'org-slug' , groupId : 'group-id' } ,
38- location : { query : { attachmentFilter : 'screenshot' } } ,
34+ const initialRouterConfig : RouterConfig = {
35+ location : {
36+ pathname : `/organizations/${ organization . slug } /issues/${ groupId } /attachments/` ,
3937 } ,
40- } ) ;
38+ route : `/organizations/:orgId/issues/:groupId/attachments/` ,
39+ } ;
40+ const screenshotRouterConfig : RouterConfig = {
41+ location : {
42+ pathname : `/organizations/${ organization . slug } /issues/${ groupId } /attachments/` ,
43+ query : { attachmentFilter : 'screenshot' } ,
44+ } ,
45+ route : `/organizations/:orgId/issues/:groupId/attachments/` ,
46+ } ;
4147 let project : Project ;
4248 let getAttachmentsMock : jest . Mock ;
4349
@@ -67,9 +73,8 @@ describe('GroupEventAttachments', () => {
6773
6874 it ( 'calls attachments api with screenshot filter' , async ( ) => {
6975 render ( < GroupEventAttachments project = { project } group = { group } /> , {
70- router : screenshotRouter ,
7176 organization,
72- deprecatedRouterMocks : true ,
77+ initialRouterConfig : screenshotRouterConfig ,
7378 } ) ;
7479 expect ( screen . getByRole ( 'radio' , { name : 'Screenshots' } ) ) . toBeInTheDocument ( ) ;
7580 await userEvent . click ( screen . getByRole ( 'radio' , { name : 'Screenshots' } ) ) ;
@@ -87,9 +92,8 @@ describe('GroupEventAttachments', () => {
8792
8893 it ( 'calls opens modal when clicking on panel body' , async ( ) => {
8994 render ( < GroupEventAttachments project = { project } group = { group } /> , {
90- router : screenshotRouter ,
9195 organization,
92- deprecatedRouterMocks : true ,
96+ initialRouterConfig : screenshotRouterConfig ,
9397 } ) ;
9498 renderGlobalModal ( ) ;
9599 await userEvent . click ( await screen . findByTestId ( 'screenshot-1' ) ) ;
@@ -98,9 +102,8 @@ describe('GroupEventAttachments', () => {
98102
99103 it ( 'links event id to event detail' , async ( ) => {
100104 render ( < GroupEventAttachments project = { project } group = { group } /> , {
101- router,
102105 organization,
103- deprecatedRouterMocks : true ,
106+ initialRouterConfig ,
104107 } ) ;
105108 expect ( await screen . findByRole ( 'link' , { name : '12345678' } ) ) . toHaveAttribute (
106109 'href' ,
@@ -110,9 +113,8 @@ describe('GroupEventAttachments', () => {
110113
111114 it ( 'links to the download URL' , async ( ) => {
112115 render ( < GroupEventAttachments project = { project } group = { group } /> , {
113- router : screenshotRouter ,
114116 organization,
115- deprecatedRouterMocks : true ,
117+ initialRouterConfig : screenshotRouterConfig ,
116118 } ) ;
117119 await userEvent . click ( await screen . findByLabelText ( 'Actions' ) ) ;
118120 expect (
@@ -126,9 +128,8 @@ describe('GroupEventAttachments', () => {
126128 statusCode : 500 ,
127129 } ) ;
128130 render ( < GroupEventAttachments project = { project } group = { group } /> , {
129- router,
130131 organization,
131- deprecatedRouterMocks : true ,
132+ initialRouterConfig ,
132133 } ) ;
133134 expect ( await screen . findByText ( / e r r o r l o a d i n g / i) ) . toBeInTheDocument ( ) ;
134135 } ) ;
@@ -139,9 +140,8 @@ describe('GroupEventAttachments', () => {
139140 method : 'DELETE' ,
140141 } ) ;
141142 render ( < GroupEventAttachments project = { project } group = { group } /> , {
142- router,
143143 organization,
144- deprecatedRouterMocks : true ,
144+ initialRouterConfig ,
145145 } ) ;
146146 renderGlobalModal ( ) ;
147147
@@ -169,13 +169,14 @@ describe('GroupEventAttachments', () => {
169169 render ( < GroupEventAttachments project = { project } group = { group } /> , {
170170 initialRouterConfig : {
171171 location : {
172- pathname : ' /organizations/org- slug/issues/group-id/' ,
172+ pathname : ` /organizations/${ organization . slug } /issues/${ groupId } /attachments/` ,
173173 query : {
174174 statsPeriod : '3d' ,
175175 query :
'user.email:[email protected] ' , 176176 environment : [ 'staging' ] ,
177177 } ,
178178 } ,
179+ route : `/organizations/:orgId/issues/:groupId/attachments/` ,
179180 } ,
180181 organization : { ...organization , features : [ 'issue-details-streamline-enforce' ] } ,
181182 } ) ;
0 commit comments