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