@@ -12,22 +12,7 @@ describe('groupEventDetails', () => {
12
12
let group ;
13
13
let event ;
14
14
15
- beforeEach ( ( ) => {
16
- const props = initializeOrg ( ) ;
17
- org = props . organization ;
18
- project = props . project ;
19
- project . organization = org ;
20
- routerContext = props . routerContext ;
21
-
22
- group = TestStubs . Group ( ) ;
23
- event = TestStubs . Event ( {
24
- size : 1 ,
25
- dateCreated : '2019-03-20T00:00:00.000Z' ,
26
- errors : [ ] ,
27
- entries : [ ] ,
28
- tags : [ { key : 'environment' , value : 'dev' } ] ,
29
- } ) ;
30
-
15
+ const mockGroupApis = ( ) => {
31
16
MockApiClient . addMockResponse ( {
32
17
url : `/issues/${ group . id } /` ,
33
18
body : group ,
@@ -67,12 +52,36 @@ describe('groupEventDetails', () => {
67
52
url : `/groups/${ group . id } /integrations/` ,
68
53
body : [ ] ,
69
54
} ) ;
55
+ } ;
56
+
57
+ beforeEach ( ( ) => {
58
+ const props = initializeOrg ( ) ;
59
+ org = props . organization ;
60
+ project = props . project ;
61
+ project . organization = org ;
62
+ routerContext = props . routerContext ;
63
+
64
+ group = TestStubs . Group ( ) ;
65
+ event = TestStubs . Event ( {
66
+ size : 1 ,
67
+ dateCreated : '2019-03-20T00:00:00.000Z' ,
68
+ errors : [ ] ,
69
+ entries : [ ] ,
70
+ tags : [ { key : 'environment' , value : 'dev' } ] ,
71
+ } ) ;
72
+
73
+ mockGroupApis ( ) ;
70
74
71
75
MockApiClient . addMockResponse ( {
72
76
url : '/sentry-apps/' ,
73
77
body : [ ] ,
74
78
} ) ;
75
79
80
+ MockApiClient . addMockResponse ( {
81
+ url : `/organizations/${ org . slug } /sentry-apps/` ,
82
+ body : [ ] ,
83
+ } ) ;
84
+
76
85
MockApiClient . addMockResponse ( {
77
86
url : `/organizations/${ org . slug } /sentry-app-installations/` ,
78
87
body : [ ] ,
@@ -192,49 +201,99 @@ describe('groupEventDetails', () => {
192
201
} ) ;
193
202
} ) ;
194
203
195
- it ( 'loads Sentry Apps' , ( ) => {
196
- const request = MockApiClient . addMockResponse ( {
197
- url : '/sentry-apps/' ,
198
- body : [ ] ,
204
+ describe ( 'Platform Integrations' , ( ) => {
205
+ let wrapper ; // eslint-disable-line
206
+ let integrationsRequest ;
207
+ let orgIntegrationsRequest ;
208
+ let componentsRequest ;
209
+
210
+ const mountWrapper = ( ) => {
211
+ return mount (
212
+ < GroupEventDetails
213
+ group = { group }
214
+ project = { project }
215
+ organization = { org }
216
+ environments = { [ { id : '1' , name : 'dev' , displayName : 'Dev' } ] }
217
+ params = { { orgId : org . slug , groupId : group . id , eventId : '1' } }
218
+ location = { { query : { environment : 'dev' } } }
219
+ /> ,
220
+ routerContext
221
+ ) ;
222
+ } ;
223
+
224
+ beforeEach ( ( ) => {
225
+ const integration = TestStubs . SentryApp ( ) ;
226
+ const unpublishedIntegration = TestStubs . SentryApp ( { status : 'unpublished' } ) ;
227
+ const internalIntegration = TestStubs . SentryApp ( { status : 'internal' } ) ;
228
+
229
+ const unpublishedInstall = TestStubs . SentryAppInstallation ( {
230
+ app : {
231
+ slug : unpublishedIntegration . slug ,
232
+ uuid : unpublishedIntegration . uuid ,
233
+ } ,
234
+ } ) ;
235
+
236
+ const internalInstall = TestStubs . SentryAppInstallation ( {
237
+ app : {
238
+ slug : internalIntegration . slug ,
239
+ uuid : internalIntegration . uuid ,
240
+ } ,
241
+ } ) ;
242
+
243
+ const component = TestStubs . SentryAppComponent ( {
244
+ sentryApp : {
245
+ uuid : unpublishedIntegration . uuid ,
246
+ slug : unpublishedIntegration . slug ,
247
+ name : unpublishedIntegration . name ,
248
+ } ,
249
+ } ) ;
250
+
251
+ MockApiClient . clearMockResponses ( ) ;
252
+ mockGroupApis ( ) ;
253
+
254
+ MockApiClient . addMockResponse ( {
255
+ url : `/projects/${ org . slug } /${ project . slug } /events/1/` ,
256
+ body : event ,
257
+ } ) ;
258
+
259
+ componentsRequest = MockApiClient . addMockResponse ( {
260
+ url : `/organizations/${ org . slug } /sentry-app-components/?projectId=${ project . id } ` ,
261
+ body : [ component ] ,
262
+ } ) ;
263
+
264
+ MockApiClient . addMockResponse ( {
265
+ url : `/projects/${ org . slug } /${ project . slug } /events/1/` ,
266
+ body : event ,
267
+ } ) ;
268
+
269
+ integrationsRequest = MockApiClient . addMockResponse ( {
270
+ url : '/sentry-apps/' ,
271
+ body : [ integration ] ,
272
+ } ) ;
273
+
274
+ MockApiClient . addMockResponse ( {
275
+ url : `/organizations/${ org . slug } /sentry-app-installations/` ,
276
+ body : [ unpublishedInstall , internalInstall ] ,
277
+ } ) ;
278
+
279
+ orgIntegrationsRequest = MockApiClient . addMockResponse ( {
280
+ url : `/organizations/${ org . slug } /sentry-apps/` ,
281
+ body : [ unpublishedIntegration , internalIntegration ] ,
282
+ } ) ;
283
+
284
+ wrapper = mountWrapper ( ) ;
199
285
} ) ;
200
286
201
- project . organization = org ;
202
-
203
- mount (
204
- < GroupEventDetails
205
- group = { group }
206
- project = { project }
207
- organization = { org }
208
- environments = { [ { id : '1' , name : 'dev' , displayName : 'Dev' } ] }
209
- params = { { } }
210
- location = { { } }
211
- /> ,
212
- routerContext
213
- ) ;
214
-
215
- expect ( request ) . toHaveBeenCalledTimes ( 1 ) ;
216
- } ) ;
217
-
218
- it ( 'loads sentry app components when flagged in' , ( ) => {
219
- const request = MockApiClient . addMockResponse ( {
220
- url : `/organizations/${ org . slug } /sentry-app-components/?projectId=${ project . id } ` ,
221
- body : [ ] ,
287
+ it ( 'loads Integrations' , ( ) => {
288
+ expect ( integrationsRequest ) . toHaveBeenCalled ( ) ;
222
289
} ) ;
223
290
224
- project . organization = org ;
225
-
226
- mount (
227
- < GroupEventDetails
228
- group = { group }
229
- project = { project }
230
- organization = { org }
231
- environments = { [ { id : '1' , name : 'dev' , displayName : 'Dev' } ] }
232
- params = { { } }
233
- location = { { } }
234
- /> ,
235
- routerContext
236
- ) ;
291
+ it ( 'loads unpublished and internal Integrations' , ( ) => {
292
+ expect ( orgIntegrationsRequest ) . toHaveBeenCalled ( ) ;
293
+ } ) ;
237
294
238
- expect ( request ) . toHaveBeenCalledTimes ( 1 ) ;
295
+ it ( 'loads Integration UI components' , ( ) => {
296
+ expect ( componentsRequest ) . toHaveBeenCalled ( ) ;
297
+ } ) ;
239
298
} ) ;
240
299
} ) ;
0 commit comments