@@ -17,8 +17,10 @@ import {
1717 type WorkspacesService ,
1818} from '@mongodb-js/compass-workspaces/provider' ;
1919import { MockDataGeneratorStep } from '../mock-data-generator-modal/types' ;
20- import { SCHEMA_ANALYSIS_STATE_COMPLETE } from '../../schema-analysis-types' ;
21- import { CompassExperimentationProvider } from '@mongodb-js/compass-telemetry' ;
20+ import {
21+ SCHEMA_ANALYSIS_STATE_COMPLETE ,
22+ SCHEMA_ANALYSIS_STATE_INITIAL ,
23+ } from '../../schema-analysis-types' ;
2224import type { ConnectionInfo } from '@mongodb-js/compass-connections/provider' ;
2325
2426import Sinon from 'sinon' ;
@@ -335,23 +337,6 @@ describe('CollectionHeader [Component]', function () {
335337 } ) ;
336338
337339 describe ( 'Mock Data Generator integration' , function ( ) {
338- let mockUseAssignment : Sinon . SinonStub ;
339-
340- beforeEach ( function ( ) {
341- // Mock the useAssignment hook from compass-experimentation
342- mockUseAssignment = Sinon . stub ( ) . returns ( {
343- assignment : {
344- assignmentData : {
345- variant : 'mockDataGeneratorVariant' ,
346- } ,
347- } ,
348- } ) ;
349- } ) ;
350-
351- afterEach ( function ( ) {
352- Sinon . restore ( ) ;
353- } ) ;
354-
355340 const atlasConnectionInfo : ConnectionInfo = {
356341 id : 'test-atlas-connection' ,
357342 connectionOptions : {
@@ -375,7 +360,7 @@ describe('CollectionHeader [Component]', function () {
375360 } ,
376361 } ;
377362
378- function renderCollectionHeaderWithExperimentation (
363+ function renderCollectionHeaderWithSchemaAnalysis (
379364 props : Partial < ComponentProps < typeof CollectionHeader > > = { } ,
380365 workspaceService : Partial < WorkspacesService > = { } ,
381366 stateOverrides : any = { } ,
@@ -392,33 +377,27 @@ describe('CollectionHeader [Component]', function () {
392377 const mockStore = createStore ( ( ) => defaultState ) ;
393378
394379 return renderWithActiveConnection (
395- < CompassExperimentationProvider
396- useAssignment = { mockUseAssignment }
397- assignExperiment = { Sinon . stub ( ) }
398- getAssignment = { Sinon . stub ( ) . resolves ( null ) }
399- >
400- < Provider store = { mockStore } >
401- < WorkspacesServiceProvider
402- value = { workspaceService as WorkspacesService }
403- >
404- < CollectionHeader
405- isAtlas = { false }
406- isReadonly = { false }
407- isTimeSeries = { false }
408- isClustered = { false }
409- isFLE = { false }
410- namespace = "test.test"
411- { ...props }
412- />
413- </ WorkspacesServiceProvider >
414- </ Provider >
415- </ CompassExperimentationProvider > ,
380+ < Provider store = { mockStore } >
381+ < WorkspacesServiceProvider
382+ value = { workspaceService as WorkspacesService }
383+ >
384+ < CollectionHeader
385+ isAtlas = { false }
386+ isReadonly = { false }
387+ isTimeSeries = { false }
388+ isClustered = { false }
389+ isFLE = { false }
390+ namespace = "test.test"
391+ { ...props }
392+ />
393+ </ WorkspacesServiceProvider >
394+ </ Provider > ,
416395 connectionInfo
417396 ) ;
418397 }
419398
420399 it ( 'should show Mock Data Generator button when all conditions are met' , async function ( ) {
421- await renderCollectionHeaderWithExperimentation (
400+ await renderCollectionHeaderWithSchemaAnalysis (
422401 {
423402 isAtlas : true , // Atlas environment
424403 isReadonly : false , // Not readonly
@@ -447,7 +426,7 @@ describe('CollectionHeader [Component]', function () {
447426 } ) ;
448427
449428 it ( 'should disable Mock Data Generator button when collection has no schema analysis data' , async function ( ) {
450- await renderCollectionHeaderWithExperimentation (
429+ await renderCollectionHeaderWithSchemaAnalysis (
451430 {
452431 isAtlas : true ,
453432 isReadonly : false ,
@@ -474,7 +453,7 @@ describe('CollectionHeader [Component]', function () {
474453 } ) ;
475454
476455 it ( 'should disable Mock Data Generator button for collections with excessive nesting depth' , async function ( ) {
477- await renderCollectionHeaderWithExperimentation (
456+ await renderCollectionHeaderWithSchemaAnalysis (
478457 {
479458 isAtlas : true ,
480459 isReadonly : false ,
@@ -503,7 +482,7 @@ describe('CollectionHeader [Component]', function () {
503482 } ) ;
504483
505484 it ( 'should not show Mock Data Generator button for readonly collections (views)' , async function ( ) {
506- await renderCollectionHeaderWithExperimentation (
485+ await renderCollectionHeaderWithSchemaAnalysis (
507486 {
508487 isAtlas : true ,
509488 isReadonly : true , // Readonly (view)
@@ -530,7 +509,7 @@ describe('CollectionHeader [Component]', function () {
530509 } ) ;
531510
532511 it ( 'should not show Mock Data Generator button in non-Atlas environments' , async function ( ) {
533- await renderCollectionHeaderWithExperimentation (
512+ await renderCollectionHeaderWithSchemaAnalysis (
534513 {
535514 isAtlas : false , // Not Atlas
536515 isReadonly : false ,
@@ -556,16 +535,8 @@ describe('CollectionHeader [Component]', function () {
556535 ) . to . not . exist ;
557536 } ) ;
558537
559- it ( 'should not show Mock Data Generator button when not in treatment variant' , async function ( ) {
560- mockUseAssignment . returns ( {
561- assignment : {
562- assignmentData : {
563- variant : 'control' ,
564- } ,
565- } ,
566- } ) ;
567-
568- await renderCollectionHeaderWithExperimentation (
538+ it ( 'should not show Mock Data Generator button when schema analysis has not run' , async function ( ) {
539+ await renderCollectionHeaderWithSchemaAnalysis (
569540 {
570541 isAtlas : true ,
571542 isReadonly : false ,
@@ -574,13 +545,7 @@ describe('CollectionHeader [Component]', function () {
574545 { } ,
575546 {
576547 schemaAnalysis : {
577- status : SCHEMA_ANALYSIS_STATE_COMPLETE ,
578- processedSchema : {
579- field1 : { type : 'String' , sample_values : [ 'value1' ] } ,
580- } ,
581- schemaMetadata : {
582- maxNestingDepth : 2 ,
583- } ,
548+ status : SCHEMA_ANALYSIS_STATE_INITIAL , // No schema analysis has run
584549 } ,
585550 } ,
586551 atlasConnectionInfo
0 commit comments