@@ -48,6 +48,7 @@ describe('CollectionHeaderActions [Component]', function () {
48
48
< CompassExperimentationProvider
49
49
useAssignment = { mockUseAssignment }
50
50
assignExperiment = { sinon . stub ( ) }
51
+ getAssignment = { sinon . stub ( ) . resolves ( null ) }
51
52
>
52
53
< WorkspacesServiceProvider
53
54
value = { workspaceService as WorkspacesService }
@@ -57,6 +58,9 @@ describe('CollectionHeaderActions [Component]', function () {
57
58
namespace = "test.test"
58
59
isReadonly = { false }
59
60
onOpenMockDataModal = { sinon . stub ( ) }
61
+ hasSchemaAnalysisData = { true }
62
+ analyzedSchemaDepth = { 2 }
63
+ schemaAnalysisStatus = "complete"
60
64
{ ...props }
61
65
/>
62
66
</ PreferencesProvider >
@@ -221,97 +225,21 @@ describe('CollectionHeaderActions [Component]', function () {
221
225
} ,
222
226
} ;
223
227
224
- it ( 'should not show Mock Data Generator button when user is in control group' , async function ( ) {
225
- mockUseAssignment . returns ( {
226
- assignment : {
227
- assignmentData : {
228
- variant : 'mockDataGeneratorControl' ,
229
- } ,
230
- } ,
231
- } ) ;
232
-
233
- await renderCollectionHeaderActions (
234
- {
235
- namespace : 'test.collection' ,
236
- isReadonly : false ,
237
- } ,
238
- { } ,
239
- atlasConnectionInfo
240
- ) ;
241
-
242
- expect (
243
- screen . queryByTestId ( 'collection-header-generate-mock-data-button' )
244
- ) . to . not . exist ;
245
- } ) ;
246
-
247
- it ( 'should not show Mock Data Generator button when not in Atlas' , async function ( ) {
248
- mockUseAssignment . returns ( {
249
- assignment : {
250
- assignmentData : {
251
- variant : 'treatment' ,
252
- } ,
253
- } ,
254
- } ) ;
255
-
228
+ it ( 'should call useAssignment with correct parameters' , async function ( ) {
256
229
await renderCollectionHeaderActions ( {
257
230
namespace : 'test.collection' ,
258
231
isReadonly : false ,
259
- // Don't pass atlasConnectionInfo, to simulate not being in Atlas
260
232
} ) ;
261
233
262
- expect (
263
- screen . queryByTestId ( 'collection-header-generate-mock-data-button' )
264
- ) . to . not . exist ;
265
- } ) ;
266
-
267
- it ( 'should not show Mock Data Generator button for readonly collections' , async function ( ) {
268
- mockUseAssignment . returns ( {
269
- assignment : {
270
- assignmentData : {
271
- variant : 'treatment' ,
272
- } ,
273
- } ,
274
- } ) ;
275
-
276
- await renderCollectionHeaderActions (
277
- {
278
- namespace : 'test.collection' ,
279
- isReadonly : true ,
280
- } ,
281
- { } ,
282
- atlasConnectionInfo
234
+ expect ( mockUseAssignment ) . to . have . been . calledWith (
235
+ ExperimentTestName . mockDataGenerator ,
236
+ true // trackIsInSample - Experiment viewed analytics event
283
237
) ;
284
-
285
- expect (
286
- screen . queryByTestId ( 'collection-header-generate-mock-data-button' )
287
- ) . to . not . exist ;
288
238
} ) ;
289
239
290
- it ( 'should not show Mock Data Generator button for views (sourceName present)' , async function ( ) {
291
- mockUseAssignment . returns ( {
292
- assignment : {
293
- assignmentData : {
294
- variant : 'treatment' ,
295
- } ,
296
- } ,
297
- } ) ;
298
-
299
- await renderCollectionHeaderActions (
300
- {
301
- namespace : 'test.collection' ,
302
- isReadonly : false ,
303
- sourceName : 'source-collection' ,
304
- } ,
305
- { } ,
306
- atlasConnectionInfo
307
- ) ;
308
-
309
- expect (
310
- screen . queryByTestId ( 'collection-header-generate-mock-data-button' )
311
- ) . to . not . exist ;
312
- } ) ;
240
+ it ( 'should call onOpenMockDataModal when CTA button is clicked' , async function ( ) {
241
+ const onOpenMockDataModal = sinon . stub ( ) ;
313
242
314
- it ( 'should show Mock Data Generator button when user is in treatment group and in Atlas' , async function ( ) {
315
243
mockUseAssignment . returns ( {
316
244
assignment : {
317
245
assignmentData : {
@@ -324,35 +252,25 @@ describe('CollectionHeaderActions [Component]', function () {
324
252
{
325
253
namespace : 'test.collection' ,
326
254
isReadonly : false ,
255
+ onOpenMockDataModal,
327
256
} ,
328
257
{ } ,
329
258
atlasConnectionInfo
330
259
) ;
331
260
332
- expect (
333
- screen . getByTestId ( 'collection-header-generate-mock-data-button' )
334
- ) . to . exist ;
335
- } ) ;
336
-
337
- it ( 'should call useAssignment with correct parameters' , async function ( ) {
338
- await renderCollectionHeaderActions ( {
339
- namespace : 'test.collection' ,
340
- isReadonly : false ,
341
- } ) ;
342
-
343
- expect ( mockUseAssignment ) . to . have . been . calledWith (
344
- ExperimentTestName . mockDataGenerator ,
345
- true // trackIsInSample - Experiment viewed analytics event
261
+ const button = screen . getByTestId (
262
+ 'collection-header-generate-mock-data-button'
346
263
) ;
347
- } ) ;
264
+ button . click ( ) ;
348
265
349
- it ( 'should call onOpenMockDataModal when CTA button is clicked' , async function ( ) {
350
- const onOpenMockDataModal = sinon . stub ( ) ;
266
+ expect ( onOpenMockDataModal ) . to . have . been . calledOnce ;
267
+ } ) ;
351
268
269
+ it ( 'should disable button for deeply nested collections' , async function ( ) {
352
270
mockUseAssignment . returns ( {
353
271
assignment : {
354
272
assignmentData : {
355
- variant : 'mockDataGeneratorVariant' ,
273
+ variant : 'mockDataGeneratorVariant' , // Treatment variant
356
274
} ,
357
275
} ,
358
276
} ) ;
@@ -361,7 +279,10 @@ describe('CollectionHeaderActions [Component]', function () {
361
279
{
362
280
namespace : 'test.collection' ,
363
281
isReadonly : false ,
364
- onOpenMockDataModal,
282
+ hasSchemaAnalysisData : true ,
283
+ analyzedSchemaDepth : 5 , // Exceeds MAX_COLLECTION_NESTING_DEPTH (3)
284
+ schemaAnalysisStatus : 'complete' ,
285
+ onOpenMockDataModal : sinon . stub ( ) ,
365
286
} ,
366
287
{ } ,
367
288
atlasConnectionInfo
@@ -370,9 +291,8 @@ describe('CollectionHeaderActions [Component]', function () {
370
291
const button = screen . getByTestId (
371
292
'collection-header-generate-mock-data-button'
372
293
) ;
373
- button . click ( ) ;
374
-
375
- expect ( onOpenMockDataModal ) . to . have . been . calledOnce ;
294
+ expect ( button ) . to . exist ;
295
+ expect ( button ) . to . have . attribute ( 'aria-disabled' , 'true' ) ;
376
296
} ) ;
377
297
} ) ;
378
298
} ) ;
0 commit comments