1
- import { act , cleanup , render , screen } from 'sentry-test/reactTestingLibrary' ;
1
+ import { act , render , screen } from 'sentry-test/reactTestingLibrary' ;
2
2
3
3
import ProjectsStore from 'sentry/stores/projectsStore' ;
4
- import { OrganizationContext } from 'sentry/views/organizationContext' ;
5
4
import EventDetails from 'sentry/views/performance/transactionDetails' ;
6
5
7
6
const alertText =
8
7
'You are viewing a sample transaction. Configure performance to start viewing real transactions.' ;
9
8
10
9
describe ( 'EventDetails' , ( ) => {
11
- afterEach ( cleanup ) ;
10
+ const project = TestStubs . Project ( ) ;
11
+ const organization = TestStubs . Organization ( {
12
+ features : [ 'performance-view' ] ,
13
+ projects : [ project ] ,
14
+ } ) ;
12
15
13
- it ( 'renders alert for sample transaction' , async ( ) => {
14
- const project = TestStubs . Project ( ) ;
16
+ beforeEach ( ( ) => {
15
17
ProjectsStore . loadInitialData ( [ project ] ) ;
16
- const organization = TestStubs . Organization ( {
17
- features : [ 'performance-view' ] ,
18
- projects : [ project ] ,
19
- } ) ;
20
- const event = TestStubs . Event ( ) ;
21
- event . tags . push ( { key : 'sample_event' , value : 'yes' } ) ;
22
- const routerContext = TestStubs . routerContext ( [ ] ) ;
23
-
24
18
MockApiClient . addMockResponse ( {
25
- url : `/projects /${ organization . slug } /latest/events/1/grouping-info /` ,
19
+ url : `/organizations /${ organization . slug } /projects /` ,
26
20
statusCode : 200 ,
27
- body : { } ,
21
+ body : [ ] ,
28
22
} ) ;
29
23
MockApiClient . addMockResponse ( {
30
- url : `/organizations /${ organization . slug } /projects /` ,
24
+ url : `/projects /${ organization . slug } /latest/events/1/grouping-info /` ,
31
25
statusCode : 200 ,
32
- body : [ ] ,
26
+ body : { } ,
33
27
} ) ;
34
28
MockApiClient . addMockResponse ( {
35
29
url : `/projects/${ organization . slug } /latest/events/1/committers/` ,
36
30
statusCode : 200 ,
37
31
body : [ ] ,
38
32
} ) ;
33
+ } ) ;
34
+
35
+ afterEach ( ( ) => {
36
+ ProjectsStore . reset ( ) ;
37
+ MockApiClient . clearMockResponses ( ) ;
38
+ } ) ;
39
+
40
+ it ( 'renders alert for sample transaction' , async ( ) => {
41
+ const event = TestStubs . Event ( ) ;
42
+ event . tags . push ( { key : 'sample_event' , value : 'yes' } ) ;
43
+
39
44
MockApiClient . addMockResponse ( {
40
45
url : `/organizations/${ organization . slug } /events/latest/` ,
41
46
statusCode : 200 ,
@@ -45,14 +50,10 @@ describe('EventDetails', () => {
45
50
} ) ;
46
51
47
52
render (
48
- < OrganizationContext . Provider value = { organization } >
49
- < EventDetails
50
- { ...TestStubs . routeComponentProps ( ) }
51
- organization = { organization }
52
- params = { { eventSlug : 'latest' } }
53
- location = { routerContext . context . location }
54
- />
55
- </ OrganizationContext . Provider >
53
+ < EventDetails
54
+ { ...TestStubs . routeComponentProps ( { params : { eventSlug : 'latest' } } ) }
55
+ /> ,
56
+ { organization}
56
57
) ;
57
58
expect ( screen . getByText ( alertText ) ) . toBeInTheDocument ( ) ;
58
59
@@ -61,14 +62,7 @@ describe('EventDetails', () => {
61
62
} ) ;
62
63
63
64
it ( 'does not reender alert if already received transaction' , async ( ) => {
64
- const project = TestStubs . Project ( ) ;
65
- ProjectsStore . loadInitialData ( [ project ] ) ;
66
- const organization = TestStubs . Organization ( {
67
- features : [ 'performance-view' ] ,
68
- projects : [ project ] ,
69
- } ) ;
70
65
const event = TestStubs . Event ( ) ;
71
- const routerContext = TestStubs . routerContext ( [ ] ) ;
72
66
73
67
MockApiClient . addMockResponse ( {
74
68
url : `/organizations/${ organization . slug } /events/latest/` ,
@@ -80,11 +74,9 @@ describe('EventDetails', () => {
80
74
81
75
render (
82
76
< EventDetails
83
- { ...TestStubs . routeComponentProps ( ) }
84
- organization = { organization }
85
- params = { { eventSlug : 'latest' } }
86
- location = { routerContext . context . location }
87
- />
77
+ { ...TestStubs . routeComponentProps ( { params : { eventSlug : 'latest' } } ) }
78
+ /> ,
79
+ { organization}
88
80
) ;
89
81
expect ( screen . queryByText ( alertText ) ) . not . toBeInTheDocument ( ) ;
90
82
0 commit comments