weekly release 3.9dev+
[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
8599eb5e
DM
21 Given I click on "Add an activity" "button" in the "Topic 1" "section"
22 Then I should see "Add an activity" 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
8599eb5e
DM
26 Given I click on "Add an activity" "button" in the "Topic 3" "section"
27 When I click on "Add a new Assignment" "link" in the "Add an activity" "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
8599eb5e
DM
35 Given I click on "Add an activity" "button" in the "Topic 1" "section"
36 When I click on "Information about the Assignment activity" "button" in the "Add an activity" "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
8599eb5e
DM
41 Given I click on "Add an activity" "button" in the "Topic 1" "section"
42 When I click on "Information about the Assignment activity" "button" in the "Add an activity" "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
8599eb5e 47 Given I click on "Add an activity" "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"
8599eb5e 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" "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
61 And I navigate to "Courses > Recommended activities" in site administration
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
8599eb5e
DM
68 Then I should see "Recommended" in the "Add an activity" "dialogue"
69 And I click on "Recommended" "link" in the "Add an activity" "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
8599eb5e
DM
74 And I should not see "Starred" in the "Add an activity" "dialogue"
75 And I click on "Star Assignment activity" "button" in the "Add an activity" "dialogue"
76 And I should see "Starred" in the "Add an activity" "dialogue"
77 When I click on "Starred" "link" in the "Add an activity" "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
8599eb5e
DM
84 And I click on "Star Assignment activity" "button" in the "Add an activity" "dialogue"
85 And I click on "Star Forum activity" "button" in the "Add an activity" "dialogue"
86 And I should see "Starred" in the "Add an activity" "dialogue"
87 And I click on "Close" "button" in the "Add an activity" "dialogue"
88 When I click on "Add an activity" "button" in the "Topic 3" "section"
89 And I click on "Starred" "link" in the "Add an activity" "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
8599eb5e
DM
94 And I click on "Star Assignment activity" "button" in the "Add an activity" "dialogue"
95 And I click on "Starred" "link" in the "Add an activity" "dialogue"
96 And I click on "Star Assignment activity" "button" in the "Add an activity" "dialogue"
97 Then I should not see "Starred" in the "Add an activity" "dialogue"
ae0e9801
MG
98
99 Scenario: The teacher can search for an activity by it's name
8599eb5e 100 Given I click on "Add an activity" "button" in the "Topic 1" "section"
ae0e9801 101 When I set the field "search" to "Lesson"
8599eb5e
DM
102 Then I should see "1 results found" in the "Add an activity" "dialogue"
103 And I should see "Lesson" in the "Add an activity" "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"
8599eb5e
DM
108 Then I should see "1 results found" in the "Add an activity" "dialogue"
109 And I should see "Lesson" in the "Add an activity" "dialogue"
ae0e9801
MG
110
111 Scenario: Search results are not returned if the search query does not match any activity name or description
8599eb5e 112 Given I click on "Add an activity" "button" in the "Topic 1" "section"
ae0e9801 113 When I set the field "search" to "Random search query"
8599eb5e 114 Then I should see "0 results found" in the "Add an activity" "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
8599eb5e 118 Given I click on "Add an activity" "button" in the "Topic 1" "section"
ae0e9801 119 And I set the field "search" to "Lesson"
8599eb5e
DM
120 And I should see "1 results found" in the "Add an activity" "dialogue"
121 And I should see "Lesson" in the "Add an activity" "dialogue"
ae0e9801 122 When I set the field "search" to ""
8599eb5e 123 And I should not see "1 results found" in the "Add an activity" "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
8599eb5e 128 When I click on "Add an activity" "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
8599eb5e 132 Given I click on "Add an activity" "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
8599eb5e 137 Given I click on "Add an activity" "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
8599eb5e 144 Given I click on "Add an activity" "button" in the "Topic 1" "section"
ae0e9801 145 And I set the field "search" to "Search query"
8599eb5e 146 And I should see "results found" in the "Add an activity" "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