[ Index ]

PHP Cross Reference of moodle-2.8

title

Body

[close]

/availability/tests/behat/ -> edit_availability.feature (source)

   1  @core @core_availability
   2  Feature: edit_availability
   3    In order to control which students can see activities
   4    As a teacher
   5    I need to set up availability options for activities and sections
   6  
   7    # PURPOSE OF THIS TEST FEATURE:
   8    #
   9    # This test covers the user interface around editing availability conditions,
  10    # especially the JavaScript code which is not tested elsewhere (e.g. does the
  11    # 'Add restriction' dialog work). It tests both forms and also the admin
  12    # setting interface.
  13    #
  14    # This test does not check the detailed behaviour of the availability system,
  15    # which is mainly covered in PHPUnit (and, from the user interface
  16    # perspective, in the other Behat tests for each type of condition).
  17  
  18    Background:
  19      Given the following "courses" exist:
  20        | fullname | shortname | format |
  21        | Course 1 | C1        | topics |
  22      And the following "users" exist:
  23        | username |
  24        | teacher1 |
  25        | student1 |
  26      And the following "course enrolments" exist:
  27        | user     | course | role           |
  28        | teacher1 | C1     | editingteacher |
  29        | student1 | C1     | student        |
  30  
  31    Scenario: Confirm the 'enable availability' option is working
  32      When I log in as "teacher1"
  33      And I follow "Course 1"
  34      And I turn editing mode on
  35      And I add a "Page" to section "1"
  36      Then "Restrict access" "fieldset" should not exist
  37  
  38      Given I follow "C1"
  39      When I edit the section "1"
  40      Then "Restrict access" "fieldset" should not exist
  41  
  42      When I log out
  43      And I log in as "admin"
  44      And I set the following administration settings values:
  45        | Enable conditional access | 1 |
  46  
  47      When I log out
  48      And I log in as "teacher1"
  49      And I follow "Course 1"
  50      And I turn editing mode on
  51      And I add a "Page" to section "1"
  52      Then "Restrict access" "fieldset" should exist
  53  
  54      Given I follow "C1"
  55      When I edit the section "1"
  56      Then "Restrict access" "fieldset" should exist
  57  
  58    @javascript
  59    Scenario: Edit availability using settings in activity form
  60      # Set up.
  61      Given I log in as "admin"
  62      And I set the following administration settings values:
  63        | Enable conditional access | 1 |
  64      And I log out
  65      And I log in as "teacher1"
  66      And I follow "Course 1"
  67  
  68      # Add a Page and check it has None in so far.
  69      And I turn editing mode on
  70      And I add a "Page" to section "1"
  71      And I expand all fieldsets
  72      Then I should see "None" in the "Restrict access" "fieldset"
  73  
  74      # Add a Date restriction and check it appears.
  75      When I click on "Add restriction..." "button"
  76      Then "Add restriction..." "dialogue" should be visible
  77      When I click on "Date" "button" in the "Add restriction..." "dialogue"
  78      Then "Add restriction..." "dialogue" should not exist
  79      And I should not see "None" in the "Restrict access" "fieldset"
  80      And "Restriction type" "select" should be visible
  81      And I should see "Date" in the "Restrict access" "fieldset"
  82      And ".availability-item .availability-eye img" "css_element" should be visible
  83      And ".availability-item .availability-delete img" "css_element" should be visible
  84      And the "alt" attribute of ".availability-item .availability-eye img" "css_element" should contain "Displayed greyed-out"
  85  
  86      # Toggle the eye icon.
  87      When I click on ".availability-item .availability-eye img" "css_element"
  88      Then the "alt" attribute of ".availability-item .availability-eye img" "css_element" should contain "Hidden entirely"
  89      When I click on ".availability-item .availability-eye img" "css_element"
  90      Then the "alt" attribute of ".availability-item .availability-eye img" "css_element" should contain "Displayed greyed-out"
  91  
  92      # Click the delete button.
  93      When I click on ".availability-item .availability-delete img" "css_element"
  94      Then I should not see "Date" in the "Restrict access" "fieldset"
  95  
  96      # Add a nested restriction set and check it appears.
  97      When I click on "Add restriction..." "button"
  98      And I click on "Restriction set" "button" in the "Add restriction..." "dialogue"
  99      Then ".availability-children .availability-list" "css_element" should be visible
 100      And I should see "None" in the ".availability-children .availability-list" "css_element"
 101      And I should see "Please set" in the ".availability-children .availability-list" "css_element"
 102      And I should see "Add restriction" in the ".availability-children .availability-list" "css_element"
 103  
 104      # Click on the button to add a restriction inside the nested set.
 105      When I click on "Add restriction..." "button" in the ".availability-children .availability-list" "css_element"
 106      And I click on "Date" "button" in the "Add restriction..." "dialogue"
 107      Then I should not see "None" in the ".availability-children .availability-list" "css_element"
 108      And I should not see "Please set" in the ".availability-children .availability-list" "css_element"
 109      And I should see "Date" in the ".availability-children .availability-list" "css_element"
 110  
 111      # OK, let's delete the date inside the nested set...
 112      When I click on ".availability-item .availability-delete img" "css_element" in the ".availability-item" "css_element"
 113      Then I should not see "Date" in the ".availability-children .availability-list" "css_element"
 114      And I should see "None" in the ".availability-children .availability-list" "css_element"
 115  
 116      # ...and the nested set itself.
 117      When I click on ".availability-none .availability-delete img" "css_element"
 118      Then ".availability-children .availability-list" "css_element" should not exist
 119  
 120      # Add two dates so we can check the connectors.
 121      When I click on "Add restriction..." "button"
 122      And I click on "Date" "button" in the "Add restriction..." "dialogue"
 123      And I click on "Add restriction..." "button"
 124      And I click on "Date" "button" in the "Add restriction..." "dialogue"
 125      Then I should see "and" in the "Restrict access" "fieldset"
 126      And "Required restrictions" "select" should be visible
 127  
 128      # Try changing the connector type.
 129      When I set the field "Required restrictions" to "any"
 130      Then I should not see "and" in the "Restrict access" "fieldset"
 131      And I should see "or" in the "Restrict access" "fieldset"
 132  
 133      # Now delete one of the dates and check the connector goes away.
 134      When I click on ".availability-item .availability-delete img" "css_element"
 135      Then I should not see "or" in the "Restrict access" "fieldset"
 136  
 137      # Add a nested restriction set with two dates so there will be inner connector.
 138      When I click on "Add restriction..." "button"
 139      And I click on "Restriction set" "button" in the "Add restriction..." "dialogue"
 140      And I click on "Add restriction..." "button" in the ".availability-children .availability-list" "css_element"
 141      And I click on "Date" "button" in the "Add restriction..." "dialogue"
 142      And I click on "Add restriction..." "button" in the ".availability-children .availability-list" "css_element"
 143      And I click on "Date" "button" in the "Add restriction..." "dialogue"
 144      Then I should see "and" in the ".availability-children .availability-list .availability-connector" "css_element"
 145  
 146      # Check changing the outer one does not affect the inner one.
 147      When I set the field "Required restrictions" to "all"
 148      Then I should not see "or" in the "Restrict access" "fieldset"
 149      When I set the field "Required restrictions" to "any"
 150      Then I should see "or" in the "Restrict access" "fieldset"
 151      And I should not see "or" in the ".availability-children .availability-list .availability-connector" "css_element"
 152  
 153    @javascript
 154    Scenario: Edit availability using settings in section form
 155      # Set up.
 156      Given I log in as "admin"
 157      And I set the following administration settings values:
 158        | Enable conditional access | 1 |
 159      And I log out
 160      And I log in as "teacher1"
 161      And I follow "Course 1"
 162      And I turn editing mode on
 163  
 164      # Edit a section
 165      When I edit the section "1"
 166      And I expand all fieldsets
 167      Then I should see "None" in the "Restrict access" "fieldset"
 168  
 169      # Add a Date restriction and check it appears.
 170      When I click on "Add restriction..." "button"
 171      When I click on "Date" "button" in the "Add restriction..." "dialogue"
 172      And I should not see "None" in the "Restrict access" "fieldset"
 173      And "Restriction type" "select" should be visible
 174      And I should see "Date" in the "Restrict access" "fieldset"


Generated: Fri Nov 28 20:29:05 2014 Cross-referenced by PHPXref 0.7.1