@@ -112,13 +112,13 @@ describe('PrimaryNavigationQuotaExceeded', function () {
112
112
) . toBe ( 'Mon Jun 06 2022' ) ;
113
113
}
114
114
115
- it ( 'should render' , async function ( ) {
115
+ it ( 'should render for multiple categories ' , async function ( ) {
116
116
render ( < PrimaryNavigationQuotaExceeded organization = { organization } /> ) ;
117
117
118
118
// open the alert
119
119
await userEvent . click ( await screen . findByRole ( 'button' , { name : 'Billing Status' } ) ) ;
120
- expect ( await screen . findByText ( 'Quota Exceeded' ) ) . toBeInTheDocument ( ) ;
121
- // doesn't show categories with <1 reserved tier and no PAYG
120
+ expect ( await screen . findByText ( 'Quotas Exceeded' ) ) . toBeInTheDocument ( ) ;
121
+ // doesn't show categories with <= 1 reserved tier and no PAYG
122
122
expect (
123
123
screen . getByText (
124
124
/ Y o u ’ v e r u n o u t o f e r r o r s , r e p l a y s , a n d s p a n s f o r t h i s b i l l i n g c y c l e ./
@@ -129,6 +129,47 @@ describe('PrimaryNavigationQuotaExceeded', function () {
129
129
expect ( screen . getByRole ( 'checkbox' ) ) . not . toBeChecked ( ) ;
130
130
} ) ;
131
131
132
+ it ( 'should render for single category' , async function ( ) {
133
+ const newSub = SubscriptionFixture ( {
134
+ organization,
135
+ plan : 'am3_team' ,
136
+ } ) ;
137
+ newSub . categories . errors ! . usageExceeded = true ;
138
+ newSub . categories . monitorSeats ! . usageExceeded = true ;
139
+ SubscriptionStore . set ( organization . slug , newSub ) ;
140
+ localStorage . setItem (
141
+ `billing-status-last-shown-categories-${ organization . id } ` ,
142
+ 'errors' // exceeded categories
143
+ ) ;
144
+ render ( < PrimaryNavigationQuotaExceeded organization = { organization } /> ) ;
145
+
146
+ // open the alert
147
+ await userEvent . click ( await screen . findByRole ( 'button' , { name : 'Billing Status' } ) ) ;
148
+
149
+ expect ( await screen . findByText ( 'Error Quota Exceeded' ) ) . toBeInTheDocument ( ) ;
150
+ expect (
151
+ screen . getByText ( / Y o u ’ v e r u n o u t o f e r r o r s f o r t h i s b i l l i n g c y c l e ./ )
152
+ ) . toBeInTheDocument ( ) ; // doesn't show categories with <=1 reserved tier and no PAYG
153
+ expect ( screen . getByRole ( 'checkbox' ) ) . not . toBeChecked ( ) ;
154
+ } ) ;
155
+
156
+ it ( 'should not render for zero categories' , function ( ) {
157
+ const newSub = SubscriptionFixture ( {
158
+ organization,
159
+ plan : 'am3_team' ,
160
+ } ) ;
161
+ // these categories are PAYG categories and there is no PAYG, so they should not trigger the alert
162
+ newSub . categories . monitorSeats ! . usageExceeded = true ;
163
+ newSub . categories . profileDuration ! . usageExceeded = true ;
164
+ SubscriptionStore . set ( organization . slug , newSub ) ;
165
+ localStorage . clear ( ) ;
166
+ render ( < PrimaryNavigationQuotaExceeded organization = { organization } /> ) ;
167
+ expect (
168
+ screen . queryByRole ( 'button' , { name : 'Billing Status' } )
169
+ ) . not . toBeInTheDocument ( ) ;
170
+ expect ( screen . queryByText ( 'Quotas Exceeded' ) ) . not . toBeInTheDocument ( ) ;
171
+ } ) ;
172
+
132
173
it ( 'should render PAYG categories when there is shared PAYG' , async function ( ) {
133
174
localStorage . setItem (
134
175
`billing-status-last-shown-categories-${ organization . id } ` ,
@@ -140,7 +181,7 @@ describe('PrimaryNavigationQuotaExceeded', function () {
140
181
141
182
// open the alert
142
183
await userEvent . click ( await screen . findByRole ( 'button' , { name : 'Billing Status' } ) ) ;
143
- expect ( await screen . findByText ( 'Quota Exceeded' ) ) . toBeInTheDocument ( ) ;
184
+ expect ( await screen . findByText ( 'Quotas Exceeded' ) ) . toBeInTheDocument ( ) ;
144
185
expect (
145
186
screen . getByText (
146
187
/ Y o u ’ v e r u n o u t o f e r r o r s , r e p l a y s , s p a n s , c r o n m o n i t o r s , a n d c o n t i n u o u s p r o f i l e h o u r s f o r t h i s b i l l i n g c y c l e ./
@@ -177,7 +218,7 @@ describe('PrimaryNavigationQuotaExceeded', function () {
177
218
178
219
// open the alert
179
220
await userEvent . click ( await screen . findByRole ( 'button' , { name : 'Billing Status' } ) ) ;
180
- expect ( await screen . findByText ( 'Quota Exceeded' ) ) . toBeInTheDocument ( ) ;
221
+ expect ( await screen . findByText ( 'Quotas Exceeded' ) ) . toBeInTheDocument ( ) ;
181
222
expect (
182
223
screen . getByText (
183
224
/ Y o u ’ v e r u n o u t o f e r r o r s , r e p l a y s , s p a n s , a n d c r o n m o n i t o r s f o r t h i s b i l l i n g c y c l e ./
@@ -197,7 +238,7 @@ describe('PrimaryNavigationQuotaExceeded', function () {
197
238
expect (
198
239
screen . queryByRole ( 'button' , { name : 'Billing Status' } )
199
240
) . not . toBeInTheDocument ( ) ;
200
- expect ( screen . queryByText ( 'Quota Exceeded' ) ) . not . toBeInTheDocument ( ) ;
241
+ expect ( screen . queryByText ( 'Quotas Exceeded' ) ) . not . toBeInTheDocument ( ) ;
201
242
202
243
// reset
203
244
subscription . canSelfServe = true ;
@@ -208,7 +249,7 @@ describe('PrimaryNavigationQuotaExceeded', function () {
208
249
209
250
// open the alert
210
251
await userEvent . click ( await screen . findByRole ( 'button' , { name : 'Billing Status' } ) ) ;
211
- expect ( await screen . findByText ( 'Quota Exceeded' ) ) . toBeInTheDocument ( ) ;
252
+ expect ( await screen . findByText ( 'Quotas Exceeded' ) ) . toBeInTheDocument ( ) ;
212
253
213
254
// stop the alert from animating
214
255
await userEvent . click ( screen . getByRole ( 'checkbox' ) ) ;
@@ -220,7 +261,7 @@ describe('PrimaryNavigationQuotaExceeded', function () {
220
261
221
262
// open the alert
222
263
await userEvent . click ( await screen . findByRole ( 'button' , { name : 'Billing Status' } ) ) ;
223
- expect ( await screen . findByText ( 'Quota Exceeded' ) ) . toBeInTheDocument ( ) ;
264
+ expect ( await screen . findByText ( 'Quotas Exceeded' ) ) . toBeInTheDocument ( ) ;
224
265
expect ( screen . getByText ( 'Request Additional Quota' ) ) . toBeInTheDocument ( ) ;
225
266
226
267
// click the button
@@ -235,11 +276,12 @@ describe('PrimaryNavigationQuotaExceeded', function () {
235
276
organization,
236
277
plan : 'am3_f' ,
237
278
} ) ;
279
+ freeSub . categories . errors ! . usageExceeded = true ;
238
280
freeSub . categories . replays ! . usageExceeded = true ;
239
281
SubscriptionStore . set ( organization . slug , freeSub ) ;
240
282
localStorage . setItem (
241
283
`billing-status-last-shown-categories-${ organization . id } ` ,
242
- 'replays'
284
+ 'errors- replays'
243
285
) ;
244
286
MockApiClient . addMockResponse ( {
245
287
method : 'GET' ,
@@ -251,12 +293,12 @@ describe('PrimaryNavigationQuotaExceeded', function () {
251
293
252
294
// open the alert
253
295
await userEvent . click ( await screen . findByRole ( 'button' , { name : 'Billing Status' } ) ) ;
254
- expect ( await screen . findByText ( 'Quota Exceeded' ) ) . toBeInTheDocument ( ) ;
296
+ expect ( await screen . findByText ( 'Quotas Exceeded' ) ) . toBeInTheDocument ( ) ;
255
297
expect ( screen . getByText ( 'Start Trial' ) ) . toBeInTheDocument ( ) ;
256
298
257
299
// click the button
258
300
await userEvent . click ( screen . getByText ( 'Start Trial' ) ) ;
259
- expect ( promptMock ) . toHaveBeenCalledTimes ( 1 ) ;
301
+ expect ( promptMock ) . toHaveBeenCalledTimes ( 2 ) ;
260
302
expect ( customerPutMock ) . toHaveBeenCalled ( ) ;
261
303
} ) ;
262
304
@@ -265,14 +307,14 @@ describe('PrimaryNavigationQuotaExceeded', function () {
265
307
expect (
266
308
await screen . findByRole ( 'button' , { name : 'Billing Status' } )
267
309
) . toBeInTheDocument ( ) ;
268
- expect ( screen . queryByText ( 'Quota Exceeded' ) ) . not . toBeInTheDocument ( ) ;
310
+ expect ( screen . queryByText ( 'Quotas Exceeded' ) ) . not . toBeInTheDocument ( ) ;
269
311
270
312
localStorage . clear ( ) ;
271
313
render ( < PrimaryNavigationQuotaExceeded organization = { organization } /> ) ;
272
314
expect (
273
315
await screen . findByRole ( 'button' , { name : 'Billing Status' } )
274
316
) . toBeInTheDocument ( ) ;
275
- expect ( await screen . findByText ( 'Quota Exceeded' ) ) . toBeInTheDocument ( ) ;
317
+ expect ( await screen . findByText ( 'Quotas Exceeded' ) ) . toBeInTheDocument ( ) ;
276
318
assertLocalStorageStateAfterAutoOpen ( ) ;
277
319
} ) ;
278
320
@@ -298,15 +340,15 @@ describe('PrimaryNavigationQuotaExceeded', function () {
298
340
expect (
299
341
await screen . findByRole ( 'button' , { name : 'Billing Status' } )
300
342
) . toBeInTheDocument ( ) ;
301
- expect ( screen . queryByText ( 'Quota Exceeded' ) ) . not . toBeInTheDocument ( ) ;
343
+ expect ( screen . queryByText ( 'Quotas Exceeded' ) ) . not . toBeInTheDocument ( ) ;
302
344
303
345
// even when localStorage is cleared, the alert should not show
304
346
localStorage . clear ( ) ;
305
347
render ( < PrimaryNavigationQuotaExceeded organization = { organization } /> ) ;
306
348
expect (
307
349
await screen . findByRole ( 'button' , { name : 'Billing Status' } )
308
350
) . toBeInTheDocument ( ) ;
309
- expect ( screen . queryByText ( 'Quota Exceeded' ) ) . not . toBeInTheDocument ( ) ;
351
+ expect ( screen . queryByText ( 'Quotas Exceeded' ) ) . not . toBeInTheDocument ( ) ;
310
352
expect ( localStorage ) . toHaveLength ( 0 ) ;
311
353
} ) ;
312
354
@@ -330,19 +372,19 @@ describe('PrimaryNavigationQuotaExceeded', function () {
330
372
} ) ;
331
373
localStorage . clear ( ) ;
332
374
render ( < PrimaryNavigationQuotaExceeded organization = { organization } /> ) ;
333
- expect ( await screen . findByText ( 'Quota Exceeded' ) ) . toBeInTheDocument ( ) ;
375
+ expect ( await screen . findByText ( 'Quotas Exceeded' ) ) . toBeInTheDocument ( ) ;
334
376
} ) ;
335
377
336
378
it ( 'should auto open the alert when categories have changed' , async function ( ) {
337
379
render ( < PrimaryNavigationQuotaExceeded organization = { organization } /> ) ;
338
- expect ( screen . queryByText ( 'Quota Exceeded' ) ) . not . toBeInTheDocument ( ) ;
380
+ expect ( screen . queryByText ( 'Quotas Exceeded' ) ) . not . toBeInTheDocument ( ) ;
339
381
340
382
localStorage . setItem (
341
383
`billing-status-last-shown-categories-${ organization . id } ` ,
342
384
'errors-replays'
343
385
) ; // spans not included, so alert should show even though last opened "today"
344
386
render ( < PrimaryNavigationQuotaExceeded organization = { organization } /> ) ;
345
- expect ( await screen . findByText ( 'Quota Exceeded' ) ) . toBeInTheDocument ( ) ;
387
+ expect ( await screen . findByText ( 'Quotas Exceeded' ) ) . toBeInTheDocument ( ) ;
346
388
assertLocalStorageStateAfterAutoOpen ( ) ;
347
389
} ) ;
348
390
@@ -352,7 +394,7 @@ describe('PrimaryNavigationQuotaExceeded', function () {
352
394
'Sun Jun 05 2022'
353
395
) ; // more than a day, so alert should show even though categories haven't changed
354
396
render ( < PrimaryNavigationQuotaExceeded organization = { organization } /> ) ;
355
- expect ( await screen . findByText ( 'Quota Exceeded' ) ) . toBeInTheDocument ( ) ;
397
+ expect ( await screen . findByText ( 'Quotas Exceeded' ) ) . toBeInTheDocument ( ) ;
356
398
assertLocalStorageStateAfterAutoOpen ( ) ;
357
399
} ) ;
358
400
@@ -362,7 +404,7 @@ describe('PrimaryNavigationQuotaExceeded', function () {
362
404
'Sun May 29 2022'
363
405
) ; // last seen before current usage cycle started, so alert should show even though categories haven't changed
364
406
render ( < PrimaryNavigationQuotaExceeded organization = { organization } /> ) ;
365
- expect ( await screen . findByText ( 'Quota Exceeded' ) ) . toBeInTheDocument ( ) ;
407
+ expect ( await screen . findByText ( 'Quotas Exceeded' ) ) . toBeInTheDocument ( ) ;
366
408
assertLocalStorageStateAfterAutoOpen ( ) ;
367
409
} ) ;
368
410
} ) ;
0 commit comments