From c99dffb69c7db1e28aa67f465a3b9b633dfedfe1 Mon Sep 17 00:00:00 2001 From: Rajesh Taneja Date: Tue, 25 Oct 2016 13:48:51 +0800 Subject: [PATCH] MDL-55074 behat: Fixed new theme related changes --- blocks/tests/behat/hide_blocks.feature | 19 ++++++++++--------- .../behat/return_block_original_state.feature | 6 +++--- course/tests/behat/behat_course.php | 12 ++++++++++-- lib/tests/behat/behat_navigation.php | 2 +- .../behat/behat_theme_boost_behat_course.php | 16 ---------------- 5 files changed, 24 insertions(+), 31 deletions(-) diff --git a/blocks/tests/behat/hide_blocks.feature b/blocks/tests/behat/hide_blocks.feature index 43ae1499a5c..c83bd02c4f3 100644 --- a/blocks/tests/behat/hide_blocks.feature +++ b/blocks/tests/behat/hide_blocks.feature @@ -11,18 +11,19 @@ Feature: Block visibility And I log in as "admin" And I am on site homepage And I follow "Course 1" - And I follow "Turn editing on" + And I turn editing mode on @javascript Scenario: Hiding all blocks on the page should remove the column they're in - Given I open the "Search forums" blocks action menu + Given I add the "Search forums" block + And I open the "Search forums" blocks action menu + And I click on "Configure Search forums block" "link" in the "Search forums" "block" + And I set the field "Region" to "Right" + And I press "Save changes" + And I turn editing mode off + And ".empty-region-side-post" "css_element" should not exist in the "body" "css_element" + And I turn editing mode on + And I open the "Search forums" blocks action menu And I click on "Hide Search forums block" "link" in the "Search forums" "block" - And I open the "Latest announcements" blocks action menu - And I click on "Hide Latest announcements block" "link" in the "Latest announcements" "block" - And I open the "Upcoming events" blocks action menu - And I click on "Hide Upcoming events block" "link" in the "Upcoming events" "block" - And I open the "Recent activity" blocks action menu - When I click on "Hide Recent activity block" "link" in the "Recent activity" "block" - Then ".empty-region-side-post" "css_element" should not exist in the "body" "css_element" And I follow "Turn editing off" And ".empty-region-side-post" "css_element" should exist in the "body" "css_element" diff --git a/blocks/tests/behat/return_block_original_state.feature b/blocks/tests/behat/return_block_original_state.feature index 8b43a40ec8b..931eb3fab48 100644 --- a/blocks/tests/behat/return_block_original_state.feature +++ b/blocks/tests/behat/return_block_original_state.feature @@ -14,7 +14,7 @@ Feature: The context of a block can always be returned to it's original state. And I follow "Turn editing on" And I add the "Tags" block Then I should see "Tags" in the "Tags" "block" - And I click on "Participants" "link" in the "//li[p/span[contains(normalize-space(string(.)), 'Current course')]]" "xpath_element" + And I click on "Participants" "link" in the "//li[p/a[contains(normalize-space(string(.)), 'Courses')]]" "xpath_element" And I configure the "Tags" block And I set the following fields to these values: | Display on page types | Any page | @@ -31,7 +31,7 @@ Feature: The context of a block can always be returned to it's original state. And I should see "Tags" in the "Tags" "block" And I follow "Course 1" And "Tags" "block" should not exist - And I click on "Participants" "link" in the "//li[p/span[contains(normalize-space(string(.)), 'Current course')]]" "xpath_element" + And I navigate to "Participants" node in "Courses > C1" And "Tags" "block" should not exist And I follow "Course 1" And I add a "Assignment" to section "1" and I fill the form with: @@ -45,5 +45,5 @@ Feature: The context of a block can always be returned to it's original state. And I press "Save changes" And I follow "Course 1" And I should see "Tags" in the "Tags" "block" - And I click on "Participants" "link" in the "//li[p/span[contains(normalize-space(string(.)), 'Current course')]]" "xpath_element" + And I navigate to "Participants" node in "Courses > C1" And I should see "Tags" in the "Tags" "block" diff --git a/course/tests/behat/behat_course.php b/course/tests/behat/behat_course.php index 166210a8f51..759b3427791 100644 --- a/course/tests/behat/behat_course.php +++ b/course/tests/behat/behat_course.php @@ -48,7 +48,11 @@ class behat_course extends behat_base { */ public function i_turn_editing_mode_on() { - $this->execute("behat_forms::press_button", get_string('turneditingon')); + try { + $this->execute("behat_forms::press_button", get_string('turneditingon')); + } catch (Exception $e) { + $this->execute("behat_general::i_click_on_in_the", [get_string('turneditingon'), 'link', 'Administration', 'block']); + } } /** @@ -57,7 +61,11 @@ class behat_course extends behat_base { */ public function i_turn_editing_mode_off() { - $this->execute("behat_forms::press_button", get_string('turneditingoff')); + try { + $this->execute("behat_forms::press_button", get_string('turneditingoff')); + } catch (Exception $e) { + $this->execute("behat_general::i_click_on_in_the", [get_string('turneditingoff'), 'link', 'Administration', 'block']); + } } /** diff --git a/lib/tests/behat/behat_navigation.php b/lib/tests/behat/behat_navigation.php index e970829b6c3..f4ae59a0b9c 100644 --- a/lib/tests/behat/behat_navigation.php +++ b/lib/tests/behat/behat_navigation.php @@ -330,7 +330,7 @@ class behat_navigation extends behat_base { "/li[contains(concat(' ', normalize-space(@class), ' '), ' contains_branch ')]" . "/ul/li[contains(concat(' ', normalize-space(@class), ' '), ' contains_branch ')]" . "[p[contains(concat(' ', normalize-space(@class), ' '), ' branch ')]" . - "/span[normalize-space(.)=" . $nodetextliteral ."]]" . + "[span[normalize-space(.)=" . $nodetextliteral ."] or a[normalize-space(.)=" . $nodetextliteral ."]]]" . "|" . "//div[contains(concat(' ', normalize-space(@class), ' '), ' content ')]/div" . "/ul[contains(concat(' ', normalize-space(@class), ' '), ' block_tree ')]" . diff --git a/theme/boost/tests/behat/behat_theme_boost_behat_course.php b/theme/boost/tests/behat/behat_theme_boost_behat_course.php index 032384b3c56..58fd4017c3c 100644 --- a/theme/boost/tests/behat/behat_theme_boost_behat_course.php +++ b/theme/boost/tests/behat/behat_theme_boost_behat_course.php @@ -248,22 +248,6 @@ class behat_theme_boost_behat_course extends behat_course { $actionnode->click(); } - public function i_turn_editing_mode_on() { - try { - $this->execute("behat_forms::press_button", get_string('turneditingon')); - } catch (Exception $e) { - $this->execute("behat_general::i_click_on_in_the", [get_string('turneditingon'), 'link', 'Administration', 'block']); - } - } - - public function i_turn_editing_mode_off() { - try { - $this->execute("behat_forms::press_button", get_string('turneditingoff')); - } catch (Exception $e) { - $this->execute("behat_general::i_click_on_in_the", [get_string('turneditingoff'), 'link', 'Administration', 'block']); - } - } - protected function is_course_editor() { // We don't need to behat_base::spin() here as all is already loaded.