Proyectos de Subversion Moodle

Rev

| Ultima modificación | Ver Log |

Rev Autor Línea Nro. Línea
1 efrain 1
@mod @mod_data @javascript @_file_upload
2
Feature: Users can import presets
3
  In order to use presets
4
  As a user
5
  I need to import and apply presets from zip files
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 | n     | C1     | data1    |
20
 
21
  Scenario: Teacher can import from preset page on an empty database
22
    Given I am on the "Mountain landscapes" "data activity" page logged in as teacher1
23
    And I follow "Presets"
24
    And I choose the "Import preset" item in the "Action" action menu
25
    And I upload "mod/data/tests/fixtures/image_gallery_preset.zip" file to "Preset file" filemanager
26
    When I click on "Import preset and apply" "button"
27
    Then I should not see "Field mappings"
28
    And I should see "Image" in the "image" "table_row"
29
 
30
  Scenario: Teacher can import from preset page on a database with fields
31
    Given the following "mod_data > fields" exist:
32
      | database | type | name              | description              |
33
      | data1    | text | Test field name   | Test field description   |
34
    And I am on the "Mountain landscapes" "data activity" page logged in as teacher1
35
    And I follow "Presets"
36
    And I choose the "Import preset" item in the "Action" action menu
37
    And I upload "mod/data/tests/fixtures/image_gallery_preset.zip" file to "Preset file" filemanager
38
    When I click on "Import preset and apply" "button"
39
    Then I should see "Field mappings"
40
    And I should see "image"
41
    And I should see "Create a new field" in the "image" "table_row"
42
 
43
  Scenario: Teacher can import from preset page on a database with entries
44
    And the following "mod_data > fields" exist:
45
      | database | type | name   | description              |
46
      | data1    | text | field1 | Test field description   |
47
    And the following "mod_data > templates" exist:
48
      | database | name            |
49
      | data1    | singletemplate  |
50
      | data1    | listtemplate    |
51
      | data1    | addtemplate     |
52
      | data1    | asearchtemplate |
53
      | data1    | rsstemplate     |
54
    And the following "mod_data > entries" exist:
55
      | database | field1          |
56
      | data1    | Student entry 1 |
57
    And I am on the "Mountain landscapes" "data activity" page logged in as teacher1
58
    And I follow "Presets"
59
    And I choose the "Import preset" item in the "Action" action menu
60
    And I upload "mod/data/tests/fixtures/image_gallery_preset.zip" file to "Preset file" filemanager
61
    When I click on "Import preset and apply" "button"
62
    Then I should see "Field mappings"
63
    And I should see "image"
64
    And I should see "Create a new field" in the "image" "table_row"
65
 
66
  Scenario: Teacher can import from field page on a database with entries
67
    And the following "mod_data > fields" exist:
68
      | database | type | name   | description              |
69
      | data1    | text | field1 | Test field description   |
70
    And the following "mod_data > templates" exist:
71
      | database | name            |
72
      | data1    | singletemplate  |
73
      | data1    | listtemplate    |
74
      | data1    | addtemplate     |
75
      | data1    | asearchtemplate |
76
      | data1    | rsstemplate     |
77
    And the following "mod_data > entries" exist:
78
      | database | field1          |
79
      | data1    | Student entry 1 |
80
    And I am on the "Mountain landscapes" "data activity" page logged in as teacher1
81
    And I follow "Presets"
82
    And I choose the "Import preset" item in the "Action" action menu
83
    And I upload "mod/data/tests/fixtures/image_gallery_preset.zip" file to "Preset file" filemanager
84
    When I click on "Import preset and apply" "button"
85
    Then I should see "Field mappings"
86
    And I should see "title"
87
    And I should see "Create a new field" in the "title" "table_row"
88
    # We map existing field to keep the entry data
89
    And I set the field "id_title" to "Map to field1"
90
    And I click on "Continue" "button"
91
    And I follow "Database"
92
    And I should see "Student entry"
93
 
94
  Scenario: Teacher can import from zero state page on an empty database
95
    Given I am on the "Mountain landscapes" "data activity" page logged in as teacher1
96
    And I click on "Import a preset" "button"
97
    And I upload "mod/data/tests/fixtures/image_gallery_preset.zip" file to "Preset file" filemanager
98
    When I click on "Import preset and apply" "button"
99
    Then I should not see "Field mappings"
100
    And I should see "Image" in the "image" "table_row"
101
 
102
  Scenario: Importing a preset could create new fields
103
    Given the following "mod_data > fields" exist:
104
      | database | type | name    |
105
      | data1    | text | title   |
106
    And I am on the "Mountain landscapes" "data activity" page logged in as teacher1
107
    And I follow "Fields"
108
    And I should see "title"
109
    And I should not see "Description"
110
    And I should not see "image"
111
    And I follow "Presets"
112
    And I choose the "Import preset" item in the "Action" action menu
113
    And I upload "mod/data/tests/fixtures/image_gallery_preset.zip" file to "Preset file" filemanager
114
    When I click on "Import preset and apply" "button"
115
    And I click on "Continue" "button"
116
    And I should see "Preset applied"
117
    Then I should see "title"
118
    And I should see "description" in the "description" "table_row"
119
    And I should see "image" in the "image" "table_row"
120
 
121
  Scenario: Importing a preset could create map fields
122
    Given the following "mod_data > fields" exist:
123
      | database | type | name            |
124
      | data1    | text | oldtitle        |
125
    And I am on the "Mountain landscapes" "data activity" page logged in as teacher1
126
    And I follow "Fields"
127
    And I should see "oldtitle"
128
    And I should not see "Description"
129
    And I should not see "image"
130
    And I follow "Presets"
131
    And I choose the "Import preset" item in the "Action" action menu
132
    And I upload "mod/data/tests/fixtures/image_gallery_preset.zip" file to "Preset file" filemanager
133
    When I click on "Import preset and apply" "button"
134
    # Let's map a field that is not mapped by default
135
    And I should see "Create a new field" in the "oldtitle" "table_row"
136
    And I set the field "id_title" to "Map to oldtitle"
137
    And I click on "Continue" "button"
138
    And I should see "Preset applied"
139
    Then I should not see "oldtitle"
140
    And I should see "title"
141
    And I should see "description" in the "description" "table_row"
142
    And I should see "image" in the "image" "table_row"
143
 
144
  Scenario: Importing same preset twice doesn't show mapping dialogue
145
    # Importing a preset on an empty database doesn't show the mapping dialogue, so we add a field for the database
146
    # not to be empty.
147
    Given the following "mod_data > fields" exist:
148
      | database | type | name    |
149
      | data1    | text | title   |
150
    And I am on the "Mountain landscapes" "data activity" page logged in as teacher1
151
    And I follow "Presets"
152
    And I choose the "Import preset" item in the "Action" action menu
153
    And I upload "mod/data/tests/fixtures/image_gallery_preset.zip" file to "Preset file" filemanager
154
    When I click on "Import preset and apply" "button"
155
    And I should see "Field mappings"
156
    And I click on "Continue" "button"
157
    And I should see "Preset applied"
158
    And I follow "Presets"
159
    And I choose the "Import preset" item in the "Action" action menu
160
    And I upload "mod/data/tests/fixtures/image_gallery_preset.zip" file to "Preset file" filemanager
161
    And I click on "Import preset and apply" "button"
162
    Then I should not see "Field mappings"
163
    And I should see "Preset applied"
164
 
165
  Scenario: Teacher can import from field page on a non-empty database and previous fields will be removed
166
    Given the following "mod_data > fields" exist:
167
      | database | type | name              | description              |
168
      | data1    | text | Test field name   | Test field description   |
169
    And I am on the "Mountain landscapes" "data activity" page logged in as teacher1
170
    And I follow "Presets"
171
    And I click on "Actions" "button"
172
    And I choose "Import preset" in the open action menu
173
    And I upload "mod/data/tests/fixtures/image_gallery_preset.zip" file to "Preset file" filemanager
174
    When I click on "Import preset and apply" "button"
175
    And I click on "Continue" "button"
176
    Then I should see "Preset applied."
177
    And I follow "Fields"
178
    And I should see "image"
179
    And I should see "title"
180
    And I should not see "Test field name"