Skip to content

Commit

Permalink
CONTRIB-6184 mod_checklist: Behat test for bulk auto-pop display toggle
Browse files Browse the repository at this point in the history
  • Loading branch information
tonyjbutler committed Mar 14, 2016
1 parent 2cfbc51 commit 27ee7ae
Show file tree
Hide file tree
Showing 2 changed files with 39 additions and 2 deletions.
3 changes: 2 additions & 1 deletion locallib.php
Original file line number Diff line number Diff line change
Expand Up @@ -1487,7 +1487,8 @@ protected function view_edit_items() {

echo html_writer::start_span('', array('style' => 'display: inline-block; width: 16px;'));
if ($autoitem && $item->hidden != CHECKLIST_HIDDEN_BYMODULE) {
echo html_writer::checkbox('items[' . $item->id . ']', $item->id, false);
echo html_writer::checkbox('items[' . $item->id . ']', $item->id, false, '',
array('title' => $item->displaytext));
}
echo html_writer::end_span();

Expand Down
38 changes: 37 additions & 1 deletion tests/behat/create_edit_checklist.feature
Original file line number Diff line number Diff line change
Expand Up @@ -13,12 +13,20 @@ 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 @@ -29,6 +37,15 @@ 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 @@ -199,4 +216,23 @@ 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"
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"

0 comments on commit 27ee7ae

Please sign in to comment.