on-demand release 4.0dev+
[moodle.git] / contentbank / tests / behat / visibility.feature
CommitLineData
39263ddb 1@core @core_contentbank @core_h5p @contentbank_h5p @_file_upload @javascript
3776fbaf
FM
2Feature: Make content public or unlisted
3 In order to make content public or unlisted
4 As a user
5 I need to be able to access the edition options
6
7 Background:
8 Given I log in as "admin"
9 And I am on site homepage
10 And I turn editing mode on
11 And I add the "Navigation" block if not present
12 And I configure the "Navigation" block
13 And I set the following fields to these values:
14 | Page contexts | Display throughout the entire site |
15 And I press "Save changes"
f3d43c76
SA
16 And I navigate to "H5P > Manage H5P content types" in site administration
17 And I upload "h5p/tests/fixtures/filltheblanks.h5p" file to "H5P content type" filemanager
18 And I click on "Upload H5P content types" "button" in the "#fitem_id_uploadlibraries" "css_element"
3776fbaf
FM
19
20 Scenario: Users can make their content public or unlisted
21 Given the following "contentbank content" exist:
22 | contextlevel | reference | contenttype | user | contentname | filepath | visibility |
23 | System | | contenttype_h5p | admin | filltheblanks.h5p | /h5p/tests/fixtures/filltheblanks.h5p | 1 |
24 And I click on "Site pages" "list_item" in the "Navigation" "block"
25 And I click on "Content bank" "link" in the "Navigation" "block"
26 And I click on "filltheblanks.h5p" "link"
27 And I wait until the page is ready
28 And I should not see "filltheblanks.h5p (Unlisted)" in the "h1" "css_element"
29 And I open the action menu in "region-main-settings-menu" "region"
30 And I should see "Make unlisted"
31 When I choose "Make unlisted" in the open action menu
32 And I wait until the page is ready
33 Then I should see "filltheblanks.h5p (Unlisted)" in the "h1" "css_element"
34 And I open the action menu in "region-main-settings-menu" "region"
35 And I should see "Make public"
36
37 Scenario: Unlisted content cannot be seen by other users
38 Given the following "users" exist:
39 | username | firstname | lastname | email |
40 | teacher1 | Teacher | 1 | teacher1@example.com |
41 | teacher2 | Teacher | 2 | teacher2@example.com |
42 And the following "courses" exist:
43 | fullname | shortname |
44 | Course 1 | C1 |
45 And the following "course enrolments" exist:
46 | user | course | role |
47 | teacher1 | C1 | editingteacher |
48 | teacher2 | C1 | editingteacher |
49 And the following "contentbank content" exist:
50 | contextlevel | reference | contenttype | user | contentname | filepath | visibility |
51 | Course | C1 | contenttype_h5p | teacher1 | filltheblanks.h5p | /h5p/tests/fixtures/filltheblanks.h5p | 2 |
52 And I log out
53 And I log in as "teacher1"
54 And I am on "Course 1" course homepage
55 And I click on "Site pages" "list_item" in the "Navigation" "block"
56 And I click on "Content bank" "link" in the "Navigation" "block"
57 Then I should see "filltheblanks.h5p (Unlisted)"
58 And I log out
59 And I log in as "teacher2"
60 And I am on "Course 1" course homepage
61 And I click on "Site pages" "list_item" in the "Navigation" "block"
62 And I click on "Content bank" "link" in the "Navigation" "block"
63 Then I should not see "filltheblanks.h5p"
64
65 Scenario: Unlisted content is not found through search by other users
66 Given the following "users" exist:
67 | username | firstname | lastname | email |
68 | teacher1 | Teacher | 1 | teacher1@example.com |
69 | teacher2 | Teacher | 2 | teacher2@example.com |
70 And the following "courses" exist:
71 | fullname | shortname |
72 | Course 1 | C1 |
73 And the following "course enrolments" exist:
74 | user | course | role |
75 | teacher1 | C1 | editingteacher |
76 | teacher2 | C1 | editingteacher |
77 And the following "contentbank content" exist:
78 | contextlevel | reference | contenttype | user | contentname | filepath | visibility |
79 | Course | C1 | contenttype_h5p | teacher1 | filltheblanks.h5p | /h5p/tests/fixtures/filltheblanks.h5p | 2 |
80 And I log out
81 And I log in as "teacher1"
82 And I am on "Course 1" course homepage
83 And I click on "Site pages" "list_item" in the "Navigation" "block"
84 And I click on "Content bank" "link" in the "Navigation" "block"
85 And I set the field "Search" to "filltheblanks.h5p"
86 And I should see "filltheblanks.h5p"
87 And I log out
88 And I log in as "teacher2"
89 And I am on "Course 1" course homepage
90 And I click on "Site pages" "list_item" in the "Navigation" "block"
91 And I click on "Content bank" "link" in the "Navigation" "block"
92 When I set the field "Search" to "filltheblanks.h5p"
93 Then I should not see "filltheblanks.h5p"
94
95 Scenario: Managers can see other users' unlisted content
96 Given the following "users" exist:
97 | username | firstname | lastname | email |
98 | teacher1 | Teacher | 1 | teacher1@example.com |
99 | manager1 | Manager | 1 | manager1@example.com |
100 And the following "courses" exist:
101 | fullname | shortname |
102 | Course 1 | C1 |
103 And the following "course enrolments" exist:
104 | user | course | role |
105 | teacher1 | C1 | editingteacher |
106 | manager1 | C1 | manager |
107 And the following "contentbank content" exist:
108 | contextlevel | reference | contenttype | user | contentname | filepath | visibility |
109 | Course | C1 | contenttype_h5p | teacher1 | filltheblanks.h5p | /h5p/tests/fixtures/filltheblanks.h5p | 2 |
110 And I log out
111 And I log in as "manager1"
112 And I am on "Course 1" course homepage
113 And I click on "Site pages" "list_item" in the "Navigation" "block"
114 And I click on "Content bank" "link" in the "Navigation" "block"
115 And I should see "filltheblanks.h5p (Unlisted)"
116 And I set the field "Search" to "filltheblanks.h5p"
117 And I should see "filltheblanks.h5p (Unlisted)"
118
119 @_file_upload
120 Scenario: Default content visibility can be set to unlisted
121 Given the following "courses" exist:
122 | fullname | shortname |
123 | Course 1 | C1 |
124 And I set the following administration settings values:
125 | Default content visibility | 2 |
126 And I am on "Course 1" course homepage
127 And I click on "Site pages" "list_item" in the "Navigation" "block"
128 And I click on "Content bank" "link" in the "Navigation" "block"
129 And I click on "Upload" "link"
130 And I upload "h5p/tests/fixtures/filltheblanks.h5p" file to "Upload content" filemanager
131 And I click on "Save changes" "button"
132 Then I should see "filltheblanks.h5p (Unlisted)" in the "h1" "css_element"
133
134 @_file_upload
135 Scenario: User preference concerning content visibility overrides site-wide default content visibility
136 Given the following "courses" exist:
137 | fullname | shortname |
138 | Course 1 | C1 |
139 And I set the following administration settings values:
140 | Default content visibility | 2 |
141 And the following "user preferences" exist:
142 | user | preference | value |
143 | admin | core_contentbank_visibility | 1 |
144 And I am on "Course 1" course homepage
145 And I click on "Site pages" "list_item" in the "Navigation" "block"
146 And I click on "Content bank" "link" in the "Navigation" "block"
147 And I click on "Upload" "link"
148 And I upload "h5p/tests/fixtures/filltheblanks.h5p" file to "Upload content" filemanager
149 And I click on "Save changes" "button"
150 Then I should see "filltheblanks.h5p" in the "h1" "css_element"
151 And I should not see "filltheblanks.h5p (Unlisted)" in the "h1" "css_element"