Proyectos de Subversion Moodle

Rev

| Ultima modificación | Ver Log |

Rev Autor Línea Nro. Línea
1 efrain 1
@mod @mod_data @javascript
2
Feature: Users can use predefined presets
3
  In order to use presets
4
  As a user
5
  I need to select an existing preset
6
 
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     | Mountain landscapes | introduction... | C1     | data1    |
20
    And the following "mod_data > fields" exist:
21
      | database | type | name              | description              |
22
      | data1    | text | Test field name   | Test field description   |
23
 
24
  Scenario: Using a preset on a non empty database could create new fields
25
    Given the following "mod_data > fields" exist:
26
      | database | type | name    |
27
      | data1    | text | title   |
28
    And I am on the "Mountain landscapes" "data activity" page logged in as teacher1
29
    And I follow "Fields"
30
    And I should see "title"
31
    And I should not see "Description"
32
    And I should not see "image"
33
    And I follow "Presets"
34
    And I click on "fullname" "radio" in the "Image gallery" "table_row"
35
    And I click on "Use this preset" "button"
36
    And I should see "Apply preset Image gallery"
37
    And I click on "Map fields" "button"
38
    And I should see "Field mappings"
39
    When I click on "Continue" "button"
40
    And I should see "Preset applied"
41
    Then I should see "title"
42
    And I should see "description" in the "description" "table_row"
43
    And I should see "image" in the "image" "table_row"
44
 
45
  Scenario: Using a preset on a non-empty database could show the option to map fields
46
    Given the following "mod_data > fields" exist:
47
      | database | type | name            |
48
      | data1    | text | oldtitle        |
49
    And I am on the "Mountain landscapes" "data activity" page logged in as teacher1
50
    And I follow "Fields"
51
    And I should see "oldtitle"
52
    And I should not see "Description"
53
    And I should not see "image"
54
    And I follow "Presets"
55
    And I click on "fullname" "radio" in the "Image gallery" "table_row"
56
    And I click on "Use this preset" "button"
57
    # Let's map a field that is not mapped by default
58
    And I should see "Apply preset Image gallery"
59
    And I should see "Fields to be created: image, title, description"
60
    And I should see "Existing fields to be deleted: Test field name, oldtitle"
61
    When I click on "Map fields" "button"
62
    And I should see "Create a new field" in the "oldtitle" "table_row"
63
    And I set the field "id_title" to "Map to oldtitle"
64
    And I click on "Continue" "button"
65
    And I should see "Preset applied"
66
    Then I should not see "oldtitle"
67
    And I should see "title"
68
    And I should see "description" in the "description" "table_row"
69
    And I should see "image" in the "image" "table_row"
70
 
71
  Scenario: Teacher can use a preset from presets page on a database with existing entries
72
    # Creating an entry to test use a preset feature with databases with entries.
73
    Given the following "mod_data > entries" exist:
74
      | database | Test field name |
75
      | data1    | Student entry 1 |
76
    And I am on the "Mountain landscapes" "data activity" page logged in as teacher1
77
    And I follow "Presets"
78
    And I click on "fullname" "radio" in the "Image gallery" "table_row"
79
    And the "Use this preset" "button" should be enabled
80
    When I click on "Use this preset" "button"
81
    And I should see "Apply preset Image gallery"
82
    And I click on "Map fields" "button"
83
    Then I should see "Field mappings"
84
    And I should see "title"
85
    And I should see "Create a new field" in the "title" "table_row"
86
    # We map existing field to keep the entry data
87
    And I set the field "id_title" to "Map to Test field name"
88
    And I click on "Continue" "button"
89
    And I should see "Preset applied"
90
    And I follow "Fields"
91
    And I should see "title"
92
    And I follow "Database"
93
    And I should see "Student entry 1"
94
 
95
  Scenario: Using same preset twice doesn't show mapping dialogue and applies the preset directly
96
    Given I am on the "Mountain landscapes" "data activity" page logged in as teacher1
97
    And I follow "Presets"
98
    And I click on "fullname" "radio" in the "Image gallery" "table_row"
99
    When I click on "Use this preset" "button"
100
    And I should see "Apply preset"
101
    And I click on "Map fields" "button"
102
    And I set the field "id_title" to "Map to Test field name"
103
    And I click on "Continue" "button"
104
    And I should see "Preset applied"
105
    And I follow "Presets"
106
    And I click on "fullname" "radio" in the "Image gallery" "table_row"
107
    And I click on "Use this preset" "button"
108
    Then I should not see "Apply preset Image gallery"
109
    And I should see "Preset applied"
110
 
111
  Scenario: Using a preset from preset preview page on a non empty database could create new fields
112
    Given the following "mod_data > fields" exist:
113
      | database | type | name    |
114
      | data1    | text | title   |
115
    And I am on the "Mountain landscapes" "data activity" page logged in as teacher1
116
    And I follow "Fields"
117
    And I should see "title"
118
    And I should not see "Description"
119
    And I should not see "image"
120
    And I follow "Presets"
121
    And I click on "Image gallery" "link"
122
    And I click on "Use this preset" "button"
123
    And I should see "Apply preset Image gallery"
124
    When I click on "Apply preset" "button"
125
    And I should see "Preset applied"
126
    And I follow "Fields"
127
    Then I should see "title"
128
    And I should see "description" in the "description" "table_row"
129
    And I should see "image" in the "image" "table_row"
130
 
131
  Scenario: Using a preset from preset preview page on a non-empty database could show the option to map fields
132
    Given the following "mod_data > fields" exist:
133
      | database | type | name            |
134
      | data1    | text | oldtitle        |
135
    And I am on the "Mountain landscapes" "data activity" page logged in as teacher1
136
    And I follow "Fields"
137
    And I should see "oldtitle"
138
    And I should not see "Description"
139
    And I should not see "image"
140
    And I follow "Presets"
141
    And I click on "Image gallery" "link"
142
    And I click on "Use this preset" "button"
143
    # Let's map a field that is not mapped by default
144
    And I should see "Apply preset Image gallery"
145
    And I should see "Fields to be created: image, title, description"
146
    And I should see "Existing fields to be deleted: Test field name, oldtitle"
147
    When I click on "Map fields" "button"
148
    And I should see "Create a new field" in the "oldtitle" "table_row"
149
    And I set the field "id_title" to "Map to oldtitle"
150
    And I click on "Continue" "button"
151
    And I should see "Preset applied"
152
    Then I should not see "oldtitle"
153
    And I should see "title"
154
    And I should see "description" in the "description" "table_row"
155
    And I should see "image" in the "image" "table_row"
156
 
157
  Scenario: Teacher can use a preset from preset preview page on a database with existing entries
158
    # Creating an entry to test use a preset feature with databases with entries.
159
    Given the following "mod_data > entries" exist:
160
      | database | Test field name |
161
      | data1    | Student entry 1 |
162
    And I am on the "Mountain landscapes" "data activity" page logged in as teacher1
163
    And I follow "Presets"
164
    And I click on "Image gallery" "link"
165
    And the "Use this preset" "button" should be enabled
166
    When I click on "Use this preset" "button"
167
    And I should see "Apply preset Image gallery"
168
    And I click on "Map fields" "button"
169
    Then I should see "Field mappings"
170
    And I should see "title"
171
    And I should see "Create a new field" in the "title" "table_row"
172
    # We map existing field to keep the entry data
173
    And I set the field "id_title" to "Map to Test field name"
174
    And I click on "Continue" "button"
175
    And I should see "Preset applied"
176
    And I follow "Fields"
177
    And I should see "title"
178
    And I follow "Database"
179
    And I should see "Student entry 1"
180
 
181
  Scenario: Using same preset twice from preset preview page doesn't show mapping dialogue and applies the preset
182
  directly
183
    Given I am on the "Mountain landscapes" "data activity" page logged in as teacher1
184
    And I follow "Presets"
185
    And I click on "Image gallery" "link"
186
    When I click on "Use this preset" "button"
187
    And I should see "Apply preset Image gallery"
188
    And I click on "Map fields" "button"
189
    And I should see "Field mappings"
190
    And I set the field "id_title" to "Map to Test field name"
191
    And I click on "Continue" "button"
192
    And I should see "Preset applied"
193
    And I follow "Presets"
194
    And I click on "Image gallery" "link"
195
    And I click on "Use this preset" "button"
196
    Then I should not see "Field mappings"
197
    And I should see "Preset applied"
198
 
199
  Scenario: Apply preset dialogue should show helpful information to the user
200
    Given the following "activities" exist:
201
      | activity | name           | intro           | course | idnumber |
202
      | data     | Sea landscapes | introduction... | C1     | data2    |
203
    And the following "mod_data > fields" exist:
204
      | database | type | name            |
205
      | data2    | text | title        |
206
    And I am on the "Sea landscapes" "data activity" page logged in as teacher1
207
    And I follow "Presets"
208
    And I click on "Image gallery" "link"
209
    When I click on "Use this preset" "button"
210
    And I should see "Apply preset Image gallery"
211
    # Fields to be created only.
212
    Then I should see "Fields to be created: image, description"
213
    And I should not see "If fields to be deleted are of the same type as fields to be created"
214
    And I should not see "If fields to be deleted are of the same type as new fields in the preset"
215
    And I click on "Cancel" "button" in the "Apply preset Image gallery?" "dialogue"
216
    And I follow "Presets"
217
    And the following "mod_data > fields" exist:
218
      | database | type   | name          |
219
      | data2    | number | number        |
220
    And I click on "Image gallery" "link"
221
    And I click on "Use this preset" "button"
222
    And I should see "Apply preset Image gallery"
223
    # Fields to be created and fields to be deleted.
224
    And I should see "Fields to be created: image, description"
225
    And I should see "Existing fields to be deleted: number"
226
    And I should see "If fields to be deleted are of the same type as fields to be created"
227
    And I should not see "If fields to be deleted are of the same type as new fields in the preset"
228
    And I click on "Cancel" "button" in the "Apply preset Image gallery?" "dialogue"
229
    And I follow "Presets"
230
    And the following "mod_data > fields" exist:
231
      | database     | type      | name          |
232
      | data2        | textarea  | description   |
233
      | data2        | picture   | image         |
234
    And I click on "Image gallery" "link"
235
    And I click on "Use this preset" "button"
236
    And I should see "Apply preset Image gallery"
237
    # Fields to be deleted only.
238
    And I should see "Existing fields to be deleted: number"
239
    And I should not see "If fields to be deleted are of the same type as fields to be created"
240
    And I should see "If fields to be deleted are of the same type as new fields in the preset"
241
 
242
  Scenario: Teacher can use a preset on a non-empty database and previous fields will be removed
243
    Given I am on the "Mountain landscapes" "data activity" page logged in as teacher1
244
    And I follow "Fields"
245
    And I should see "Test field name"
246
    And I follow "Presets"
247
    And I click on "fullname" "radio" in the "Image gallery" "table_row"
248
    And I click on "Use this preset" "button"
249
    And I should see "Existing fields to be deleted: Test field name"
250
    When I click on "Apply preset" "button"
251
    Then I should see "Preset applied."
252
    And I should see "image"
253
    And I should see "title"
254
    And I should not see "Test field name"