Skip to content

Commit 455fa73

Browse files
committed
Add Behat tests for all display mode combinations
1 parent 0f17a88 commit 455fa73

File tree

1 file changed

+144
-0
lines changed

1 file changed

+144
-0
lines changed

tests/behat/display_modes.feature

Lines changed: 144 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,144 @@
1+
@block @block_course_contents @javascript
2+
#
3+
# Note we need @javascript here only because there seems to be a bug in non-js mode
4+
# that Behat does not uncheck an advcheckbox field.
5+
#
6+
Feature: Configuring various display modes how the course sections are displayed
7+
In order to help students to navigate through the course
8+
As a teacher
9+
I need to be able to configure how the block displays the course contents
10+
11+
Background:
12+
Given the following "users" exist:
13+
| username | firstname | lastname | email |
14+
| teacher1 | Teacher | 1 | teacher1@example.com |
15+
And the following "courses" exist:
16+
| fullname | shortname | format | coursedisplay | numsections |
17+
| Course 1 | C1 | topics | 0 | 3 |
18+
And the following "course enrolments" exist:
19+
| user | course | role |
20+
| teacher1 | C1 | editingteacher |
21+
And I log in as "teacher1"
22+
And I follow "Course 1"
23+
And I turn editing mode on
24+
# Rename the general section (the first click is needed in js mode only).
25+
And I click on "Edit" "link" in the "li#section-0" "css_element"
26+
And I click on "Edit section" "link" in the "li#section-0" "css_element"
27+
And I set the following fields to these values:
28+
| Use default section name | 0 |
29+
| name | Welcome to C1 |
30+
And I press "Save changes"
31+
# Add a summary text to the topic 1 section.
32+
And I click on "Edit" "link" in the "li#section-1" "css_element"
33+
And I click on "Edit topic" "link" in the "li#section-1" "css_element"
34+
And I set the following fields to these values:
35+
| Use default section name | 1 |
36+
| Summary | <h2>Unit One</h2> |
37+
And I press "Save changes"
38+
# Add both explicit name and a summary text to the topic 2 section.
39+
And I click on "Edit" "link" in the "li#section-2" "css_element"
40+
And I click on "Edit topic" "link" in the "li#section-2" "css_element"
41+
And I set the following fields to these values:
42+
| Use default section name | 0 |
43+
| name | Topic Two |
44+
| Summary | This is topic 2. |
45+
And I press "Save changes"
46+
# Add the course context block instance and enter its configuration.
47+
And I add the "Course contents" block
48+
And I configure the "Table of contents" block
49+
50+
Scenario: Customizing the block title
51+
Given I set the field "Block title" to "Course units"
52+
When I press "Save changes"
53+
Then I should not see "Table of contents"
54+
And "Course units" "block" should exist
55+
56+
Scenario: Enumeration off, auto title off
57+
Given I set the following fields to these values:
58+
| Enumerate section titles | 0 |
59+
| Auto title | 0 |
60+
When I press "Save changes"
61+
Then I should see "Welcome to C1" in the "block_course_contents" "block"
62+
And I should not see "0 Welcome to C1" in the "block_course_contents" "block"
63+
And I should see "Topic 1" in the "block_course_contents" "block"
64+
And I should not see "1 Topic 1" in the "block_course_contents" "block"
65+
And I should see "Topic Two" in the "block_course_contents" "block"
66+
And I should not see "Topic 2" in the "block_course_contents" "block"
67+
And I should see "Topic 3" in the "block_course_contents" "block"
68+
And I should not see "3 Topic 3" in the "block_course_contents" "block"
69+
70+
Scenario: Enumeration on, auto title off
71+
Given I set the following fields to these values:
72+
| Enumerate section titles | 1 |
73+
| Auto title | 0 |
74+
When I press "Save changes"
75+
Then I should see "Welcome to C1" in the "block_course_contents" "block"
76+
And I should not see "0 Welcome to C1" in the "block_course_contents" "block"
77+
And I should see "1 Topic 1" in the "block_course_contents" "block"
78+
And I should see "2 Topic Two" in the "block_course_contents" "block"
79+
And I should see "3 Topic 3" in the "block_course_contents" "block"
80+
81+
Scenario: Enumeration off, auto title on
82+
Given I set the following fields to these values:
83+
| Enumerate section titles | 0 |
84+
| Auto title | 1 |
85+
When I press "Save changes"
86+
Then I should see "Welcome to C1" in the "block_course_contents" "block"
87+
And I should not see "0 Welcome to C1" in the "block_course_contents" "block"
88+
And I should see "Unit One" in the "block_course_contents" "block"
89+
And I should not see "1 Unit One" in the "block_course_contents" "block"
90+
And I should not see "Topic 1" in the "block_course_contents" "block"
91+
And I should see "Topic Two" in the "block_course_contents" "block"
92+
And I should not see "Topic 2" in the "block_course_contents" "block"
93+
And I should see "Topic 3" in the "block_course_contents" "block"
94+
And I should not see "3 Topic 3" in the "block_course_contents" "block"
95+
96+
Scenario: Enumeration on, auto title on
97+
Given I set the following fields to these values:
98+
| Enumerate section titles | 1 |
99+
| Auto title | 1 |
100+
When I press "Save changes"
101+
Then I should see "Welcome to C1" in the "block_course_contents" "block"
102+
And I should not see "0 Welcome to C1" in the "block_course_contents" "block"
103+
And I should see "1 Unit One" in the "block_course_contents" "block"
104+
And I should not see "Topic 1" in the "block_course_contents" "block"
105+
And I should see "2 Topic Two" in the "block_course_contents" "block"
106+
And I should not see "Topic 2" in the "block_course_contents" "block"
107+
And I should see "3 Topic 3" in the "block_course_contents" "block"
108+
109+
Scenario: Enumeration off, auto title off, but the values are overwritten on site level
110+
Given I set the following fields to these values:
111+
| Enumerate section titles | 0 |
112+
| Auto title | 0 |
113+
And I press "Save changes"
114+
When the following config values are set as admin:
115+
| enumerate | forced_on | block_course_contents |
116+
| autotitle | forced_on | block_course_contents |
117+
And I am on homepage
118+
And I follow "Course 1"
119+
Then I should see "Welcome to C1" in the "block_course_contents" "block"
120+
And I should not see "0 Welcome to C1" in the "block_course_contents" "block"
121+
And I should see "1 Unit One" in the "block_course_contents" "block"
122+
And I should not see "Topic 1" in the "block_course_contents" "block"
123+
And I should see "2 Topic Two" in the "block_course_contents" "block"
124+
And I should not see "Topic 2" in the "block_course_contents" "block"
125+
And I should see "3 Topic 3" in the "block_course_contents" "block"
126+
127+
Scenario: Enumeration on, auto title on, but the values are overwritten on site level
128+
Given I set the following fields to these values:
129+
| Enumerate section titles | 1 |
130+
| Auto title | 1 |
131+
And I press "Save changes"
132+
When the following config values are set as admin:
133+
| enumerate | forced_off | block_course_contents |
134+
| autotitle | forced_off | block_course_contents |
135+
And I am on homepage
136+
And I follow "Course 1"
137+
Then I should see "Welcome to C1" in the "block_course_contents" "block"
138+
And I should not see "0 Welcome to C1" in the "block_course_contents" "block"
139+
And I should see "Topic 1" in the "block_course_contents" "block"
140+
And I should not see "1 Topic 1" in the "block_course_contents" "block"
141+
And I should see "Topic Two" in the "block_course_contents" "block"
142+
And I should not see "Topic 2" in the "block_course_contents" "block"
143+
And I should see "Topic 3" in the "block_course_contents" "block"
144+
And I should not see "3 Topic 3" in the "block_course_contents" "block"

0 commit comments

Comments
 (0)