@@ -538,8 +538,8 @@ describe('MockDataGeneratorModal', () => {
538538 ) ;
539539 } ) ;
540540
541- it ( 'does not show faker args that are too large ' , async ( ) => {
542- const largeLengthArgs = Array . from ( { length : 11 } , ( ) => 'test ' ) ;
541+ it ( 'displays preview of the faker call without args when the args are invalid ' , async ( ) => {
542+ const largeLengthArgs = Array . from ( { length : 11 } , ( ) => 'testArg ' ) ;
543543 const mockServices = createMockServices ( ) ;
544544 mockServices . atlasAiService . getMockDataSchema = ( ) =>
545545 Promise . resolve ( {
@@ -548,7 +548,45 @@ describe('MockDataGeneratorModal', () => {
548548 fieldPath : 'name' ,
549549 mongoType : 'String' ,
550550 fakerMethod : 'person.firstName' ,
551- fakerArgs : [ JSON . stringify ( largeLengthArgs ) ] ,
551+ fakerArgs : largeLengthArgs ,
552+ isArray : false ,
553+ probability : 1.0 ,
554+ } ,
555+ {
556+ fieldPath : 'age' ,
557+ mongoType : 'Int32' ,
558+ fakerMethod : 'number.int' ,
559+ fakerArgs : [
560+ {
561+ json : JSON . stringify ( {
562+ a : largeLengthArgs ,
563+ } ) ,
564+ } ,
565+ ] ,
566+ isArray : false ,
567+ probability : 1.0 ,
568+ } ,
569+ {
570+ fieldPath : 'username' ,
571+ mongoType : 'String' ,
572+ fakerMethod : 'string.alpha' ,
573+ // large string
574+ fakerArgs : [ 'a' . repeat ( 1001 ) ] ,
575+ isArray : false ,
576+ probability : 1.0 ,
577+ } ,
578+ {
579+ fieldPath : 'avatar' ,
580+ mongoType : 'String' ,
581+ fakerMethod : 'image.url' ,
582+ fakerArgs : [
583+ {
584+ json : JSON . stringify ( {
585+ width : 100_000 ,
586+ height : 100_000 ,
587+ } ) ,
588+ } ,
589+ ] ,
552590 isArray : false ,
553591 probability : 1.0 ,
554592 } ,
@@ -564,8 +602,19 @@ describe('MockDataGeneratorModal', () => {
564602 type : 'String' ,
565603 probability : 1.0 ,
566604 } ,
605+ age : {
606+ type : 'Int32' ,
607+ probability : 1.0 ,
608+ } ,
609+ username : {
610+ type : 'String' ,
611+ probability : 1.0 ,
612+ } ,
613+ avatar : {
614+ type : 'String' ,
615+ probability : 1.0 ,
616+ } ,
567617 } ,
568- sampleDocument : { name : 'Peaches' } ,
569618 } ,
570619 } ) ;
571620
@@ -574,6 +623,24 @@ describe('MockDataGeneratorModal', () => {
574623 await waitFor ( ( ) => {
575624 expect ( screen . getByTestId ( 'faker-schema-editor' ) ) . to . exist ;
576625 } ) ;
626+
627+ userEvent . click ( screen . getByText ( 'name' ) ) ;
628+ expect ( screen . getByTestId ( 'faker-function-call-preview' ) ) . to . exist ;
629+ expect ( screen . queryByText ( / t e s t A r g / ) ) . to . not . exist ;
630+
631+ userEvent . click ( screen . getByText ( 'age' ) ) ;
632+ expect ( screen . getByTestId ( 'faker-function-call-preview' ) ) . to . exist ;
633+ expect ( screen . queryByText ( / t e s t A r g / ) ) . to . not . exist ;
634+
635+ userEvent . click ( screen . getByText ( 'username' ) ) ;
636+ expect ( screen . queryByText ( / a a a a a a a / ) ) . to . not . exist ;
637+ expect ( screen . getByTestId ( 'faker-function-call-preview' ) ) . to . exist ;
638+
639+ userEvent . click ( screen . getByText ( 'avatar' ) ) ;
640+ expect ( screen . getByTestId ( 'faker-function-call-preview' ) ) . to . exist ;
641+ expect ( screen . queryByText ( / w i d t h / ) ) . to . not . exist ;
642+ expect ( screen . queryByText ( / h e i g h t / ) ) . to . not . exist ;
643+ expect ( screen . queryByText ( / 1 0 0 0 0 0 / ) ) . to . not . exist ;
577644 } ) ;
578645
579646 it ( 'disables the Next button when the faker schema mapping is not confirmed' , async ( ) => {
0 commit comments