1 |
efrain |
1 |
@core @core_availability
|
|
|
2 |
Feature: Display availability for activities and sections
|
|
|
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 "course" exists:
|
|
|
27 |
| fullname | Course 1 |
|
|
|
28 |
| shortname | C1 |
|
|
|
29 |
| format | topics |
|
|
|
30 |
| initsections | 1 |
|
|
|
31 |
And the following "users" exist:
|
|
|
32 |
| username |
|
|
|
33 |
| teacher1 |
|
|
|
34 |
| student1 |
|
|
|
35 |
And the following "course enrolments" exist:
|
|
|
36 |
| user | course | role |
|
|
|
37 |
| teacher1 | C1 | editingteacher |
|
|
|
38 |
| student1 | C1 | student |
|
|
|
39 |
And the following "activities" exist:
|
|
|
40 |
| activity | course | section | name |
|
|
|
41 |
| page | C1 | 1 | Page 1 |
|
|
|
42 |
| page | C1 | 2 | Page 2 |
|
|
|
43 |
| page | C1 | 3 | Page 3 |
|
|
|
44 |
|
|
|
45 |
@javascript
|
|
|
46 |
Scenario: Activity availability display
|
|
|
47 |
# Set up.
|
|
|
48 |
Given I am on the "Page 1" "page activity editing" page logged in as "teacher1"
|
|
|
49 |
And I expand all fieldsets
|
|
|
50 |
And I press "Add restriction..."
|
|
|
51 |
And I click on "Date" "button" in the "Add restriction..." "dialogue"
|
|
|
52 |
And I set the field "direction" to "until"
|
|
|
53 |
And I set the field "x[year]" to "2013"
|
|
|
54 |
And I set the field "x[month]" to "March"
|
|
|
55 |
And I press "Save and return to course"
|
|
|
56 |
|
|
|
57 |
# Add a Page with 2 restrictions - one is set to hide from students if failed.
|
|
|
58 |
And I am on the "Page 2" "page activity editing" page
|
|
|
59 |
And I expand all fieldsets
|
|
|
60 |
And I press "Add restriction..."
|
|
|
61 |
And I click on "Date" "button" in the "Add restriction..." "dialogue"
|
|
|
62 |
And I set the field "direction" to "until"
|
|
|
63 |
And I set the field "x[year]" to "2013"
|
|
|
64 |
And I set the field "x[month]" to "March"
|
|
|
65 |
And I click on ".availability-item .availability-eye img" "css_element"
|
|
|
66 |
And I press "Add restriction..."
|
|
|
67 |
And I click on "User profile" "button" in the "Add restriction..." "dialogue"
|
|
|
68 |
And I set the field "User profile field" to "Email address"
|
|
|
69 |
And I set the field "Value to compare against" to "email@example.com"
|
|
|
70 |
And I set the field "Method of comparison" to "is equal to"
|
|
|
71 |
And I press "Save and return to course"
|
|
|
72 |
|
|
|
73 |
# Page 1 should show in single-line format, showing the date
|
|
|
74 |
Then I should see "Available until" in the "Page 1" "core_availability > Activity availability"
|
|
|
75 |
And I should see "2013" in the "Page 1" "core_availability > Activity availability"
|
|
|
76 |
And I should see "2013" in the "Page 1" "core_availability > Activity availability"
|
|
|
77 |
And "li" "css_element" should not exist in the "Page 1" "core_availability > Activity availability"
|
|
|
78 |
And "Show more" "button" should not exist in the "Page 1" "core_availability > Activity availability"
|
|
|
79 |
|
|
|
80 |
# Page 2 should show in list format.
|
|
|
81 |
And "li" "css_element" should exist in the "Page 2" "core_availability > Activity availability"
|
|
|
82 |
And I should see "Not available unless:" in the "Page 2" "core_availability > Activity availability"
|
|
|
83 |
And I should see "It is before" in the "Page 2" "core_availability > Activity availability"
|
|
|
84 |
And I should see "hidden otherwise" in the "Page 2" "core_availability > Activity availability"
|
|
|
85 |
And I click on "Show more" "button" in the "Page 2" "activity"
|
|
|
86 |
And I should see "Email address" in the "Page 2" "core_availability > Activity availability"
|
|
|
87 |
And I click on "Show less" "button" in the "Page 2" "core_availability > Activity availability"
|
|
|
88 |
And I should not see "Email address" in the "Page 2" "core_availability > Activity availability"
|
|
|
89 |
|
|
|
90 |
# Page 3 should not have available info.
|
|
|
91 |
And "Page 3" "core_availability > Activity availability" should not exist
|
|
|
92 |
|
|
|
93 |
# Change to student view.
|
|
|
94 |
Given I am on the "C1" "Course" page logged in as "student1"
|
|
|
95 |
|
|
|
96 |
# Page 1 display still there but should not be a link.
|
|
|
97 |
Then I should see "Page 1" in the "#section-1" "css_element"
|
|
|
98 |
And ".activity-instance a" "css_element" should not exist in the "Section 1" "section"
|
|
|
99 |
|
|
|
100 |
# Date display should be present.
|
|
|
101 |
And I should see "Available until" in the "Section 1" "section"
|
|
|
102 |
|
|
|
103 |
# Page 2 display not there at all
|
|
|
104 |
And I should not see "Page 2" in the "region-main" "region"
|
|
|
105 |
|
|
|
106 |
# Page 3 display and link
|
|
|
107 |
And I should see "Page 3" in the "region-main" "region"
|
|
|
108 |
And ".activity-instance a" "css_element" should exist in the "Section 3" "section"
|
|
|
109 |
|
|
|
110 |
@javascript
|
|
|
111 |
Scenario: Section availability display
|
|
|
112 |
# Set up.
|
|
|
113 |
Given I am on the "C1" "Course" page logged in as "teacher1"
|
|
|
114 |
And I turn editing mode on
|
|
|
115 |
|
|
|
116 |
# Add a restriction to section 1 (visible to students).
|
|
|
117 |
When I edit the section "1"
|
|
|
118 |
And I expand all fieldsets
|
|
|
119 |
And I press "Add restriction..."
|
|
|
120 |
And I click on "Date" "button" in the "Add restriction..." "dialogue"
|
|
|
121 |
And I set the field "direction" to "until"
|
|
|
122 |
And I set the field "x[year]" to "2013"
|
|
|
123 |
And I press "Add restriction..."
|
|
|
124 |
And I click on "User profile" "button" in the "Add restriction..." "dialogue"
|
|
|
125 |
And I set the field "User profile field" to "Email address"
|
|
|
126 |
And I set the field "Value to compare against" to "email@example.com"
|
|
|
127 |
And I set the field "Method of comparison" to "is equal to"
|
|
|
128 |
And I press "Save changes"
|
|
|
129 |
|
|
|
130 |
# Section 2 is the same but hidden from students
|
|
|
131 |
And I am on "Course 1" course homepage
|
|
|
132 |
And I edit the section "2"
|
|
|
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 click on ".availability-item .availability-eye img" "css_element"
|
|
|
139 |
And I press "Save changes"
|
|
|
140 |
|
|
|
141 |
# This is necessary because otherwise it fails in Chrome, see MDL-44959
|
|
|
142 |
And I am on "Course 1" course homepage
|
|
|
143 |
|
|
|
144 |
# Check display
|
|
|
145 |
Then I should see "Not available unless" in the "section-1" "core_availability > Section availability"
|
|
|
146 |
And I should see "Available until" in the "section-2" "core_availability > Section availability"
|
|
|
147 |
And I should see "hidden otherwise" in the "section-2" "core_availability > Section availability"
|
|
|
148 |
|
|
|
149 |
# Change to student view.
|
|
|
150 |
Given I am on the "Course 1" "Course" page logged in as "student1"
|
|
|
151 |
|
|
|
152 |
# The contents of both sections should be hidden.
|
|
|
153 |
Then I should not see "Page 1" in the "region-main" "region"
|
|
|
154 |
And I should not see "Page 2" in the "region-main" "region"
|
|
|
155 |
And I should see "Page 3" in the "region-main" "region"
|
|
|
156 |
|
|
|
157 |
# Section 1 should be visible and show info.
|
|
|
158 |
And I should see "Section 1" in the "region-main" "region"
|
|
|
159 |
And I should see "Not available unless" in the "section-1" "core_availability > Section availability"
|
|
|
160 |
And I click on "Show more" "button" in the "section-1" "core_availability > Section availability"
|
|
|
161 |
And I should see "Email address" in the "section-1" "core_availability > Section availability"
|
|
|
162 |
And I click on "Show less" "button" in the "section-1" "core_availability > Section availability"
|
|
|
163 |
And I should not see "Email address" in the "section-1" "core_availability > Section availability"
|
|
|
164 |
|
|
|
165 |
# Section 2 should not be available at all
|
|
|
166 |
And I should not see "Section 2" in the "region-main" "region"
|