Automatically generated installer lang files
[moodle.git] / availability / tests / behat / display_availability.feature
blob3ea2a02f49bd405fe315316849fe4e78891bc342
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
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.)
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 the following "activities" exist:
38       | activity | course | section | name   |
39       | page     | C1     | 1       | Page 1 |
40       | page     | C1     | 2       | Page 2 |
41       | page     | C1     | 3       | Page 3 |
43   @javascript
44   Scenario: Activity availability display
45     # Set up.
46     Given I am on the "Page 1" "page activity editing" page logged in as "teacher1"
47     And I expand all fieldsets
48     And I press "Add restriction..."
49     And I click on "Date" "button" in the "Add restriction..." "dialogue"
50     And I set the field "direction" to "until"
51     And I set the field "x[year]" to "2013"
52     And I set the field "x[month]" to "March"
53     And I press "Save and return to course"
55     # Add a Page with 2 restrictions - one is set to hide from students if failed.
56     And I am on the "Page 2" "page activity editing" page
57     And I expand all fieldsets
58     And I press "Add restriction..."
59     And I click on "Date" "button" in the "Add restriction..." "dialogue"
60     And I set the field "direction" to "until"
61     And I set the field "x[year]" to "2013"
62     And I set the field "x[month]" to "March"
63     And I click on ".availability-item .availability-eye img" "css_element"
64     And I press "Add restriction..."
65     And I click on "User profile" "button" in the "Add restriction..." "dialogue"
66     And I set the field "User profile field" to "Email address"
67     And I set the field "Value to compare against" to "email@example.com"
68     And I set the field "Method of comparison" to "is equal to"
69     And I press "Save and return to course"
71     # Page 1 should show in single-line format, showing the date
72     Then I should see "Available until" in the "Page 1" "core_availability > Activity availability"
73     And I should see "2013" in the "Page 1" "core_availability > Activity availability"
74     And I should see "2013" in the "Page 1" "core_availability > Activity availability"
75     And "li" "css_element" should not exist in the "Page 1" "core_availability > Activity availability"
76     And "Show more" "button" should not exist in the "Page 1" "core_availability > Activity availability"
78     # Page 2 should show in list format.
79     And "li" "css_element" should exist in the "Page 2" "core_availability > Activity availability"
80     And I should see "Not available unless:" in the "Page 2" "core_availability > Activity availability"
81     And I should see "It is before" in the "Page 2" "core_availability > Activity availability"
82     And I should see "hidden otherwise" in the "Page 2" "core_availability > Activity availability"
83     And I click on "Show more" "button" in the "Page 2" "activity"
84     And I should see "Email address" in the "Page 2" "core_availability > Activity availability"
85     And I click on "Show less" "button" in the "Page 2" "core_availability > Activity availability"
86     And I should not see "Email address" in the "Page 2" "core_availability > Activity availability"
88     # Page 3 should not have available info.
89     And "Page 3" "core_availability > Activity availability" should not exist
91     # Change to student view.
92     Given I am on the "C1" "Course" page logged in as "student1"
94     # Page 1 display still there but should not be a link.
95     Then I should see "Page 1" in the "#section-1" "css_element"
96     And ".activity-instance a" "css_element" should not exist in the "Topic 1" "section"
98     # Date display should be present.
99     And I should see "Available until" in the "Topic 1" "section"
101     # Page 2 display not there at all
102     And I should not see "Page 2" in the "region-main" "region"
104     # Page 3 display and link
105     And I should see "Page 3" in the "region-main" "region"
106     And ".activity-instance a" "css_element" should exist in the "Topic 3" "section"
108   @javascript
109   Scenario: Section availability display
110     # Set up.
111     Given I am on the "C1" "Course" page logged in as "teacher1"
112     And I turn editing mode on
114     # Add a restriction to section 1 (visible to students).
115     When I edit the section "1"
116     And I expand all fieldsets
117     And I press "Add restriction..."
118     And I click on "Date" "button" in the "Add restriction..." "dialogue"
119     And I set the field "direction" to "until"
120     And I set the field "x[year]" to "2013"
121     And I press "Add restriction..."
122     And I click on "User profile" "button" in the "Add restriction..." "dialogue"
123     And I set the field "User profile field" to "Email address"
124     And I set the field "Value to compare against" to "email@example.com"
125     And I set the field "Method of comparison" to "is equal to"
126     And I press "Save changes"
128     # Section 2 is the same but hidden from students
129     When I edit the section "2"
130     And I expand all fieldsets
131     And I press "Add restriction..."
132     And I click on "Date" "button" in the "Add restriction..." "dialogue"
133     And I set the field "direction" to "until"
134     And I set the field "x[year]" to "2013"
135     And I click on ".availability-item .availability-eye img" "css_element"
136     And I press "Save changes"
138     # This is necessary because otherwise it fails in Chrome, see MDL-44959
139     And I am on "Course 1" course homepage
141     # Check display
142     Then I should see "Not available unless" in the "section-1" "core_availability > Section availability"
143     And I should see "Available until" in the "section-2" "core_availability > Section availability"
144     And I should see "hidden otherwise" in the "section-2" "core_availability > Section availability"
146     # Change to student view.
147     Given I am on the "Course 1" "Course" page logged in as "student1"
149     # The contents of both sections should be hidden.
150     Then I should not see "Page 1" in the "region-main" "region"
151     And I should not see "Page 2" in the "region-main" "region"
152     And I should see "Page 3" in the "region-main" "region"
154     # Section 1 should be visible and show info.
155     And I should see "Topic 1" in the "region-main" "region"
156     And I should see "Not available unless" in the "section-1" "core_availability > Section availability"
157     And I click on "Show more" "button" in the "section-1" "core_availability > Section availability"
158     And I should see "Email address" in the "section-1" "core_availability > Section availability"
159     And I click on "Show less" "button" in the "section-1" "core_availability > Section availability"
160     And I should not see "Email address" in the "section-1" "core_availability > Section availability"
162     # Section 2 should not be available at all
163     And I should not see "Topic 2" in the "region-main" "region"