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/blocks/activity_modules/tests/behat/block_activity_modules.feature b/blocks/activity_modules/tests/behat/block_activity_modules.feature new file mode 100644 index 00000000000..ba769080aa4 --- /dev/null +++ b/blocks/activity_modules/tests/behat/block_activity_modules.feature @@ -0,0 +1,176 @@ +@block @block_activity_modules @_only_local +Feature: Block activity modules + In order to overview activity modules in a course + As a manager + I can add activities block in a course or on the frontpage + + Background: + Given I log in as "admin" + And I expand "Site administration" node + And I expand "Plugins" node + And I expand "Activity modules" node + And I follow "Manage activities" + And I click on "//a[@title=\"Show\"]" "xpath_element" in the "Feedback" "table_row" + And I click on "//a[@title=\"Show\"]" "xpath_element" in the "Assignment (2.2)" "table_row" + + Scenario: Add activities block on the frontpage + And the following "activities" exists: + | activity | name | intro | course | idnumber | + | assign | Frontpage assignment name | Frontpage assignment description | Acceptance test site | assign0 | + | assignment | Frontpage assignment22 name | Frontpage assignment22 description | Acceptance test site | assignment0 | + | book | Frontpage book name | Frontpage book description | Acceptance test site | book0 | + | chat | Frontpage chat name | Frontpage chat description | Acceptance test site | chat0 | + | choice | Frontpage choice name | Frontpage choice description | Acceptance test site | choice0 | + | data | Frontpage database name | Frontpage database description | Acceptance test site | data0 | + | feedback | Frontpage feedback name | Frontpage feedback description | Acceptance test site | feedback0 | + | forum | Frontpage forum name | Frontpage forum description | Acceptance test site | forum0 | + | label | Frontpage label name | Frontpage label description | Acceptance test site | label0 | + | lti | Frontpage lti name | Frontpage lti description | Acceptance test site | lti0 | + | page | Frontpage page name | Frontpage page description | Acceptance test site | page0 | + | quiz | Frontpage quiz name | Frontpage quiz description | Acceptance test site | quiz0 | + | resource | Frontpage resource name | Frontpage resource description | Acceptance test site | resource0 | + | imscp | Frontpage imscp name | Frontpage imscp description | Acceptance test site | imscp0 | + | folder | Frontpage folder name | Frontpage folder description | Acceptance test site | folder0 | + | glossary | Frontpage glossary name | Frontpage glossary description | Acceptance test site | glossary0 | + | scorm | Frontpage scorm name | Frontpage scorm description | Acceptance test site | scorm0 | + | lesson | Frontpage lesson name | Frontpage lesson description | Acceptance test site | lesson0 | + | survey | Frontpage survey name | Frontpage survey description | Acceptance test site | survey0 | + | url | Frontpage url name | Frontpage url description | Acceptance test site | url0 | + | wiki | Frontpage wiki name | Frontpage wiki description | Acceptance test site | wiki0 | + | workshop | Frontpage workshop name | Frontpage workshop description | Acceptance test site | workshop0 | + + And I am on homepage + When I follow "Turn editing on" + And I add the "Activities" block + And I click on "Assignments" "link" in the "Activities" "block" + Then I should see "Frontpage assignment name" + And I am on homepage + And I click on "Assignments (2.2)" "link" in the "Activities" "block" + And I should see "Frontpage assignment22 name" + And I am on homepage + And I click on "Chats" "link" in the "Activities" "block" + And I should see "Frontpage chat name" + And I am on homepage + And I click on "Choices" "link" in the "Activities" "block" + And I should see "Frontpage choice name" + And I am on homepage + And I click on "Databases" "link" in the "Activities" "block" + And I should see "Frontpage database name" + And I am on homepage + And I click on "Feedback" "link" in the "Activities" "block" + And I should see "Frontpage feedback name" + And I am on homepage + And I click on "Forums" "link" in the "Activities" "block" + And I should see "Frontpage forum name" + And I am on homepage + And I click on "External Tools" "link" in the "Activities" "block" + And I should see "Frontpage lti name" + And I am on homepage + And I click on "Quizzes" "link" in the "Activities" "block" + And I should see "Frontpage quiz name" + And I am on homepage + And I click on "Glossaries" "link" in the "Activities" "block" + And I should see "Frontpage glossary name" + And I am on homepage + And I click on "SCORM packages" "link" in the "Activities" "block" + And I should see "Frontpage scorm name" + And I am on homepage + And I click on "Lessons" "link" in the "Activities" "block" + And I should see "Frontpage lesson name" + And I am on homepage + And I click on "Wikis" "link" in the "Activities" "block" + And I should see "Frontpage wiki name" + And I am on homepage + And I click on "Workshop" "link" in the "Activities" "block" + And I should see "Frontpage workshop name" + And I am on homepage + And I click on "Resources" "link" in the "Activities" "block" + And I should see "Frontpage book name" + And I should see "Frontpage page name" + And I should see "Frontpage resource name" + And I should see "Frontpage imscp name" + And I should see "Frontpage folder name" + And I should see "Frontpage url name" + + Scenario: Add activities block in a course + Given the following "courses" exists: + | fullname | shortname | format | + | Course 1 | C1 | topics | + And the following "activities" exists: + | activity | name | intro | course | idnumber | + | assign | Test assignment name | Test assignment description | C1 | assign1 | + | assignment | Test assignment22 name | Test assignment22 description | C1 | assignment1 | + | book | Test book name | Test book description | C1 | book1 | + | chat | Test chat name | Test chat description | C1 | chat1 | + | choice | Test choice name | Test choice description | C1 | choice1 | + | data | Test database name | Test database description | C1 | data1 | + | feedback | Test feedback name | Test feedback description | C1 | feedback1 | + | folder | Test folder name | Test folder description | C1 | folder1 | + | forum | Test forum name | Test forum description | C1 | forum1 | + | glossary | Test glossary name | Test glossary description | C1 | glossary1 | + | imscp | Test imscp name | Test imscp description | C1 | imscp1 | + | label | Test label name | Test label description | C1 | label1 | + | lesson | Test lesson name | Test lesson description | C1 | lesson1 | + | lti | Test lti name | Test lti description | C1 | lti1 | + | page | Test page name | Test page description | C1 | page1 | + | quiz | Test quiz name | Test quiz description | C1 | quiz1 | + | resource | Test resource name | Test resource description | C1 | resource1 | + | scorm | Test scorm name | Test scorm description | C1 | scorm1 | + | survey | Test survey name | Test survey description | C1 | survey1 | + | url | Test url name | Test url description | C1 | url1 | + | wiki | Test wiki name | Test wiki description | C1 | wiki1 | + | workshop | Test workshop name | Test workshop description | C1 | workshop1 | + + When I follow "Courses" + And I follow "Course 1" + And I turn editing mode on + And I add the "Activities" block + And I click on "Assignments" "link" in the "Activities" "block" + Then I should see "Test assignment name" + And I follow "Course 1" + And I click on "Assignments (2.2)" "link" in the "Activities" "block" + And I should see "Test assignment22 name" + And I follow "Course 1" + And I click on "Chats" "link" in the "Activities" "block" + And I should see "Test chat name" + And I follow "Course 1" + And I click on "Choices" "link" in the "Activities" "block" + And I should see "Test choice name" + And I follow "Course 1" + And I click on "Databases" "link" in the "Activities" "block" + And I should see "Test database name" + And I follow "Course 1" + And I click on "Feedback" "link" in the "Activities" "block" + And I should see "Test feedback name" + And I follow "Course 1" + And I click on "Forums" "link" in the "Activities" "block" + And I should see "Test forum name" + And I follow "Course 1" + And I click on "External Tools" "link" in the "Activities" "block" + And I should see "Test lti name" + And I follow "Course 1" + And I click on "Quizzes" "link" in the "Activities" "block" + And I should see "Test quiz name" + And I follow "Course 1" + And I click on "Glossaries" "link" in the "Activities" "block" + And I should see "Test glossary name" + And I follow "Course 1" + And I click on "SCORM packages" "link" in the "Activities" "block" + And I should see "Test scorm name" + And I follow "Course 1" + And I click on "Lessons" "link" in the "Activities" "block" + And I should see "Test lesson name" + And I follow "Course 1" + And I click on "Wikis" "link" in the "Activities" "block" + And I should see "Test wiki name" + And I follow "Course 1" + And I click on "Workshop" "link" in the "Activities" "block" + And I should see "Test workshop name" + And I follow "Course 1" + And I click on "Resources" "link" in the "Activities" "block" + And I should see "Test book name" + And I should see "Test page name" + And I should see "Test resource name" + And I should see "Test imscp name" + And I should see "Test folder name" + And I should see "Test url name" diff --git a/course/tests/behat/behat_course.php b/course/tests/behat/behat_course.php index a35cdddd02c..87f84954084 100644 --- a/course/tests/behat/behat_course.php +++ b/course/tests/behat/behat_course.php @@ -85,18 +85,16 @@ 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') . '"') + ); } /** - * Adds the selected activity/resource filling the form data with the specified field/value pairs. + * Adds the selected activity/resource filling the form data with the specified field/value pairs. Sections 0 and 1 are also allowed on frontpage. * * @When /^I add a "(?P(?:[^"]|\\")*)" to section "(?P\d+)" and I fill the form with:$/ * @param string $activity The activity name @@ -114,7 +112,7 @@ class behat_course extends behat_base { } /** - * Opens the activity chooser and opens the activity/resource form page. + * Opens the activity chooser and opens the activity/resource form page. Sections 0 and 1 are also allowed on frontpage. * * @Given /^I add a "(?P(?:[^"]|\\")*)" to section "(?P\d+)"$/ * @throws ElementNotFoundException Thrown by behat_base::find @@ -123,7 +121,19 @@ class behat_course extends behat_base { */ public function i_add_to_section($activity, $section) { - $sectionxpath = "//li[@id='section-" . $section . "']"; + if ($this->getSession()->getPage()->find('css', 'body#page-site-index') && (int)$section <= 1) { + // We are on the frontpage. + if ($section) { + // Section 1 represents the contents on the frontpage. + $sectionxpath = "//body[@id='page-site-index']/descendant::div[contains(concat(' ',normalize-space(@class),' '),' sitetopic ')]"; + } else { + // Section 0 represents "Site main menu" block. + $sectionxpath = "//div[contains(concat(' ',normalize-space(@class),' '),' block_site_main_menu ')]"; + } + } else { + // We are inside the course. + $sectionxpath = "//li[@id='section-" . $section . "']"; + } $activityliteral = $this->getSession()->getSelectorsHandler()->xpathLiteral(ucfirst($activity)); 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"