diff --git a/tests/behat/create_edit_checklist.feature b/tests/behat/create_edit_checklist.feature index 352bdcb0..85d349a7 100644 --- a/tests/behat/create_edit_checklist.feature +++ b/tests/behat/create_edit_checklist.feature @@ -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 @@ -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" @@ -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" \ No newline at end of file + And "You must tick this" "text" should appear before "label.itemoptional" "css_element" \ No newline at end of file diff --git a/tests/behat/show_hide_multiple_items.feature b/tests/behat/show_hide_multiple_items.feature new file mode 100644 index 00000000..0aa0519e --- /dev/null +++ b/tests/behat/show_hide_multiple_items.feature @@ -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" diff --git a/tests/generator/lib.php b/tests/generator/lib.php index e8b7f350..55af544a 100644 --- a/tests/generator/lib.php +++ b/tests/generator/lib.php @@ -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) {