MDL-67883 core: Make core ready for MoodleNet.
[moodle.git] / course / tests / behat / activity_chooser.feature
CommitLineData
37cf89b3
P
1@core @core_course @javascript
2Feature: Display and choose from the available activities in course
3 In order to add activities to a course
4 As a teacher
5 I should be enabled to choose from a list of available activities and also being able to read their summaries.
6
7 Background:
8 Given the following "users" exist:
9 | username | firstname | lastname | email |
10 | teacher | Teacher | 1 | teacher@example.com |
11 And the following "courses" exist:
12 | fullname | shortname | format |
13 | Course | C | topics |
14 And the following "course enrolments" exist:
15 | user | course | role |
16 | teacher | C | editingteacher |
16d77f18
MM
17 And the following config values are set as admin:
18 | enablemoodlenet | 0 | tool_moodlenet |
37cf89b3
P
19 And I log in as "teacher"
20 And I am on "Course" course homepage with editing mode on
21
22 Scenario: The available activities are displayed to the teacher in the activity chooser
7f864552
MM
23 Given I click on "Add an activity or resource" "button" in the "Topic 1" "section"
24 Then I should see "Add an activity or resource" in the ".modal-title" "css_element"
37cf89b3
P
25 And I should see "Assignment" in the ".modal-body" "css_element"
26
27 Scenario: The teacher can choose to add an activity from the activity items in the activity chooser
7f864552
MM
28 Given I click on "Add an activity or resource" "button" in the "Topic 3" "section"
29 When I click on "Add a new Assignment" "link" in the "Add an activity or resource" "dialogue"
37cf89b3
P
30 Then I should see "Adding a new Assignment"
31 And I set the following fields to these values:
32 | Assignment name | Test Assignment Topic 3 |
33 And I press "Save and return to course"
34 Then I should see "Test Assignment Topic 3" in the "Topic 3" "section"
35
36 Scenario: The teacher can choose to add an activity from the activity summary in the activity chooser
7f864552
MM
37 Given I click on "Add an activity or resource" "button" in the "Topic 1" "section"
38 When I click on "Information about the Assignment activity" "button" in the "Add an activity or resource" "dialogue"
37cf89b3
P
39 When I click on "Add a new Assignment" "link" in the "help" "core_course > Activity chooser screen"
40 Then I should see "Adding a new Assignment"
41
42 Scenario: Show summary
7f864552
MM
43 Given I click on "Add an activity or resource" "button" in the "Topic 1" "section"
44 When I click on "Information about the Assignment activity" "button" in the "Add an activity or resource" "dialogue"
37cf89b3
P
45 Then I should see "Assignment" in the "help" "core_course > Activity chooser screen"
46 And I should see "The assignment activity module enables a teacher to communicate tasks, collect work and provide grades and feedback."
47
48 Scenario: Hide summary
7f864552 49 Given I click on "Add an activity or resource" "button" in the "Topic 1" "section"
37cf89b3
P
50 When I click on "Information about the Assignment activity" "button" in the "modules" "core_course > Activity chooser screen"
51 And I should see "The assignment activity module enables a teacher to communicate tasks, collect work and provide grades and feedback." in the "help" "core_course > Activity chooser screen"
52 And I should see "Back" in the "help" "core_course > Activity chooser screen"
53 When I click on "Back" "button" in the "help" "core_course > Activity chooser screen"
54 Then "modules" "core_course > Activity chooser screen" should exist
55 And "help" "core_course > Activity chooser screen" should not exist
56 And "Back" "button" should not exist in the "modules" "core_course > Activity chooser screen"
7f864552 57 And I should not see "The assignment activity module enables a teacher to communicate tasks, collect work and provide grades and feedback." in the "Add an activity or resource" "dialogue"
c58c23d6 58
e04b4be6
MM
59 Scenario: View recommended activities
60 When I log out
61 And I log in as "admin"
62 And I am on site homepage
e146a2ca 63 And I navigate to "Courses > Activity chooser > Recommended activities" in site administration
e04b4be6
MM
64 And I click on ".activity-recommend-checkbox" "css_element" in the "Book" "table_row"
65 # Setup done, lets check it works with a teacher.
66 And I log out
67 And I log in as "teacher"
68 And I am on "Course" course homepage with editing mode on
69 And I open the activity chooser
7f864552
MM
70 Then I should see "Recommended" in the "Add an activity or resource" "dialogue"
71 And I click on "Recommended" "link" in the "Add an activity or resource" "dialogue"
e04b4be6 72 And I should see "Book" in the "recommended" "core_course > Activity chooser tab"
6e1a4477
MM
73
74 Scenario: Favourite a module in the activity chooser
75 Given I open the activity chooser
7f864552
MM
76 And I should not see "Starred" in the "Add an activity or resource" "dialogue"
77 And I click on "Star Assignment activity" "button" in the "Add an activity or resource" "dialogue"
78 And I should see "Starred" in the "Add an activity or resource" "dialogue"
79 When I click on "Starred" "link" in the "Add an activity or resource" "dialogue"
6e1a4477
MM
80 Then I should see "Assignment" in the "favourites" "core_course > Activity chooser tab"
81 And I click on "Information about the Assignment activity" "button" in the "favourites" "core_course > Activity chooser tab"
82 And I should see "The assignment activity module enables a teacher to communicate tasks, collect work and provide grades and feedback."
83
84 Scenario: Add a favourite module and check it exists when reopening the chooser
85 Given I open the activity chooser
7f864552
MM
86 And I click on "Star Assignment activity" "button" in the "Add an activity or resource" "dialogue"
87 And I click on "Star Forum activity" "button" in the "Add an activity or resource" "dialogue"
88 And I should see "Starred" in the "Add an activity or resource" "dialogue"
89 And I click on "Close" "button" in the "Add an activity or resource" "dialogue"
90 When I click on "Add an activity or resource" "button" in the "Topic 3" "section"
91 And I click on "Starred" "link" in the "Add an activity or resource" "dialogue"
6e1a4477
MM
92 Then I should see "Forum" in the "favourites" "core_course > Activity chooser tab"
93
94 Scenario: Add a favourite and then remove it whilst checking the tabs work as expected
95 Given I open the activity chooser
7f864552
MM
96 And I click on "Star Assignment activity" "button" in the "Add an activity or resource" "dialogue"
97 And I click on "Starred" "link" in the "Add an activity or resource" "dialogue"
98 And I click on "Star Assignment activity" "button" in the "Add an activity or resource" "dialogue"
99 Then I should not see "Starred" in the "Add an activity or resource" "dialogue"
ae0e9801
MG
100
101 Scenario: The teacher can search for an activity by it's name
7f864552 102 Given I click on "Add an activity or resource" "button" in the "Topic 1" "section"
ae0e9801 103 When I set the field "search" to "Lesson"
7f864552
MM
104 Then I should see "1 results found" in the "Add an activity or resource" "dialogue"
105 And I should see "Lesson" in the "Add an activity or resource" "dialogue"
ae0e9801
MG
106
107 Scenario: The teacher can search for an activity by it's description
108 Given I open the activity chooser
109 When I set the field "search" to "The lesson activity module enables a teacher to deliver content"
7f864552
MM
110 Then I should see "1 results found" in the "Add an activity or resource" "dialogue"
111 And I should see "Lesson" in the "Add an activity or resource" "dialogue"
ae0e9801
MG
112
113 Scenario: Search results are not returned if the search query does not match any activity name or description
7f864552 114 Given I click on "Add an activity or resource" "button" in the "Topic 1" "section"
ae0e9801 115 When I set the field "search" to "Random search query"
7f864552 116 Then I should see "0 results found" in the "Add an activity or resource" "dialogue"
ae0e9801
MG
117 And ".option" "css_element" should not exist in the ".searchresultitemscontainer" "css_element"
118
119 Scenario: Teacher can return to the default activity chooser state by manually removing the search query
7f864552 120 Given I click on "Add an activity or resource" "button" in the "Topic 1" "section"
ae0e9801 121 And I set the field "search" to "Lesson"
7f864552
MM
122 And I should see "1 results found" in the "Add an activity or resource" "dialogue"
123 And I should see "Lesson" in the "Add an activity or resource" "dialogue"
ae0e9801 124 When I set the field "search" to ""
7f864552 125 And I should not see "1 results found" in the "Add an activity or resource" "dialogue"
ae0e9801
MG
126 Then ".searchresultscontainer" "css_element" should not exist
127 And ".optionscontainer" "css_element" should exist
128
129 Scenario: Teacher can not see a "clear" button if a search query is not entered in the activity chooser search bar
7f864552 130 When I click on "Add an activity or resource" "button" in the "Topic 1" "section"
ae0e9801
MG
131 Then "Clear search input" "button" should not exist
132
133 Scenario: Teacher can see a "clear" button after entering a search query in the activity chooser search bar
7f864552 134 Given I click on "Add an activity or resource" "button" in the "Topic 1" "section"
ae0e9801
MG
135 When I set the field "search" to "Search query"
136 Then "Clear search input" "button" should not exist
137
138 Scenario: Teacher can not see a "clear" button if the search query is removed in the activity chooser search bar
7f864552 139 Given I click on "Add an activity or resource" "button" in the "Topic 1" "section"
ae0e9801
MG
140 And I set the field "search" to "Search query"
141 And "Clear search input" "button" should exist
142 When I set the field "search" to ""
143 Then "Clear search input" "button" should not exist
144
145 Scenario: Teacher can instantly remove the search query from the activity search bar by clicking on the "clear" button
7f864552 146 Given I click on "Add an activity or resource" "button" in the "Topic 1" "section"
ae0e9801 147 And I set the field "search" to "Search query"
7f864552 148 And I should see "results found" in the "Add an activity or resource" "dialogue"
ae0e9801
MG
149 When I click on "Clear search input" "button"
150 Then I should not see "Search query"
151 And ".searchresultscontainer" "css_element" should not exist
152 And ".optionscontainer" "css_element" should exist
e146a2ca
MM
153
154 Scenario: Teacher gets the base case for the Activity Chooser tab mode
7f864552
MM
155 Given I click on "Add an activity or resource" "button" in the "Topic 1" "section"
156 And I should see "Activities" in the "Add an activity or resource" "dialogue"
157 When I click on "Activities" "link" in the "Add an activity or resource" "dialogue"
e146a2ca 158 Then I should not see "Book" in the "activity" "core_course > Activity chooser tab"
7f864552 159 And I click on "Resources" "link" in the "Add an activity or resource" "dialogue"
e146a2ca
MM
160 And I should not see "Assignment" in the "resources" "core_course > Activity chooser tab"
161
162 Scenario: Teacher gets the simple case for the Activity Chooser tab mode
163 Given I log out
164 And I log in as "admin"
165 And I am on site homepage
166 When I navigate to "Courses > Activity chooser > Activity chooser settings" in site administration
167 And I select "Starred, All, Recommended" from the "Activity chooser tabs" singleselect
168 And I press "Save changes"
169 And I log out
170 And I log in as "teacher"
171 And I am on "Course" course homepage with editing mode on
7f864552
MM
172 And I click on "Add an activity or resource" "button" in the "Topic 1" "section"
173 Then I should not see "Activities" in the "Add an activity or resource" "dialogue"
174 And I should not see "Resources" in the "Add an activity or resource" "dialogue"
e146a2ca
MM
175
176 Scenario: Teacher gets the final case for the Activity Chooser tab mode
177 Given I log out
178 And I log in as "admin"
179 And I am on site homepage
180 When I navigate to "Courses > Activity chooser > Activity chooser settings" in site administration
181 And I select "Starred, Activities, Resources, Recommended" from the "Activity chooser tabs" singleselect
182 And I press "Save changes"
183 And I log out
184 And I log in as "teacher"
185 And I am on "Course" course homepage with editing mode on
7f864552
MM
186 And I click on "Add an activity or resource" "button" in the "Topic 1" "section"
187 Then I should not see "All" in the "Add an activity or resource" "dialogue"
188 And I should see "Activities" in the "Add an activity or resource" "dialogue"
189 And I should see "Resources" in the "Add an activity or resource" "dialogue"