@@ -764,6 +764,110 @@ void testIsVncEnabledAcceptSingleEnvVar() {
764
764
assertThat (nodeOptionsEnabled .isVncEnabled ()).isFalse ();
765
765
}
766
766
767
+ @ Test
768
+ void deleteSessionOnUiIsEnabledByDefault () {
769
+ Config config = new MapConfig (singletonMap ("node" , singletonMap ("detect-drivers" , "false" )));
770
+ NodeOptions nodeOptions = new NodeOptions (config );
771
+ assertThat (nodeOptions .isSessionDeletedOnUi ()).isFalse ();
772
+ }
773
+
774
+ @ Test
775
+ void deleteSessionOnUiCanBeEnabledExplicitly () {
776
+ Config config =
777
+ new MapConfig (
778
+ singletonMap (
779
+ "node" ,
780
+ ImmutableMap .of ("detect-drivers" , "false" , "delete-session-on-ui" , "true" )));
781
+ NodeOptions nodeOptions = new NodeOptions (config );
782
+ assertThat (nodeOptions .isSessionDeletedOnUi ()).isTrue ();
783
+ }
784
+
785
+ @ Test
786
+ void deleteSessionOnUiCanBeDisabled () {
787
+ Config config =
788
+ new MapConfig (
789
+ singletonMap (
790
+ "node" ,
791
+ ImmutableMap .of ("detect-drivers" , "false" , "delete-session-on-ui" , "false" )));
792
+ NodeOptions nodeOptions = new NodeOptions (config );
793
+ assertThat (nodeOptions .isSessionDeletedOnUi ()).isFalse ();
794
+ }
795
+
796
+ @ Test
797
+ void deleteSessionOnUiCapabilityIsAddedWhenEnabled () {
798
+ assumeTrue (
799
+ new ChromeDriverInfo ().isPresent () || new GeckoDriverInfo ().isPresent (),
800
+ "A driver needs to be available" );
801
+
802
+ Config config =
803
+ new MapConfig (
804
+ singletonMap (
805
+ "node" , ImmutableMap .of ("detect-drivers" , "true" , "delete-session-on-ui" , "true" )));
806
+
807
+ List <Capabilities > reported = new ArrayList <>();
808
+ new NodeOptions (config )
809
+ .getSessionFactories (
810
+ caps -> {
811
+ reported .add (caps );
812
+ return Collections .singleton (HelperFactory .create (config , caps ));
813
+ });
814
+
815
+ assertThat (reported )
816
+ .filteredOn (capabilities -> capabilities .getCapability ("se:deleteSessionOnUi" ) != null )
817
+ .hasSize (reported .size ());
818
+
819
+ assertThat (reported )
820
+ .allMatch (
821
+ capabilities ->
822
+ Boolean .TRUE .equals (capabilities .getCapability ("se:deleteSessionOnUi" )));
823
+ }
824
+
825
+ @ Test
826
+ void deleteSessionOnUiCapabilityIsNotAddedWhenDisabled () {
827
+ assumeTrue (
828
+ new ChromeDriverInfo ().isPresent () || new GeckoDriverInfo ().isPresent (),
829
+ "A driver needs to be available" );
830
+
831
+ Config config =
832
+ new MapConfig (
833
+ singletonMap (
834
+ "node" ,
835
+ ImmutableMap .of ("detect-drivers" , "true" , "delete-session-on-ui" , "false" )));
836
+
837
+ List <Capabilities > reported = new ArrayList <>();
838
+ new NodeOptions (config )
839
+ .getSessionFactories (
840
+ caps -> {
841
+ reported .add (caps );
842
+ return Collections .singleton (HelperFactory .create (config , caps ));
843
+ });
844
+
845
+ assertThat (reported )
846
+ .filteredOn (capabilities -> capabilities .getCapability ("se:deleteSessionOnUi" ) == null )
847
+ .hasSize (reported .size ());
848
+ }
849
+
850
+ @ Test
851
+ void deleteSessionOnUiCapabilityIsAddedByDefault () {
852
+ assumeTrue (
853
+ new ChromeDriverInfo ().isPresent () || new GeckoDriverInfo ().isPresent (),
854
+ "A driver needs to be available" );
855
+
856
+ Config config = new MapConfig (singletonMap ("node" , singletonMap ("detect-drivers" , "true" )));
857
+
858
+ List <Capabilities > reported = new ArrayList <>();
859
+ new NodeOptions (config )
860
+ .getSessionFactories (
861
+ caps -> {
862
+ reported .add (caps );
863
+ return Collections .singleton (HelperFactory .create (config , caps ));
864
+ });
865
+
866
+ assertThat (reported )
867
+ .filteredOn (capabilities -> capabilities .getCapability ("se:deleteSessionOnUi" ) == null )
868
+ .hasSize (reported .size ());
869
+ }
870
+
767
871
private Condition <? super List <? extends Capabilities >> supporting (String name ) {
768
872
return new Condition <>(
769
873
caps -> caps .stream ().anyMatch (cap -> name .equals (cap .getBrowserName ())),
0 commit comments