MDL-39051 behat: New tests
[moodle.git] / course / tests / behat / course_controls.feature
bloba243ace4fd561fe0160303e6ff34342e480f8f44
1 @core @core_course
2 Feature: Course activity controls works as expected
3   In order to manage my course's activities
4   As a teacher
5   I need to edit, hide, show and indent activities inside course sections
7   # This two scenario outlines contains exactly the same steps, the
8   # only difference is whether JS is enabled or not; we can not use
9   # Background sections when using Scenario Outlines because of Behat
10   # framework restrictions.
12   # We are testing:
13   # * Javascript on and off
14   # * Topics and weeks course formats
15   # * Course controls without paged mode
16   # * Course controls with paged mode in the course home page
17   # * Course controls with paged mode in a section's page
19   @javascript @_cross_browser
20   Scenario Outline: General activities course controls using topics and weeks formats, and paged mode and not paged mode works as expected
21     Given the following "users" exists:
22       | username | firstname | lastname | email |
23       | teacher1 | Teacher | 1 | teacher1@asd.com |
24     And the following "courses" exists:
25       | fullname | shortname | format | coursedisplay | numsections |
26       | Course 1 | C1 | <courseformat> | <coursedisplay> | 5 |
27     And the following "course enrolments" exists:
28       | user | course | role |
29       | teacher1 | C1 | editingteacher |
30     And I log in as "teacher1"
31     And I follow "Course 1"
32     When I follow <targetpage>
33     And I press "Turn editing on"
34     Then I should see "Turn editing off"
35     And I press "Turn editing off"
36     And "Turn editing on" "button" should exists
37     And I follow "Turn editing on"
38     And "Turn editing off" "button" should exists
39     And I follow "Turn editing off"
40     And I should see "Turn editing on"
41     And "Turn editing on" "button" should exists
42     And I turn editing mode on
43     And I click on "Delete Recent activity block" "link"
44     And I press "Yes"
45     And "#section-2" "css_element" <should_see_other_sections> exists
46     And I add a "Forum" to section "1" and I fill the form with:
47       | Forum name | Test forum name 1 |
48       | Description | Test forum description 1 |
49     And I add a "Forum" to section "1" and I fill the form with:
50       | Forum name | Test forum name 2 |
51       | Description | Test forum description 2 |
52     And "#section-2" "css_element" <should_see_other_sections> exists
53     And I indent right "Test forum name 1" activity
54     And "#section-2" "css_element" <should_see_other_sections> exists
55     And I indent left "Test forum name 1" activity
56     And "#section-2" "css_element" <should_see_other_sections> exists
57     And I click on "Update" "link" in the "Test forum name 1" activity
58     And I should see "Updating Forum"
59     And I should see "Display description on course page"
60     And I press "Save and return to course"
61     And "#section-2" "css_element" <should_see_other_sections> exists
62     And I click on "Hide" "link" in the "Test forum name 1" activity
63     And "#section-2" "css_element" <should_see_other_sections> exists
64     And I delete "Test forum name 1" activity
65     And "#section-2" "css_element" <should_see_other_sections> exists
66     And I should not see "Test forum name 1" in the ".region-content" "css_element"
67     And I duplicate "Test forum name 2" activity editing the new copy with:
68       | Forum name | Edited test forum name 2 |
69     And "#section-2" "css_element" <should_see_other_sections> exists
70     And I should see "Test forum name 2"
71     And I should see "Edited test forum name 2"
72     And I hide section "1"
73     And "#section-2" "css_element" <should_see_other_sections> exists
74     And section "1" should be hidden
75     And I show section "1"
76     And "#section-2" "css_element" <should_see_other_sections> exists
77     And section "1" should be visible
78     And I add the "Section links" block
79     And "#section-2" "css_element" <should_see_other_sections> exists
80     And I should see "1 2 3 4 5" in the ".block_section_links" "css_element"
81     And I click on "2" "link" in the ".block_section_links" "css_element"
82     And I <should_see_other_sections_following_block_sections_links> see "Test forum name 2"
84     Examples:
85       | courseformat | coursedisplay | targetpage              | should_see_other_sections | should_see_other_sections_following_block_sections_links |
86       | topics       | 0             | "Course 1"              | should                    | should                                                   |
87       | topics       | 1             | "Topic 1"               | should not                | should not                                               |
88       | topics       | 1             | "Course 1"              | should                    | should not                                               |
89       | weeks        | 0             | "Course 1"              | should                    | should                                                   |
90       | weeks        | 1             | "1 January - 7 January" | should not                | should not                                               |
91       | weeks        | 1             | "Course 1"              | should                    | should not                                               |
94   Scenario Outline: General activities course controls using topics and weeks formats, and paged mode and not paged mode works as expected
95     Given the following "users" exists:
96       | username | firstname | lastname | email |
97       | teacher1 | Teacher | 1 | teacher1@asd.com |
98     And the following "courses" exists:
99       | fullname | shortname | format | coursedisplay | numsections |
100       | Course 1 | C1 | <courseformat> | <coursedisplay> | 5 |
101     And the following "course enrolments" exists:
102       | user | course | role |
103       | teacher1 | C1 | editingteacher |
104     And I log in as "teacher1"
105     And I follow "Course 1"
106     When I follow <targetpage>
107     And I press "Turn editing on"
108     Then I should see "Turn editing off"
109     And I press "Turn editing off"
110     And "Turn editing on" "button" should exists
111     And I follow "Turn editing on"
112     And "Turn editing off" "button" should exists
113     And I follow "Turn editing off"
114     And I should see "Turn editing on"
115     And "Turn editing on" "button" should exists
116     And I turn editing mode on
117     And I click on "Delete Recent activity block" "link"
118     And I press "Yes"
119     And "#section-2" "css_element" <should_see_other_sections> exists
120     And I add a "Forum" to section "1" and I fill the form with:
121       | Forum name | Test forum name 1 |
122       | Description | Test forum description 1 |
123     And I add a "Forum" to section "1" and I fill the form with:
124       | Forum name | Test forum name 2 |
125       | Description | Test forum description 2 |
126     And "#section-2" "css_element" <should_see_other_sections> exists
127     And I indent right "Test forum name 1" activity
128     And "#section-2" "css_element" <should_see_other_sections> exists
129     And I indent left "Test forum name 1" activity
130     And "#section-2" "css_element" <should_see_other_sections> exists
131     And I click on "Update" "link" in the "Test forum name 1" activity
132     And I should see "Updating Forum"
133     And I should see "Display description on course page"
134     And I press "Save and return to course"
135     And "#section-2" "css_element" <should_see_other_sections> exists
136     And I click on "Hide" "link" in the "Test forum name 1" activity
137     And "#section-2" "css_element" <should_see_other_sections> exists
138     And I delete "Test forum name 1" activity
139     And "#section-2" "css_element" <should_see_other_sections> exists
140     And I should not see "Test forum name 1" in the ".region-content" "css_element"
141     And I duplicate "Test forum name 2" activity editing the new copy with:
142       | Forum name | Edited test forum name 2 |
143     And "#section-2" "css_element" <should_see_other_sections> exists
144     And I should see "Test forum name 2"
145     And I should see "Edited test forum name 2"
146     And I hide section "1"
147     And "#section-2" "css_element" <should_see_other_sections> exists
148     And section "1" should be hidden
149     And I show section "1"
150     And "#section-2" "css_element" <should_see_other_sections> exists
151     And section "1" should be visible
152     And I add the "Section links" block
153     And "#section-2" "css_element" <should_see_other_sections> exists
154     And I should see "1 2 3 4 5" in the ".block_section_links" "css_element"
155     And I click on "2" "link" in the ".block_section_links" "css_element"
156     And I <should_see_other_sections_following_block_sections_links> see "Test forum name 2"
158     Examples:
159       | courseformat | coursedisplay | targetpage              | should_see_other_sections | should_see_other_sections_following_block_sections_links |
160       | topics       | 0             | "Course 1"              | should                    | should                                                   |
161       | topics       | 1             | "Topic 1"               | should not                | should not                                               |
162       | topics       | 1             | "Course 1"              | should                    | should not                                               |
163       | weeks        | 0             | "Course 1"              | should                    | should                                                   |
164       | weeks        | 1             | "1 January - 7 January" | should not                | should not                                               |
165       | weeks        | 1             | "Course 1"              | should                    | should not                                               |