Skip to content

Commit

Permalink
MDL-40975 course: Adapt behat tests to the new course editing interface
Browse files Browse the repository at this point in the history
  • Loading branch information
David Monllao authored and andrewnicols committed Nov 6, 2013
1 parent 79864ef commit 047a880
Show file tree
Hide file tree
Showing 19 changed files with 77 additions and 50 deletions.
14 changes: 9 additions & 5 deletions backup/util/ui/tests/behat/duplicate_activities.feature
Original file line number Diff line number Diff line change
Expand Up @@ -21,14 +21,18 @@ Feature: Duplicate activities
And I add a "Database" to section "1" and I fill the form with:
| Name | Test database name |
| Description | Test database description |
And I click on "Actions" "link" in the "Test database name" activity
And I open "Test database name" actions menu
When I click on "Duplicate" "link" in the "Test database name" activity
And I press "Continue"
And I press "Edit the new copy"
And I click on "Edit settings" "link" in the "Test database name" activity
And I fill the moodle form with:
| Name | Original database name |
And I press "Save and return to course"
And I open "Test database name" actions menu
And I click on "Edit settings" "link" in the "Test database name" activity
And I fill the moodle form with:
| Name | Duplicated database name |
| Description | Duplicated database description |
And I press "Save and return to course"
Then I should see "Test database name" in the "#section-1" "css_element"
Then I should see "Original database name" in the "#section-1" "css_element"
And I should see "Duplicated database name" in the "#section-1" "css_element"
And "Test database name" "link" should appear before "Duplicated database name" "link"
And "Original database name" "link" should appear before "Duplicated database name" "link"
10 changes: 5 additions & 5 deletions backup/util/ui/tests/behat/restore_moodle2_courses.feature
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ Feature: Restore Moodle 2 course backups
Then I should see "Course 1 restored in a new course"
And I should see "Community finder" in the "Community finder" "block"
And I should see "Test forum name"
And I follow "Edit settings"
And I click on "Edit settings" "link" in the "Administration" "block"
And I expand all fieldsets
And the "id_format" field should match "Topics format" value
And the "Number of sections" field should match "15" value
Expand Down Expand Up @@ -85,7 +85,7 @@ Feature: Restore Moodle 2 course backups
When I restore "test_backup.mbz" backup into a new course using this options:
Then I should see "Topic 1"
And I should see "Test forum name"
And I follow "Edit settings"
And I click on "Edit settings" "link" in the "Administration" "block"
And I expand all fieldsets
And the "id_format" field should match "Topics format" value
And I fill the moodle form with:
Expand All @@ -96,14 +96,14 @@ Feature: Restore Moodle 2 course backups
And I press "Save changes"
And I should see "1 January - 7 January"
And I should see "Test forum name"
And I follow "Edit settings"
And I click on "Edit settings" "link" in the "Administration" "block"
And I expand all fieldsets
And the "id_format" field should match "Weekly format" value
And I fill the moodle form with:
| id_format | Social format |
And I press "Save changes"
And I should see "An open forum for chatting about anything you want to"
And I follow "Edit settings"
And I click on "Edit settings" "link" in the "Administration" "block"
And I expand all fieldsets
And the "id_format" field should match "Social format" value
And I press "Cancel"
Expand All @@ -120,7 +120,7 @@ Feature: Restore Moodle 2 course backups
| Filename | test_backup.mbz |
And I restore "test_backup.mbz" backup into "Course 2" course using this options:
| Overwrite course configuration | Yes |
And I follow "Edit settings"
And I click on "Edit settings" "link" in the "Administration" "block"
And I expand all fieldsets
Then the "id_format" field should match "Topics format" value
And the "Number of sections" field should match "15" value
Expand Down
2 changes: 2 additions & 0 deletions blocks/tests/behat/configure_block_throughout_site.feature
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@ Feature: Add and configure blocks throughout the site
And I log in as "manager1"
And I follow "Turn editing on"
And I add the "Comments" block
And I click on "Actions" "link" in the "Comments" "block"
And I follow "Configure Comments block"
And I fill the moodle form with:
| Page contexts | Display throughout the entire site |
Expand All @@ -26,6 +27,7 @@ Feature: Add and configure blocks throughout the site
Then I should see "Comments" in the "Comments" "block"
And I should see "Save comment" in the "Comments" "block"
And I am on homepage
And I click on "Actions" "link" in the "Comments" "block"
And I follow "Configure Comments block"
And I fill the moodle form with:
| Default weight | -10 (first) |
Expand Down
3 changes: 3 additions & 0 deletions blocks/tests/behat/return_block_original_state.feature
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@ Feature: The context of a block can always be returned to it's original state.
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 "Actions" "link" in the "Tags" "block"
And I follow "Configure Tags block"
And I fill the moodle form with:
| Display on page types | Any page |
Expand All @@ -24,6 +25,7 @@ Feature: The context of a block can always be returned to it's original state.
| Assignment name | Assignment1 |
| Description | Description |
And I follow "Assignment1"
And I click on "Actions" "link" in the "Tags" "block"
And I follow "Configure Tags block"
And I fill the moodle form with:
| Display on page types | Any assignment module page |
Expand All @@ -39,6 +41,7 @@ Feature: The context of a block can always be returned to it's original state.
| Description | Description |
And I follow "Assignment2"
And I should see "Tags" in the "Tags" "block"
And I click on "Actions" "link" in the "Tags" "block"
And I follow "Configure Tags block"
And I fill the moodle form with:
| Display on page types | Any page |
Expand Down
2 changes: 1 addition & 1 deletion completion/tests/behat/enable_manual_complete_mark.feature
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ Feature: Allow students to manually mark an activity as complete
And I log in as "teacher1"
And I follow "Course 1"
And I turn editing mode on
And I follow "Edit settings"
And I click on "Edit settings" "link" in the "Administration" "block"
And I fill the moodle form with:
| Enable completion tracking | Yes |
And I press "Save changes"
Expand Down
4 changes: 2 additions & 2 deletions completion/tests/behat/restrict_section_availability.feature
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ Feature: Restrict sections availability through completion or grade conditions
Given I log in as "teacher1"
And I follow "Course 1"
And I turn editing mode on
And I follow "Edit settings"
And I click on "Edit settings" "link" in the "Administration" "block"
And I fill the moodle form with:
| Enable completion tracking | Yes |
And I press "Save changes"
Expand Down Expand Up @@ -93,4 +93,4 @@ Feature: Restrict sections availability through completion or grade conditions
And I log in as "student1"
And I follow "Course 1"
And "Test page name" activity should be visible
And I should not see "Not available until you achieve a required score in Grade assignment"
And I should not see "Not available until you achieve a required score in Grade assignment"
2 changes: 1 addition & 1 deletion course/tests/behat/activities_group_icons.feature
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ Feature: Toggle activities groups mode from the course page
And I add a "Forum" to section "1" and I fill the form with:
| Forum name | Test forum name |
| Description | Test forum description |
And I follow "Edit settings"
And I click on "Edit settings" "link" in the "Administration" "block"
And I fill the moodle form with:
| Group mode | No groups |
| Force group mode | No |
Expand Down
3 changes: 2 additions & 1 deletion course/tests/behat/activities_visibility_icons.feature
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,8 @@ Feature: Toggle activities visibility from the course page
| Forum name | Test forum name |
| Description | Test forum description |
| Visible | Show |
When I click on "Hide" "link" in the "Test forum name" activity
When I open "Test forum name" actions menu
And I click on "Hide" "link" in the "Test forum name" activity
Then "Test forum name" activity should be hidden
And I click on "Show" "link" in the "Test forum name" activity
And "Test forum name" activity should be visible
Expand Down
2 changes: 1 addition & 1 deletion course/tests/behat/add_activities.feature
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ Feature: Add activities to courses
And I turn editing mode off
Then I should not see "Adding a new"
And I follow "Test name"
And I follow "Edit settings"
And I click on "Edit settings" "link" in the "Administration" "block"
And I expand all fieldsets
And the "Name" field should match "Test name" value
And the "Entries required for completion" field should match "9" value
Expand Down
42 changes: 34 additions & 8 deletions course/tests/behat/behat_course.php
Original file line number Diff line number Diff line change
Expand Up @@ -327,6 +327,11 @@ public function section_should_be_hidden($sectionnumber) {

// Non-JS browsers can not click on img elements.
if ($this->running_javascript()) {

// Expanding the actions menu.
$actionsmenu = $this->find('css', "a[role='menuitem']", false, $activity);
$actionsmenu->click();

// To check that the visibility is not clickable we check the funcionality rather than the applied style.
$visibilityiconnode = $this->find('css', 'a.editing_show img', false, $activity);
$visibilityiconnode->click();
Expand Down Expand Up @@ -527,7 +532,6 @@ public function i_change_activity_name_to($activityname, $newactivityname) {
// Adding chr(10) to save changes.
$activity = $this->escape($activityname);
return array(
new Given('I open "' . $activity . '" actions menu'),
new Given('I click on "' . get_string('edittitle') . '" "link" in the "' . $activity .'" activity'),
new Given('I fill in "title" with "' . $this->escape($newactivityname) . chr(10) . '"'),
new Given('I wait "2" seconds')
Expand Down Expand Up @@ -555,7 +559,7 @@ public function i_open_actions_menu($activityname) {
return;
}

return new Given('I click on "' . get_string('actions', 'moodle') . '" "link" in the "' . $this->escape($activityname) . '" activity');
return new Given('I click on "a[role=\'menuitem\']" "css_element" in the "' . $this->escape($activityname) . '" activity');
}

/**
Expand Down Expand Up @@ -654,8 +658,13 @@ public function i_duplicate_activity($activityname) {
$steps[] = new Given('I open "' . $activity . '" actions menu');
}
$steps[] = new Given('I click on "' . get_string('duplicate') . '" "link" in the "' . $activity . '" activity');
$steps[] = new Given('I press "' . get_string('continue') .'"');
$steps[] = new Given('I press "' . get_string('duplicatecontcourse') .'"');
if ($this->running_javascript()) {
// Temporary wait until MDL-41030 lands.
$steps[] = new Given('I wait "4" seconds');
} else {
$steps[] = new Given('I press "' . get_string('continue') .'"');
$steps[] = new Given('I press "' . get_string('duplicatecontcourse') .'"');
}
return $steps;
}

Expand All @@ -668,14 +677,31 @@ public function i_duplicate_activity($activityname) {
* @return Given[]
*/
public function i_duplicate_activity_editing_the_new_copy_with($activityname, TableNode $data) {

$steps = array();

$activity = $this->escape($activityname);

if ($this->running_javascript()) {
$steps[] = new Given('I open "' . $activity . '" actions menu');
$steps[] = new Given('I duplicate "' . $activity . '" activity');

// Determine the future new activity xpath from the former one.
$activityliteral = $this->getSession()->getSelectorsHandler()->xpathLiteral($activityname);
$duplicatedxpath = "//li[contains(concat(' ', normalize-space(@class), ' '), ' activity ')][contains(., $activityliteral)]" .
"/following-sibling::li";
$duplicatedactionsmenuxpath = $duplicatedxpath . "/descendant::a[@role='menuitem']";

// The next sibling of the former activity will be the duplicated one, so we click on it from it's xpath as, at
// this point, it don't even exists in the DOM (the steps are executed when we return them).
$steps[] = new Given('I click on "' . $this->escape($duplicatedactionsmenuxpath) . '" "xpath_element"');

// We force the xpath as otherwise mink tries to interact with the former one.
$steps[] = new Given('I click on "' . get_string('editsettings') . '" "link" in the "' . $this->escape($duplicatedxpath) . '" "xpath_element"');
} else {
$steps[] = new Given('I click on "' . get_string('duplicate') . '" "link" in the "' . $activity . '" activity');
$steps[] = new Given('I press "' . get_string('continue') .'"');
$steps[] = new Given('I press "' . get_string('duplicatecontedit') . '"');
}
$steps[] = new Given('I click on "' . get_string('duplicate') . '" "link" in the "' . $activity . '" activity');
$steps[] = new Given('I press "' . get_string('continue') .'"');
$steps[] = new Given('I press "' . get_string('duplicatecontedit') . '"');
$steps[] = new Given('I fill the moodle form with:', $data);
$steps[] = new Given('I press "' . get_string('savechangesandreturntocourse') . '"');
return $steps;
Expand Down
4 changes: 2 additions & 2 deletions course/tests/behat/course_controls.feature
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,7 @@ Feature: Course activity controls works as expected
And I indent left "Test forum name 1" activity
And "#section-2" "css_element" <should_see_other_sections> exists
And I open "Test forum name 1" actions menu
And I click on "Update" "link" in the "Test forum name 1" activity
And I click on "Edit settings" "link" in the "Test forum name 1" activity
And I should see "Updating Forum"
And I should see "Display description on course page"
And I press "Save and return to course"
Expand Down Expand Up @@ -128,7 +128,7 @@ Feature: Course activity controls works as expected
And "#section-2" "css_element" <should_see_other_sections> exists
And I indent left "Test forum name 1" activity
And "#section-2" "css_element" <should_see_other_sections> exists
And I click on "Update" "link" in the "Test forum name 1" activity
And I click on "Edit settings" "link" in the "Test forum name 1" activity
And I should see "Updating Forum"
And I should see "Display description on course page"
And I press "Save and return to course"
Expand Down
4 changes: 2 additions & 2 deletions course/tests/behat/edit_settings.feature
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ Feature: Edit course settings
| teacher1 | C1 | editingteacher |
And I log in as "teacher1"
And I follow "Course 1"
When I follow "Edit settings"
When I click on "Edit settings" "link" in the "Administration" "block"
And I fill the moodle form with:
| Course full name | Edited course fullname |
| Course short name | Edited course shortname |
Expand All @@ -28,7 +28,7 @@ Feature: Edit course settings
And I should not see "C1"
And I should see "Edited course fullname"
And I should see "Edited course shortname"
And I follow "Edit settings"
And I click on "Edit settings" "link" in the "Administration" "block"
And the "Course full name" field should match "Edited course fullname" value
And the "Course short name" field should match "Edited course shortname" value
And the "Course summary" field should match "Edited course summary" value
Expand Down
17 changes: 4 additions & 13 deletions course/tests/behat/force_group_mode.feature
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ Feature: Force group mode in a course
And I add a "Chat" to section "1" and I fill the form with:
| Name of this chat room | Chat room |
| Description | Chat description |
And I follow "Edit settings"
And I click on "Edit settings" "link" in the "Administration" "block"

@javascript
Scenario: Forced group mode using separate groups
Expand All @@ -29,10 +29,7 @@ Feature: Force group mode in a course
| Force group mode | Yes |
When I press "Save changes"
Then "//a/child::img[contains(@alt, 'Separate groups (forced mode)')]" "xpath_element" should not exists
And "//img[contains(@alt, 'Separate groups (forced mode)')]" "xpath_element" should exists
And I click on "//img[contains(@alt, 'Separate groups (forced mode)')]" "xpath_element" in the "li.activity.chat" "css_element"
And "//a/child::img[contains(@alt, 'Separate groups (forced mode)')]" "xpath_element" should not exists
And "//img[contains(@alt, 'Separate groups (forced mode)')]" "xpath_element" should exists
And "//img[contains(@alt, 'Separate groups (forced mode)')]" "xpath_element" should not exists

@javascript
Scenario: Forced group mode using visible groups
Expand All @@ -41,10 +38,7 @@ Feature: Force group mode in a course
| Force group mode | Yes |
And I press "Save changes"
Then "//a/child::img[contains(@alt, 'Visible groups (forced mode)')]" "xpath_element" should not exists
And "//img[contains(@alt, 'Visible groups (forced mode)')]" "xpath_element" should exists
And I click on "//img[contains(@alt, 'Visible groups (forced mode)')]" "xpath_element" in the "li.activity.chat" "css_element"
And "//a/child::img[contains(@alt, 'Visible groups (forced mode)')]" "xpath_element" should not exists
And "//img[contains(@alt, 'Visible groups (forced mode)')]" "xpath_element" should exists
And "//img[contains(@alt, 'Visible groups (forced mode)')]" "xpath_element" should not exists

@javascript
Scenario: Forced group mode without groups
Expand All @@ -53,8 +47,5 @@ Feature: Force group mode in a course
| Force group mode | Yes |
And I press "Save changes"
Then "//a/child::img[contains(@alt, 'No groups (forced mode)')]" "xpath_element" should not exists
And "//img[contains(@alt, 'No groups (forced mode)')]" "xpath_element" should exists
And I click on "//img[contains(@alt, 'No groups (forced mode)')]" "xpath_element" in the "li.activity.chat" "css_element"
And "//a/child::img[contains(@alt, 'No groups (forced mode)')]" "xpath_element" should not exists
And "//img[contains(@alt, 'No groups (forced mode)')]" "xpath_element" should exists
And "//img[contains(@alt, 'No groups (forced mode)')]" "xpath_element" should not exists

4 changes: 2 additions & 2 deletions course/tests/behat/move_activities.feature
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ Feature: Activities can be moved between sections
And I should not see "Test forum name" in the "#section-1" "css_element"

Scenario: Move activities in the course home with Javascript disabled using paged mode
Given I follow "Edit settings"
Given I click on "Edit settings" "link" in the "Administration" "block"
And I fill the moodle form with:
| Course layout | Show one section per page |
And I press "Save changes"
Expand All @@ -42,7 +42,7 @@ Feature: Activities can be moved between sections
And I should not see "Test forum name" in the "#section-1" "css_element"

Scenario: Move activities in a course section with Javascript disabled using paged mode
Given I follow "Edit settings"
Given I click on "Edit settings" "link" in the "Administration" "block"
And I fill the moodle form with:
| Course layout | Show one section per page |
And I press "Save changes"
Expand Down
4 changes: 2 additions & 2 deletions course/tests/behat/move_sections.feature
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ Feature: Sections can be moved
And I should see "Test forum name" in the "#section-1" "css_element"

Scenario: Move up and down a section with Javascript disabled in the course home of a course using paged mode
Given I follow "Edit settings"
Given I click on "Edit settings" "link" in the "Administration" "block"
And I fill the moodle form with:
| Course layout | Show one section per page |
And I press "Save changes"
Expand All @@ -41,7 +41,7 @@ Feature: Sections can be moved
And I should see "Test forum name" in the "#section-1" "css_element"

Scenario: Sections can not be moved with Javascript disabled in a section page of a course using paged mode
Given I follow "Edit settings"
Given I click on "Edit settings" "link" in the "Administration" "block"
And I fill the moodle form with:
| Course layout | Show one section per page |
And I press "Save changes"
Expand Down
Loading

0 comments on commit 047a880

Please sign in to comment.