From 6dfd8325f07b81dc4e85e45175a7256ef531b808 Mon Sep 17 00:00:00 2001 From: Marina Glancy Date: Fri, 22 Nov 2013 21:12:22 +1100 Subject: [PATCH] MDL-42731 behat: load 'Site administration' when expanding node in non-javascript mode --- admin/tests/behat/behat_admin.php | 19 --------------- admin/tests/behat/display_short_names.feature | 3 ++- course/tests/behat/behat_course.php | 14 +++++------ lib/tests/behat/behat_deprecated.php | 24 +++++++++++++++++++ lib/tests/behat/behat_navigation.php | 4 ++++ .../tests/behat/edit_post_student.feature | 2 +- 6 files changed, 37 insertions(+), 29 deletions(-) diff --git a/admin/tests/behat/behat_admin.php b/admin/tests/behat/behat_admin.php index 10d39ebbdf7..13d5f2f248a 100644 --- a/admin/tests/behat/behat_admin.php +++ b/admin/tests/behat/behat_admin.php @@ -125,23 +125,4 @@ class behat_admin extends behat_base { $this->getSession()->wait($timeout, $javascript); } } - - /** - * Goes to notification page ensuring site admin navigation is loaded. - * - * @Given /^I go to notifications page$/ - * @return Given[] - */ - public function i_go_to_notifications_page() { - if ($this->running_javascript()) { - return array( - new Given('I expand "' . get_string('administrationsite') . '" node'), - new Given('I follow "' . get_string('notifications') . '"') - ); - } else { - return array( - new Given('I follow "' . get_string('administrationsite') . '"') - ); - } - } } diff --git a/admin/tests/behat/display_short_names.feature b/admin/tests/behat/display_short_names.feature index 86231b27460..76cfda0d94b 100644 --- a/admin/tests/behat/display_short_names.feature +++ b/admin/tests/behat/display_short_names.feature @@ -15,7 +15,8 @@ Feature: Display extended course names And I should not see "C_shortname Course fullname" Scenario: Courses list with extended course names - Given I go to notifications page + Given I expand "Site administration" node + And I expand "Appearance" node And I click on "Courses" "link" in the "//div[@id='settingsnav']/descendant::li[contains(concat(' ', normalize-space(@class), ' '), ' type_setting ')][contains(., 'Appearance')]" "xpath_element" And I check "Display extended course names" When I press "Save changes" diff --git a/course/tests/behat/behat_course.php b/course/tests/behat/behat_course.php index a35cdddd02c..e7619e9bc83 100644 --- a/course/tests/behat/behat_course.php +++ b/course/tests/behat/behat_course.php @@ -85,14 +85,12 @@ class behat_course extends behat_base { * @return Given[] */ public function i_go_to_the_courses_management_page() { - if ($this->running_javascript()) { - $scenario = array(new Given('I expand "' . get_string('administrationsite') . '" node')); - } else { - $scenario = array(new Given('I follow "' . get_string('administrationsite') . '"')); - } - $scenario[] = new Given('I expand "' . get_string('courses', 'admin') . '" node'); - $scenario[] = new Given('I follow "' . get_string('coursemgmt', 'admin') . '"'); - return $scenario; + return array( + new Given('I am on homepage'), + new Given('I expand "' . get_string('administrationsite') . '" node'), + new Given('I expand "' . get_string('courses', 'admin') . '" node'), + new Given('I follow "' . get_string('coursemgmt', 'admin') . '"') + ); } /** diff --git a/lib/tests/behat/behat_deprecated.php b/lib/tests/behat/behat_deprecated.php index 2034a78f044..25c8bb442f0 100644 --- a/lib/tests/behat/behat_deprecated.php +++ b/lib/tests/behat/behat_deprecated.php @@ -70,6 +70,30 @@ class behat_deprecated extends behat_base { $elementnode->click(); } + /** + * Goes to notification page ensuring site admin navigation is loaded. + * + * Step [I expand "Site administration" node] will ensure that administration menu + * is opened in both javascript and non-javascript modes. + * + * @deprecated since 2.7 + * @todo MDL-42862 This will be deleted in Moodle 2.9 + * + * @Given /^I go to notifications page$/ + * @return Given[] + */ + public function i_go_to_notifications_page() { + $alternative = array( + 'I expand "' . get_string('administrationsite') . '" node', + 'I click on "' . get_string('notifications') . '" "link" in the "'.get_string('administration').'" "block"' + ); + $this->deprecated_message($alternative); + return array( + new Given($alternative[0]), + new Given($alternative[1]), + ); + } + /** * Throws an exception if $CFG->behat_usedeprecated is not allowed. * diff --git a/lib/tests/behat/behat_navigation.php b/lib/tests/behat/behat_navigation.php index 90d68a5764c..541731050e1 100644 --- a/lib/tests/behat/behat_navigation.php +++ b/lib/tests/behat/behat_navigation.php @@ -53,6 +53,10 @@ class behat_navigation extends behat_base { // all of tree's nodes; adding this because of scenarios that shares the // same steps with and without Javascript enabled. if (!$this->running_javascript()) { + if ($nodetext === get_string('administrationsite')) { + // Administration menu is not loaded by default any more. Click the link to expand. + return new Given('I click on "'.$nodetext.'" "link" in the "'.get_string('administration').'" "block"'); + } return false; } diff --git a/mod/forum/tests/behat/edit_post_student.feature b/mod/forum/tests/behat/edit_post_student.feature index 0f4aa79ad12..4b3afcd72a7 100644 --- a/mod/forum/tests/behat/edit_post_student.feature +++ b/mod/forum/tests/behat/edit_post_student.feature @@ -15,7 +15,7 @@ Feature: Students can edit or delete their forum posts within a set time limit | user | course | role | | student1 | C1 | student | And I log in as "admin" - And I go to notifications page + And I expand "Site administration" node And I expand "Security" node And I follow "Site policies" And I select "1 minutes" from "Maximum time to edit posts"