MDL-80880 quiz: change display of previous attempts summary
[moodle.git] / mod / data / tests / behat / edit_templates.feature
blobf128d530162e280c8f3efccc89f1b7576c80d11b
1 @mod @mod_data
2 Feature: Users can edit the database templates
3   In order to use custom templates for entries
4   As a teacher
5   I need to edit the templates html
7   Background:
8     Given the following "users" exist:
9       | username | firstname | lastname | email                |
10       | teacher1 | Teacher   | 1        | teacher1@example.com |
11     And the following "courses" exist:
12       | fullname | shortname | category |
13       | Course 1 | C1        | 0        |
14     And the following "course enrolments" exist:
15       | user     | course | role           |
16       | teacher1 | C1     | editingteacher |
17     And the following "activities" exist:
18       | activity | name               | intro          | course | idnumber |
19       | data     | Test database name | Database intro | C1     | data1    |
20     And the following "mod_data > fields" exist:
21       | database | type | name   | description              |
22       | data1    | text | field1 | Test field description   |
23       | data1    | text | field2 | Test field 2 description |
24     And the following "mod_data > entries" exist:
25       | database | field1          | field2         |
26       | data1    | Student entry 1 | Some content 1 |
27     And I am on the "Test database name" "data activity" page logged in as teacher1
28     And I navigate to "Templates" in current page administration
29     And I set the field "Templates tertiary navigation" to "List view template"
31   @javascript
32   Scenario: Edit list template
33     Given I set the following fields to these values:
34       | Header         | New header!                |
35       | Repeated entry | [[field1]] and [[field2]]! |
36       | Footer         | New footer!                |
37     And I click on "Save" "button" in the "sticky-footer" "region"
38     When I navigate to "Database" in current page administration
39     Then I should see "New header!"
40     And I should see "Student entry 1 and Some content 1!"
41     And I should see "New footer!"
43   @javascript
44   Scenario: Edit single template
45     Given I set the field "Templates tertiary navigation" to "Single view template"
46     And I set the following fields to these values:
47       | Single view template | [[field1]] and [[field2]] details! |
48     And I click on "Save" "button" in the "sticky-footer" "region"
49     When I navigate to "Database" in current page administration
50     And I set the field "View mode tertiary navigation" to "Single view"
51     Then I should see "Student entry 1 and Some content 1 details!"
53   @javascript
54   Scenario: Edit add entry template
55     Given I set the field "Templates tertiary navigation" to "Add entry template"
56     And I set the following fields to these values:
57       | Add entry template | [[field1]] [[field2]] Form extra! |
58     And I click on "Save" "button" in the "sticky-footer" "region"
59     When I navigate to "Database" in current page administration
60     And I click on "Add entry" "button"
61     Then I should see "Form extra!"
63   @javascript
64   Scenario: Edit advanced search template
65     Given I set the field "Templates tertiary navigation" to "Advanced search template"
66     And I set the following fields to these values:
67       | Advanced search template | New advanced search template! |
68     And I click on "Save" "button" in the "sticky-footer" "region"
69     When I navigate to "Database" in current page administration
70     And I click on "Advanced search" "checkbox"
71     Then I should see "New advanced search template!"
73   @javascript
74   Scenario: Edit without the wysiwyg editor
75     Given I click on "Enable code editor" "checkbox"
76     And I set the following fields to these values:
77       | Repeated entry | <span class="d-none">Nope</span>Yep! |
78     And I click on "Save" "button" in the "sticky-footer" "region"
79     When I navigate to "Database" in current page administration
80     Then I should not see "Nope"
81     And I should see "Yep!"
83   @javascript
84   Scenario: Edit CSS teamplate
85     Given I click on "Enable code editor" "checkbox"
86     And I set the following fields to these values:
87       | Repeated entry | <span class="hideme">Nope</span>Yep! |
88     And I click on "Save" "button" in the "sticky-footer" "region"
89     And I set the field "Templates tertiary navigation" to "Custom CSS"
90     And I set the following fields to these values:
91       | Custom CSS | .hideme {display: none;} |
92     And I click on "Save" "button" in the "sticky-footer" "region"
93     When I navigate to "Database" in current page administration
94     Then I should not see "Nope"
95     And I should see "Yep!"
97   @javascript
98   Scenario: Edit Custom JavaScript
99     Given I click on "Enable code editor" "checkbox"
100     And I set the following fields to these values:
101       | Repeated entry | <span id="hideme">Nope</span>Yep! |
102     And I click on "Save" "button" in the "sticky-footer" "region"
103     And I set the field "Templates tertiary navigation" to "Custom JavaScript"
104     And I set the following fields to these values:
105       | Custom JavaScript | window.onload = () => document.querySelector('#hideme').style.display = 'none'; |
106     And I click on "Save" "button" in the "sticky-footer" "region"
107     When I navigate to "Database" in current page administration
108     Then I should not see "Nope"
109     And I should see "Yep!"
111   @javascript
112   Scenario: Reset database activity template
113     Given I set the following fields to these values:
114       | Header         | New header!                  |
115       | Repeated entry | This is the template content |
116       | Footer         | New footer!                  |
117     And I click on "Save" "button" in the "sticky-footer" "region"
118     And I navigate to "Database" in current page administration
119     And I should see "New header!"
120     And I should see "This is the template content"
121     And I should see "New footer!"
122     And I should not see "Student entry 1"
123     And I should not see "Some content 1"
124     When I navigate to "Templates" in current page administration
125     And I set the field "Templates tertiary navigation" to "List view template"
126     And I click on "Actions" "button"
127     And I choose "Reset current template" in the open action menu
128     And I should see "This will permanently remove the List view template for your current preset."
129     And I click on "Reset" "button" in the "Reset template?" "dialogue"
130     Then I should see "Template reset"
131     And I navigate to "Database" in current page administration
132     And I should not see "New header!"
133     And I should not see "This is the template content"
134     And I should not see "New footer!"
135     And I should see "Student entry 1"
136     And I should see "Some content 1"
138   @javascript
139   Scenario: Reset all database templates using the action menu
140     Given the following "mod_data > templates" exist:
141       | database | name            | content        |
142       | data1    | singletemplate  | Initial single |
143       | data1    | listtemplate    | Initial list   |
144       | data1    | addtemplate     | Initial add    |
145       | data1    | asearchtemplate | Initial search |
146     And I navigate to "Database" in current page administration
147     And I should see "Initial list"
148     And I should not see "Student entry 1"
149     And I should not see "Some content 1"
150     And I click on "Advanced search" "checkbox"
151     And I should see "Initial search"
152     And I set the field "View mode tertiary navigation" to "Single view"
153     And I should see "Initial single"
154     And I should not see "Student entry 1"
155     And I should not see "Some content 1"
156     And I click on "Add entry" "button"
157     And I should see "Initial add"
158     When I navigate to "Templates" in current page administration
159     And I click on "Actions" "button"
160     And I choose "Reset all templates" in the open action menu
161     And I should see "You're about to remove all templates for your current preset."
162     And I click on "Reset" "button" in the "Reset all templates?" "dialogue"
163     Then I should see "All templates reset"
164     And I navigate to "Database" in current page administration
165     And I should not see "Initial list"
166     And I should see "Student entry 1"
167     And I should see "Some content 1"
168     And I click on "Advanced search" "checkbox"
169     And I should not see "Initial search"
170     And I set the field "View mode tertiary navigation" to "Single view"
171     And I should not see "Initial single"
172     And I should see "Student entry 1"
173     And I should see "Some content 1"
174     And I click on "Add entry" "button"
175     And I should not see "Initial add"
177   @javascript
178   Scenario: Reset all database templates using the reset template button
179     Given the following "mod_data > templates" exist:
180       | database | name            | content        |
181       | data1    | singletemplate  | Initial single |
182       | data1    | listtemplate    | Initial list   |
183       | data1    | addtemplate     | Initial add    |
184       | data1    | asearchtemplate | Initial search |
185     And I navigate to "Database" in current page administration
186     And I should see "Initial list"
187     And I should not see "Student entry 1"
188     And I should not see "Some content 1"
189     And I click on "Advanced search" "checkbox"
190     And I should see "Initial search"
191     And I set the field "View mode tertiary navigation" to "Single view"
192     And I should see "Initial single"
193     And I should not see "Student entry 1"
194     And I should not see "Some content 1"
195     And I click on "Add entry" "button"
196     And I should see "Initial add"
197     When I navigate to "Templates" in current page administration
198     And I click on "Actions" "button"
199     And I choose "Reset current template" in the open action menu
200     And I should see "This will permanently remove the Add entry template for your current preset."
201     And I click on "Reset all templates" "checkbox"
202     And I click on "Reset" "button" in the "Reset template?" "dialogue"
203     Then I should see "All templates reset"
204     And I navigate to "Database" in current page administration
205     And I should not see "Initial list"
206     And I should see "Student entry 1"
207     And I should see "Some content 1"
208     And I click on "Advanced search" "checkbox"
209     And I should not see "Initial search"
210     And I set the field "View mode tertiary navigation" to "Single view"
211     And I should not see "Initial single"
212     And I should see "Student entry 1"
213     And I should see "Some content 1"
214     And I click on "Add entry" "button"
215     And I should not see "Initial add"