From 6d15c6fca56e3d429f3aa54f9f369b59c97da94d Mon Sep 17 00:00:00 2001
From: Rajab Natshah <rajabn@gmail.com>
Date: Sat, 5 Oct 2019 13:04:46 +0300
Subject: [PATCH] Issue #3085506: Add a definition step to check if the media
 browser with the selected iframe idis open with Varbase Context for Beaht
 Automated Functional Acceptance Testing

---
 tests/features/bootstrap/VarbaseContext.php   | 32 ++++++++++++++++++-
 ...ueue-using-entityqueue-form-widget.feature |  8 +++--
 2 files changed, 36 insertions(+), 4 deletions(-)

diff --git a/tests/features/bootstrap/VarbaseContext.php b/tests/features/bootstrap/VarbaseContext.php
index b1e05e6c..d42b9374 100644
--- a/tests/features/bootstrap/VarbaseContext.php
+++ b/tests/features/bootstrap/VarbaseContext.php
@@ -1406,6 +1406,25 @@ JS;
     }
   }
   
+  /**
+   * #varbase: To check if the media browser with the selected iframe id 
+   *           is open.
+   * 
+   * Example : Then the "entity_browser_iframe_media_browser" media browser should be open
+   *
+   * @Then /^the "([^"]*)" media browser should be open$/
+   */
+  public function theMediaBrowserIsOpen($entity_browser_iframe_id) {
+    if (!$elem = $this->getSession()->getPage()->find('css', '.ui-dialog.ui-widget-content')) {
+      throw new Exception('The media browser failed to open.');
+    }
+
+    $radioButton = $this->getSession()->getPage()->find('css', "#$entity_browser_iframe_id");
+    if (!$radioButton) {
+        throw new \Exception("$labelText is not found.");
+    }
+  }
+  
   /**
    * #varbase: To find an element with a selected index having the
    *           first attribute, and check if it's have the second one.
@@ -1421,6 +1440,17 @@ JS;
       throw new Exception("The image position is wrong");
     }
   }
+  
+  /**
+   * #varbase: Resize the current window browser to a selected width and height.
+   * 
+   * Example #1: And I resize the current window to width="1280" and height="600" 
+   * 
+   * @Given /^I resize the current window to width="([^"]*)" and height="([^"]*)"$/
+   */
+  public function resizeTheCurrentWindowToWidthAndHeight($width, $height) {
+    $this->getSession()->resizeWindow((int)$width, (int)$height, 'current');
+  }
 
 
   public function cleanUsers() {
@@ -1473,7 +1503,7 @@ JS;
   /**
    * Maximize the window before scenario.
    *
-   * @BeforeStep @javascript
+   * @BeforeStep
    */
   public function beforeStepMaximizeWindow() {
     $this->getSession()->getDriver()->maximizeWindow();
diff --git a/tests/features/varbase/step2-apply-tests/05-content-management/05-03-add-hero-slider-to-entityqueue-using-entityqueue-form-widget.feature b/tests/features/varbase/step2-apply-tests/05-content-management/05-03-add-hero-slider-to-entityqueue-using-entityqueue-form-widget.feature
index bd1fb6ce..be7cfd94 100644
--- a/tests/features/varbase/step2-apply-tests/05-content-management/05-03-add-hero-slider-to-entityqueue-using-entityqueue-form-widget.feature
+++ b/tests/features/varbase/step2-apply-tests/05-content-management/05-03-add-hero-slider-to-entityqueue-using-entityqueue-form-widget.feature
@@ -29,7 +29,7 @@ I want to be able to add and remove entities to any allowed entity queue.
      Then I should see "Create Hero slider"
      When I press "Select media"
       And I wait for AJAX to finish
-     Then the image media browser should be open
+     Then the "entity_browser_iframe_media_browser" media browser should be open
 
   @javascript @local @development @staging @production
   Scenario: Add a Test hero slider number 1 to the heroslider entity queue.
@@ -41,8 +41,9 @@ I want to be able to add and remove entities to any allowed entity queue.
       And I fill in "Test hero slider slide text #1" for "Slide text"
       And I press "Select media"
       And I wait for AJAX to finish
-     Then the image media browser should be open
+     Then the "entity_browser_iframe_media_browser" media browser should be open
      When I switch to iframe "entity_browser_iframe_media_browser"
+      And I wait max of 5s 
       And I fill in "Flag Earth" for "edit-name"
       And I press the "Search" button
       And wait max of 5s
@@ -73,8 +74,9 @@ I want to be able to add and remove entities to any allowed entity queue.
       And I fill in "Test hero slider slide text #2" for "Slide text"
       And I press "Select media"
       And I wait for AJAX to finish
-     Then the image media browser should be open
+     Then the "entity_browser_iframe_media_browser" media browser should be open
      When I switch to iframe "entity_browser_iframe_media_browser"
+      And I wait max of 5s
       And I fill in "Flag Earth" for "edit-name"
       And I press the "Search" button
       And wait max of 5s
-- 
GitLab