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