@@ -615,6 +615,84 @@ describe('Collection aggregations tab', function () {
615
615
) ;
616
616
} ) ;
617
617
618
+ context ( 'with existing validation rule' , function ( ) {
619
+ const REQUIRE_PHONE_VALIDATOR =
620
+ '{ $jsonSchema: { bsonType: "object", required: [ "phone" ] } }' ;
621
+ const VALIDATED_OUT_COLLECTION = 'nestedDocs' ;
622
+ beforeEach ( async function ( ) {
623
+ await browser . setValidation ( {
624
+ connectionName : DEFAULT_CONNECTION_NAME_1 ,
625
+ database : 'test' ,
626
+ collection : VALIDATED_OUT_COLLECTION ,
627
+ validator : REQUIRE_PHONE_VALIDATOR ,
628
+ } ) ;
629
+ await browser . navigateToCollectionTab (
630
+ DEFAULT_CONNECTION_NAME_1 ,
631
+ 'test' ,
632
+ 'numbers' ,
633
+ 'Aggregations'
634
+ ) ;
635
+ await addStage ( browser , 1 ) ;
636
+ } ) ;
637
+
638
+ afterEach ( async function ( ) {
639
+ await browser . setValidation ( {
640
+ connectionName : DEFAULT_CONNECTION_NAME_1 ,
641
+ database : 'test' ,
642
+ collection : VALIDATED_OUT_COLLECTION ,
643
+ validator : '{}' ,
644
+ } ) ;
645
+ } ) ;
646
+
647
+ it ( 'Shows error info when inserting' , async function ( ) {
648
+ await browser . selectStageOperator ( 0 , '$out' ) ;
649
+ await browser . setCodemirrorEditorValue (
650
+ Selectors . stageEditor ( 0 ) ,
651
+ `'${ VALIDATED_OUT_COLLECTION } '`
652
+ ) ;
653
+
654
+ await waitForAnyText ( browser , browser . $ ( Selectors . stageContent ( 0 ) ) ) ;
655
+
656
+ // run the $out stage
657
+ await browser . clickVisible ( Selectors . RunPipelineButton ) ;
658
+
659
+ // confirm the write operation
660
+ const writeOperationConfirmationModal = browser . $ (
661
+ Selectors . AggregationWriteOperationConfirmationModal
662
+ ) ;
663
+ await writeOperationConfirmationModal . waitForDisplayed ( ) ;
664
+
665
+ const description = await browser
666
+ . $ ( Selectors . AggregationWriteOperationConfirmationModalDescription )
667
+ . getText ( ) ;
668
+
669
+ expect ( description ) . to . contain ( `test.${ VALIDATED_OUT_COLLECTION } ` ) ;
670
+
671
+ await browser . clickVisible (
672
+ Selectors . AggregationWriteOperationConfirmButton
673
+ ) ;
674
+
675
+ await writeOperationConfirmationModal . waitForDisplayed ( { reverse : true } ) ;
676
+
677
+ const errorElement = browser . $ ( Selectors . AggregationErrorBanner ) ;
678
+ await errorElement . waitForDisplayed ( ) ;
679
+ expect ( await errorElement . getText ( ) ) . to . include (
680
+ 'Document failed validation'
681
+ ) ;
682
+ // enter details
683
+ const errorDetailsBtn = browser . $ ( Selectors . AggregationErrorDetailsBtn ) ;
684
+ await errorElement . waitForDisplayed ( ) ;
685
+ await errorDetailsBtn . click ( ) ;
686
+
687
+ const errorDetailsJson = browser . $ ( Selectors . ErrorDetailsJson ) ;
688
+ await errorDetailsJson . waitForDisplayed ( ) ;
689
+
690
+ // exit details
691
+ await browser . clickVisible ( Selectors . confirmationModalConfirmButton ( ) ) ;
692
+ await errorElement . waitForDisplayed ( ) ;
693
+ } ) ;
694
+ } ) ;
695
+
618
696
it ( 'cancels pipeline with $out as the last stage' , async function ( ) {
619
697
await browser . selectStageOperator ( 0 , '$out' ) ;
620
698
await browser . setCodemirrorEditorValue (
0 commit comments