Skip to content

Commit

Permalink
CONTRIB-6184 mod_checklist: separate out behat tests for show/hide items
Browse files Browse the repository at this point in the history
  • Loading branch information
davosmith committed Mar 14, 2016
1 parent 27ee7ae commit 9a7f562
Show file tree
Hide file tree
Showing 3 changed files with 59 additions and 37 deletions.
38 changes: 1 addition & 37 deletions tests/behat/create_edit_checklist.feature
Original file line number Diff line number Diff line change
Expand Up @@ -13,20 +13,12 @@ Feature: I can create and update a checklist
| user | course | role |
| teacher1 | C1 | editingteacher |
| student1 | C1 | student |
And the following "activities" exist:
| activity | course | section | idnumber | name | intro |
| assign | C1 | 1 | assign1 | Test assignment | This is an assignment |
| data | C1 | 1 | data1 | Test database | This is a database |
And I log in as "teacher1"
And I follow "Course 1"
And I turn editing mode on
And I add a "Checklist" to section "1" and I fill the form with:
| Checklist | Test checklist |
| Introduction | This is a checklist |
And I add a "Checklist" to section "2" and I fill the form with:
| Checklist | Test auto-pop checklist |
| Introduction | This is an auto-populated checklist |
| Show course modules in checklist | Whole course |
And I log out

Scenario: When I add no items to a checklist a student sees no items
Expand All @@ -37,15 +29,6 @@ Feature: I can create and update a checklist
And I should see "This is a checklist"
And I should see "No items in the checklist"

Scenario: When viewing an auto-populated checklist, a student should see items corresponding to the course modules
When I log in as "student1"
And I follow "Course 1"
And I follow "Test auto-pop checklist"
Then I should see "Test auto-pop checklist"
And I should see "This is an auto-populated checklist"
And I should see "Test assignment"
And I should see "Test database"

Scenario: When I add some items to a checklist a student should see them
Given I log in as "teacher1"
And I follow "Course 1"
Expand Down Expand Up @@ -216,23 +199,4 @@ Feature: I can create and update a checklist
Then I should see "All items"
And I should see "Required items"
And "label.itemheading" "css_element" should appear before "You must tick this" "text"
And "You must tick this" "text" should appear before "label.itemoptional" "css_element"

Scenario: When I select multiple items and click the 'Show/hide' button, the items' visibility should toggle
Given I log in as "teacher1"
And I follow "Course 1"
And I follow "Test auto-pop checklist"
And I follow "Edit checklist"
And I set the field with xpath "//input[@type='checkbox' and @title='Test assignment']" to "1"
And I set the field with xpath "//input[@type='checkbox' and @title='Test database']" to "1"
And I press "Show/hide selected items"
And I set the field with xpath "//input[@type='checkbox' and @title='Test database']" to "1"
And I set the field with xpath "//input[@type='checkbox' and @title='Test checklist']" to "1"
And I press "Show/hide selected items"
And I log out
When I log in as "student1"
And I follow "Course 1"
And I follow "Test auto-pop checklist"
Then I should not see "Test assignment"
And I should see "Test database"
And I should not see "Test checklist"
And "You must tick this" "text" should appear before "label.itemoptional" "css_element"
56 changes: 56 additions & 0 deletions tests/behat/show_hide_multiple_items.feature
Original file line number Diff line number Diff line change
@@ -0,0 +1,56 @@
@mod @mod_checklist @checklist
Feature: Multiple autopopulate items can be shown/hidden at once

Background:
Given the following "courses" exist:
| fullname | shortname |
| Course 1 | C1 |
And the following "users" exist:
| username | firstname | lastname | email |
| teacher1 | Teacher | 1 | teacher1@asd.com |
| student1 | Student | 1 | student1@asd.com |
And the following "course enrolments" exist:
| user | course | role |
| teacher1 | C1 | editingteacher |
| student1 | C1 | student |
And the following "activities" exist:
| activity | course | section | idnumber | name | intro |
| assign | C1 | 1 | assign1 | Test assignment | This is an assignment |
| data | C1 | 1 | data1 | Test database | This is a database |
| checklist | C1 | 1 | checklist1 | Test checklist | This is a checklist |
And I log in as "teacher1"
And I follow "Course 1"
And I turn editing mode on
And I add a "Checklist" to section "1" and I fill the form with:
| Checklist | Test auto-pop checklist |
| Introduction | This is an auto-populated checklist |
| Show course modules in checklist | Whole course |
And I log out

Scenario: When viewing an auto-populated checklist, a student should see items corresponding to the course modules
When I log in as "student1"
And I follow "Course 1"
And I follow "Test auto-pop checklist"
Then I should see "Test auto-pop checklist"
And I should see "This is an auto-populated checklist"
And I should see "Test assignment"
And I should see "Test database"

Scenario: When I select multiple items and click the 'Show/hide' button, the items' visibility should toggle
Given I log in as "teacher1"
And I follow "Course 1"
And I follow "Test auto-pop checklist"
And I follow "Edit checklist"
And I set the field with xpath "//input[@type='checkbox' and @title='Test assignment']" to "1"
And I set the field with xpath "//input[@type='checkbox' and @title='Test database']" to "1"
And I press "Show/hide selected items"
And I set the field with xpath "//input[@type='checkbox' and @title='Test database']" to "1"
And I set the field with xpath "//input[@type='checkbox' and @title='Test checklist']" to "1"
And I press "Show/hide selected items"
And I log out
When I log in as "student1"
And I follow "Course 1"
And I follow "Test auto-pop checklist"
Then I should not see "Test assignment" in the "#region-main" "css_element"
And I should see "Test database" in the "#region-main" "css_element"
And I should not see "Test checklist" in the "#region-main" "css_element"
2 changes: 2 additions & 0 deletions tests/generator/lib.php
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,8 @@
*/

defined('MOODLE_INTERNAL') || die();
global $CFG;
require_once($CFG->dirroot.'/mod/checklist/lib.php');

class mod_checklist_generator extends testing_module_generator {
public function create_instance($record = null, array $options = null) {
Expand Down

0 comments on commit 9a7f562

Please sign in to comment.