From 84a1e50a9ff8cca1d15b7e7d4a4f1440ba20acd5 Mon Sep 17 00:00:00 2001
From: Rex Lorenzo <rex@oid.ucla.edu>
Date: Thu, 31 Jul 2014 11:29:00 -0700
Subject: [PATCH] MDL-46641 behat: Delete activity step does not work without
 actions menu open

---
 course/tests/behat/behat_course.php        | 12 ++++++------
 course/tests/behat/course_controls.feature |  1 -
 2 files changed, 6 insertions(+), 7 deletions(-)

diff --git a/course/tests/behat/behat_course.php b/course/tests/behat/behat_course.php
index 7698fe75603..580003b4dfd 100644
--- a/course/tests/behat/behat_course.php
+++ b/course/tests/behat/behat_course.php
@@ -697,12 +697,12 @@ class behat_course extends behat_base {
      * @return Given[]
      */
     public function i_delete_activity($activityname) {
-
-        $deletestring = get_string('delete');
-
-        $steps = array(
-            new Given('I click on "' . $this->escape($deletestring) . '" "link" in the "' . $this->escape($activityname) . '" activity')
-        );
+        $steps = array();
+        $activity = $this->escape($activityname);
+        if ($this->running_javascript()) {
+            $steps[] = new Given('I open "' . $activity . '" actions menu');
+        }
+        $steps[] = new Given('I click on "' . get_string('delete') . '" "link" in the "' . $activity . '" activity');
 
         // JS enabled.
         // Not using chain steps here because the exceptions catcher have problems detecting
diff --git a/course/tests/behat/course_controls.feature b/course/tests/behat/course_controls.feature
index 7b601981d39..c3a965e3026 100644
--- a/course/tests/behat/course_controls.feature
+++ b/course/tests/behat/course_controls.feature
@@ -67,7 +67,6 @@ Feature: Course activity controls works as expected
     And I open "Test forum name 1" actions menu
     And I click on "Hide" "link" in the "Test forum name 1" activity
     And "#section-2" "css_element" <should_see_other_sections> exist
-    And I open "Test forum name 1" actions menu
     And I delete "Test forum name 1" activity
     And I should not see "Test forum name 1" in the "#region-main" "css_element"
     And I duplicate "Test forum name 2" activity editing the new copy with: