[ Index ]

PHP Cross Reference of moodle-2.8

title

Body

[close]

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

   1  @core @core_availability
   2  Feature: display_availability
   3    In order to know which activities are available
   4    As a user
   5    I need to see appropriate availability restrictions for activities and sections
   6  
   7    # PURPOSE OF THIS TEST FEATURE:
   8    #
   9    # This test is to do a basic check of the user interface relating to display
  10    # of availability conditions - i.e. if there's a condition, does it show up;
  11    # are we doing the HTML correctly; does it correctly hide an activity where
  12    # the options are set to not show it at all.
  13    #
  14    # Things this test is not:
  15    # - It is not a test of the date condition specifically. The date condition is
  16    #   only used as an example in order to get the availability information to
  17    #   display. (The date condition has its own Behat test in
  18    #   /availability/condition/date/tests/behat.)
  19    # - It is not a complete test of the logic. This is supposed to be a shallow
  20    #   check of the user interface parts and doesn't cover all logical
  21    #   possibilities. The logic is tested in PHPUnit tests instead, which are
  22    #   much more efficient. (Again there are unit tests for the overall system
  23    #   and for each condition type.)
  24  
  25    Background:
  26      Given the following "courses" exist:
  27        | fullname | shortname | format |
  28        | Course 1 | C1        | topics |
  29      And the following "users" exist:
  30        | username |
  31        | teacher1 |
  32        | student1 |
  33      And the following "course enrolments" exist:
  34        | user     | course | role           |
  35        | teacher1 | C1     | editingteacher |
  36        | student1 | C1     | student        |
  37      And I log in as "admin"
  38      And I set the following administration settings values:
  39        | Enable conditional access | 1 |
  40      And I log out
  41  
  42    @javascript
  43    Scenario: Activity availability display
  44      # Set up.
  45      Given I log in as "teacher1"
  46      And I follow "Course 1"
  47      And I turn editing mode on
  48  
  49      # Add a Page with 1 restriction.
  50      When I add a "Page" to section "1"
  51      And I set the following fields to these values:
  52        | Name         | Page 1 |
  53        | Description  | Test   |
  54        | Page content | Test   |
  55      And I expand all fieldsets
  56      And I press "Add restriction..."
  57      And I click on "Date" "button" in the "Add restriction..." "dialogue"
  58      And I set the field "direction" to "until"
  59      And I set the field "x[year]" to "2013"
  60      And I set the field "x[month]" to "March"
  61      And I press "Save and return to course"
  62  
  63      # Add a Page with 2 restrictions - one is set to hide from students if failed.
  64      And I add a "Page" to section "2"
  65      And I set the following fields to these values:
  66        | Name         | Page 2 |
  67        | Description  | Test   |
  68        | Page content | Test   |
  69      And I expand all fieldsets
  70      And I press "Add restriction..."
  71      And I click on "Date" "button" in the "Add restriction..." "dialogue"
  72      And I set the field "direction" to "until"
  73      And I set the field "x[year]" to "2013"
  74      And I set the field "x[month]" to "March"
  75      And I click on ".availability-item .availability-eye img" "css_element"
  76      And I press "Add restriction..."
  77      And I click on "User profile" "button" in the "Add restriction..." "dialogue"
  78      And I set the field "User profile field" to "Email address"
  79      And I set the field "Value to compare against" to "[email protected]"
  80      And I set the field "Method of comparison" to "is equal to"
  81      And I press "Save and return to course"
  82  
  83      # Add another Page with no restrictions.
  84      And I add a "Page" to section "3" and I fill the form with:
  85        | Name         | Page 3 |
  86        | Description  | Test   |
  87        | Page content | Test   |
  88  
  89      # Page 1 should show in single-line format, showing the date
  90      Then I should see "Available until" in the "#section-1 .availabilityinfo" "css_element"
  91      And I should see "2013" in the "#section-1 .availabilityinfo" "css_element"
  92      And I should see "2013" in the "#section-1 .availabilityinfo" "css_element"
  93      And "li" "css_element" should not exist in the "#section-1 .availabilityinfo" "css_element"
  94  
  95      # Page 2 should show in list format.
  96      And "li" "css_element" should exist in the "#section-2 .availabilityinfo" "css_element"
  97      And I should see "Not available unless:" in the "#section-2 .availabilityinfo" "css_element"
  98      And I should see "It is before" in the "#section-2 .availabilityinfo" "css_element"
  99      And I should see "hidden otherwise" in the "#section-2 .availabilityinfo" "css_element"
 100      And I should see "Email address" in the "#section-2 .availabilityinfo" "css_element"
 101  
 102      # Page 3 should not have available info.
 103      And "#section-3 .availabilityinfo" "css_element" should not exist
 104  
 105      # Change to student view.
 106      Given I log out
 107      And I log in as "student1"
 108      And I follow "Course 1"
 109  
 110      # Page 1 display still there but should be dimmed and not a link.
 111      Then I should see "Page 1" in the "#section-1 .dimmed_text" "css_element"
 112      And ".activityinstance a" "css_element" should not exist in the "#section-1" "css_element"
 113  
 114      # Date display should be present.
 115      And I should see "Available until" in the "#section-1" "css_element"
 116  
 117      # Page 2 display not there at all
 118      And I should not see "Page 2" in the "region-main" "region"
 119  
 120      # Page 3 display and link
 121      And I should see "Page 3" in the "region-main" "region"
 122      And ".activityinstance a" "css_element" should exist in the "#section-3" "css_element"
 123  
 124    @javascript
 125    Scenario: Section availability display
 126      # Set up.
 127      Given I log in as "teacher1"
 128      And I follow "Course 1"
 129      And I turn editing mode on
 130  
 131      # Add a restriction to section 1 (visible to students).
 132      When I edit the section "1"
 133      And I expand all fieldsets
 134      And I press "Add restriction..."
 135      And I click on "Date" "button" in the "Add restriction..." "dialogue"
 136      And I set the field "direction" to "until"
 137      And I set the field "x[year]" to "2013"
 138      And I press "Save changes"
 139  
 140      # Section 2 is the same but hidden from students
 141      When I edit the section "2"
 142      And I expand all fieldsets
 143      And I press "Add restriction..."
 144      And I click on "Date" "button" in the "Add restriction..." "dialogue"
 145      And I set the field "direction" to "until"
 146      And I set the field "x[year]" to "2013"
 147      And I click on ".availability-item .availability-eye img" "css_element"
 148      And I press "Save changes"
 149  
 150      # This is necessary because otherwise it fails in Chrome, see MDL-44959
 151      And I am on homepage
 152      And I follow "Course 1"
 153  
 154      # Add Pages to each section.
 155      And I add a "Page" to section "1" and I fill the form with:
 156        | Name         | Page 1 |
 157        | Description  | Test   |
 158        | Page content | Test   |
 159      And I add a "Page" to section "2" and I fill the form with:
 160        | Name         | Page 2 |
 161        | Description  | Test   |
 162        | Page content | Test   |
 163      And I add a "Page" to section "3" and I fill the form with:
 164        | Name         | Page 3 |
 165        | Description  | Test   |
 166        | Page content | Test   |
 167  
 168      # Check display
 169      Then I should see "Available until" in the "#section-1 .availabilityinfo" "css_element"
 170      And I should see "Available until" in the "#section-2 .availabilityinfo" "css_element"
 171      And I should see "hidden otherwise" in the "#section-2 .availabilityinfo" "css_element"
 172  
 173      # Change to student view.
 174      Given I log out
 175      And I log in as "student1"
 176      And I follow "Course 1"
 177  
 178      # The contents of both sections should be hidden.
 179      Then I should not see "Page 1" in the "region-main" "region"
 180      And I should not see "Page 2" in the "region-main" "region"
 181      And I should see "Page 3" in the "region-main" "region"
 182  
 183      # Section 1 should be visible and show info.
 184      And I should see "Topic 1" in the "region-main" "region"
 185      And I should see "Available until" in the "#section-1 .availabilityinfo" "css_element"
 186  
 187      # Section 2 should not be available at all
 188      And I should not see "Topic 2" in the "region-main" "region"


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