@@ -7,10 +7,14 @@ import {render, screen, userEvent, waitFor} from 'sentry-test/reactTestingLibrar
7
7
import type { PlatformKey } from 'sentry/types/project' ;
8
8
import ProjectCharts from 'sentry/views/projectDetail/projectCharts' ;
9
9
10
- function renderProjectCharts ( platform ?: PlatformKey , chartDisplay ?: string ) {
10
+ function renderProjectCharts (
11
+ platform ?: PlatformKey ,
12
+ chartDisplay ?: string ,
13
+ features ?: [ string ]
14
+ ) {
11
15
const { organization, router, project} = initializeOrg ( {
12
16
organization : OrganizationFixture ( ) ,
13
- projects : [ { platform} ] ,
17
+ projects : [ { platform, features } ] ,
14
18
router : {
15
19
params : { orgId : 'org-slug' , projectId : 'project-slug' } ,
16
20
location : {
@@ -76,6 +80,43 @@ describe('ProjectDetail > ProjectCharts', () => {
76
80
expect ( screen . getByText ( 'ANR Rate' ) ) . toBeInTheDocument ( ) ;
77
81
} ) ;
78
82
83
+ it ( 'renders App Hang options for apple projects when the feature flag is enabled' , async ( ) => {
84
+ renderProjectCharts ( 'apple' , undefined , [
85
+ 'projects:project-detail-apple-app-hang-rate' ,
86
+ ] ) ;
87
+
88
+ await userEvent . click (
89
+ screen . getByRole ( 'button' , { name : 'Display Crash Free Sessions' } )
90
+ ) ;
91
+
92
+ expect ( screen . getByText ( 'ANR Rate' ) ) . toBeInTheDocument ( ) ;
93
+ expect ( screen . queryByText ( 'Foreground ANR Rate' ) ) . not . toBeInTheDocument ( ) ;
94
+ } ) ;
95
+
96
+ it ( 'renders App Hang options for apple-ios projects when the feature flag is enabled' , async ( ) => {
97
+ renderProjectCharts ( 'apple-ios' , undefined , [
98
+ 'projects:project-detail-apple-app-hang-rate' ,
99
+ ] ) ;
100
+
101
+ await userEvent . click (
102
+ screen . getByRole ( 'button' , { name : 'Display Crash Free Sessions' } )
103
+ ) ;
104
+
105
+ expect ( screen . getByText ( 'ANR Rate' ) ) . toBeInTheDocument ( ) ;
106
+ expect ( screen . queryByText ( 'Foreground ANR Rate' ) ) . not . toBeInTheDocument ( ) ;
107
+ } ) ;
108
+
109
+ it ( 'does not render App Hang options for apple-ios projects when the feature flag is disabled' , async ( ) => {
110
+ renderProjectCharts ( 'apple-ios' , undefined ) ;
111
+
112
+ await userEvent . click (
113
+ screen . getByRole ( 'button' , { name : 'Display Crash Free Sessions' } )
114
+ ) ;
115
+
116
+ expect ( screen . queryByText ( 'ANR Rate' ) ) . not . toBeInTheDocument ( ) ;
117
+ expect ( screen . queryByText ( 'Foreground ANR Rate' ) ) . not . toBeInTheDocument ( ) ;
118
+ } ) ;
119
+
79
120
it ( 'does not render ANR options for non-compatible platforms' , async ( ) => {
80
121
renderProjectCharts ( 'python' ) ;
81
122
@@ -109,10 +150,7 @@ describe('ProjectDetail > ProjectCharts', () => {
109
150
groups : [
110
151
{
111
152
by : { } ,
112
- totals : {
113
- 'anr_rate()' : 492 ,
114
- 'count_unique(user)' : 3 ,
115
- } ,
153
+ totals : { 'anr_rate()' : 492 , 'count_unique(user)' : 3 } ,
116
154
series : {
117
155
'anr_rate()' : [ 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 2 , 490 ] ,
118
156
'count_unique(user)' : [ 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 2 , 1 ] ,
@@ -132,9 +170,7 @@ describe('ProjectDetail > ProjectCharts', () => {
132
170
expect ( mockSessions ) . toHaveBeenCalledWith (
133
171
'/organizations/org-slug/sessions/' ,
134
172
expect . objectContaining ( {
135
- query : expect . objectContaining ( {
136
- field : [ 'anr_rate()' , 'count_unique(user)' ] ,
137
- } ) ,
173
+ query : expect . objectContaining ( { field : [ 'anr_rate()' , 'count_unique(user)' ] } ) ,
138
174
} )
139
175
)
140
176
) ;
0 commit comments