MDL-75234 mod_data: add default templates behats
Most behats access the templates page just to autocreate the default templates. This is not needed anymore and most behats can be optimized.
This commit is contained in:
@@ -22,17 +22,10 @@ Feature: Users can add entries to database activities
|
||||
|
||||
@javascript
|
||||
Scenario: Students can add entries to a database
|
||||
Given I am on the "Course 1" course page logged in as teacher1
|
||||
And I add a "Short text" field to "Test database name" database and I fill the form with:
|
||||
| Field name | Test field name |
|
||||
| Field description | Test field description |
|
||||
And I add a "Short text" field to "Test database name" database and I fill the form with:
|
||||
| Field name | Test field 2 name |
|
||||
| Field description | Test field 2 description |
|
||||
# To generate the default templates.
|
||||
And I navigate to "Templates" in current page administration
|
||||
And I wait until the page is ready
|
||||
And I log out
|
||||
Given the following "mod_data > fields" exist:
|
||||
| database | type | name | description |
|
||||
| data1 | text | Test field name | Test field description |
|
||||
| data1 | text | Test field 2 name | Test field 2 description |
|
||||
When I am on the "Course 1" course page logged in as student1
|
||||
And I add an entry to "Test database name" database with:
|
||||
| Test field name | Student original entry |
|
||||
@@ -96,8 +89,6 @@ Feature: Users can add entries to database activities
|
||||
And I press "Save and display"
|
||||
And I add a "Short text" field to "Test database name" database and I fill the form with:
|
||||
| Field name | Test1 |
|
||||
And I navigate to "Templates" in current page administration
|
||||
And I press "Save template"
|
||||
And I log out
|
||||
And I am on the "Test database name" "data activity" page logged in as student1
|
||||
And I press "Add entry"
|
||||
@@ -133,14 +124,12 @@ Feature: Users can add entries to database activities
|
||||
Scenario Outline: Users see the Add entry button in the view page when some field has been created only.
|
||||
Given I am on the "Test database name" "data activity" page logged in as <user>
|
||||
And I should not see "Add entry"
|
||||
When I log out
|
||||
And I am on the "Test database name" "data activity" page logged in as teacher1
|
||||
And I add a "Short text" field to "Test database name" database and I fill the form with:
|
||||
| Field name | Test field name |
|
||||
| Field description | Test field description |
|
||||
And I log out
|
||||
And I am on the "Test database name" "data activity" page logged in as <user>
|
||||
Then I should see "Add entry"
|
||||
When the following "mod_data > fields" exist:
|
||||
| database | type | name | description |
|
||||
| data1 | text | Test field name | Test field description |
|
||||
Then I am on the "Test database name" "data activity" page logged in as <user>
|
||||
And I should see "Add entry"
|
||||
|
||||
Examples:
|
||||
| user |
|
||||
|
||||
@@ -36,8 +36,6 @@ Feature: View activity completion in the database activity
|
||||
And I press "Save and display"
|
||||
And I add a "Short text" field to "Music history" database and I fill the form with:
|
||||
| Field name | Instrument types |
|
||||
And I navigate to "Templates" in current page administration
|
||||
And I press "Save template"
|
||||
And I log out
|
||||
|
||||
Scenario: View automatic completion items as a teacher
|
||||
|
||||
@@ -50,8 +50,6 @@ Feature: Completion pass grade
|
||||
And I press "Save and display"
|
||||
And I add a "Short text" field to "Music history" database and I fill the form with:
|
||||
| Field name | Instrument types |
|
||||
And I navigate to "Templates" in current page administration
|
||||
And I press "Save template"
|
||||
And I log out
|
||||
|
||||
Scenario: View automatic completion items as a teacher
|
||||
|
||||
@@ -0,0 +1,158 @@
|
||||
@mod @mod_data
|
||||
Feature: Users can use mod_data without editing the templates
|
||||
In order to use the database module
|
||||
As a teacher
|
||||
I need to manage fields and entries using always the default templates.
|
||||
|
||||
Background:
|
||||
Given the following "users" exist:
|
||||
| username | firstname | lastname | email |
|
||||
| teacher1 | Teacher | 1 | teacher1@example.com |
|
||||
And the following "courses" exist:
|
||||
| fullname | shortname | category |
|
||||
| Course 1 | C1 | 0 |
|
||||
And the following "course enrolments" exist:
|
||||
| user | course | role |
|
||||
| teacher1 | C1 | editingteacher |
|
||||
And the following "activities" exist:
|
||||
| activity | name | intro | course | idnumber |
|
||||
| data | Test database name | Database intro | C1 | data1 |
|
||||
And the following "mod_data > fields" exist:
|
||||
| database | type | name | description |
|
||||
| data1 | text | field1 | Test field description |
|
||||
| data1 | text | field2 | Test field 2 description |
|
||||
And the following "mod_data > entries" exist:
|
||||
| database | field1 | field2 |
|
||||
| data1 | Student entry 1 | Some content 1 |
|
||||
| data1 | Student entry 2 | Some content 2 |
|
||||
And I am on the "Test database name" "data activity" page logged in as teacher1
|
||||
|
||||
@javascript
|
||||
Scenario: The default view templates should be updated when a field is added.
|
||||
Given I navigate to "Database" in current page administration
|
||||
And I should see "field1"
|
||||
And I should see "field2"
|
||||
And I should see "Student entry 1"
|
||||
And I should see "Some content 1"
|
||||
And I should see "Student entry 2"
|
||||
And I should see "Some content 2"
|
||||
And I set the field "View mode tertiary navigation" to "Single view"
|
||||
And I should see "field1"
|
||||
And I should see "field2"
|
||||
And I should see "Student entry 1"
|
||||
And I should see "Some content 1"
|
||||
And I should not see "Student entry 2"
|
||||
And I should not see "Some content 2"
|
||||
When the following "mod_data > fields" exist:
|
||||
| database | type | name | description |
|
||||
| data1 | text | field3 | Test field 3 description |
|
||||
Then I navigate to "Database" in current page administration
|
||||
And I should see "field1"
|
||||
And I should see "field2"
|
||||
And I should see "field3"
|
||||
And I should see "Student entry 1"
|
||||
And I should see "Some content 1"
|
||||
And I should see "Student entry 2"
|
||||
And I should see "Some content 2"
|
||||
And I set the field "View mode tertiary navigation" to "Single view"
|
||||
And I should see "field1"
|
||||
And I should see "field2"
|
||||
And I should see "field3"
|
||||
And I should see "Student entry 1"
|
||||
And I should see "Some content 1"
|
||||
And I should not see "Student entry 2"
|
||||
And I should not see "Some content 2"
|
||||
|
||||
Scenario: The default add templates should be updated when a field is added.
|
||||
Given I navigate to "Database" in current page administration
|
||||
And I click on "Add entry" "button"
|
||||
And I should see "field1"
|
||||
And I should see "field2"
|
||||
When the following "mod_data > fields" exist:
|
||||
| database | type | name | description |
|
||||
| data1 | text | field3 | Test field 3 description |
|
||||
Then I navigate to "Database" in current page administration
|
||||
And I click on "Add entry" "button"
|
||||
And I should see "field1"
|
||||
And I should see "field2"
|
||||
And I should see "field3"
|
||||
|
||||
@javascript
|
||||
Scenario: The default view templates should be updated when a field is deleted.
|
||||
Given I navigate to "Database" in current page administration
|
||||
And I should see "field1"
|
||||
And I should see "field2"
|
||||
And I should see "Student entry 1"
|
||||
And I should see "Some content 1"
|
||||
And I should see "Student entry 2"
|
||||
And I should see "Some content 2"
|
||||
And I set the field "View mode tertiary navigation" to "Single view"
|
||||
And I should see "field1"
|
||||
And I should see "field2"
|
||||
And I should see "Student entry 1"
|
||||
And I should see "Some content 1"
|
||||
And I should not see "Student entry 2"
|
||||
And I should not see "Some content 2"
|
||||
When I navigate to "Fields" in current page administration
|
||||
And I click on "Delete" "link" in the "field2" "table_row"
|
||||
And I click on "Continue" "button"
|
||||
Then I navigate to "Database" in current page administration
|
||||
And I should see "field1"
|
||||
And I should not see "field2"
|
||||
And I should see "Student entry 1"
|
||||
And I should not see "Some content 1"
|
||||
And I should see "Student entry 2"
|
||||
And I should not see "Some content 2"
|
||||
And I set the field "View mode tertiary navigation" to "Single view"
|
||||
And I should see "field1"
|
||||
And I should not see "field2"
|
||||
And I should see "Student entry 1"
|
||||
And I should not see "Some content 1"
|
||||
And I should not see "Student entry 2"
|
||||
And I should not see "Some content 2"
|
||||
|
||||
Scenario: The default add templates should be updated when a field is deleted.
|
||||
Given I navigate to "Database" in current page administration
|
||||
And I click on "Add entry" "button"
|
||||
And I should see "field1"
|
||||
And I should see "field2"
|
||||
When I navigate to "Fields" in current page administration
|
||||
And I click on "Delete" "link" in the "field2" "table_row"
|
||||
And I click on "Continue" "button"
|
||||
Then I navigate to "Database" in current page administration
|
||||
And I click on "Add entry" "button"
|
||||
And I should see "field1"
|
||||
And I should not see "field2"
|
||||
|
||||
@javascript
|
||||
Scenario: The dynamic default templates can be reset after a manual edition.
|
||||
Given I navigate to "Templates" in current page administration
|
||||
And I set the following fields to these values:
|
||||
| Header | New header! |
|
||||
| Repeated entry | This is the template content |
|
||||
| Footer | New footer! |
|
||||
And I click on "Save template" "button"
|
||||
And I navigate to "Database" in current page administration
|
||||
And I should see "New header!"
|
||||
And I should see "This is the template content"
|
||||
And I should see "New footer!"
|
||||
And I should not see "Student entry 1"
|
||||
And I should not see "Some content 1"
|
||||
When I navigate to "Templates" in current page administration
|
||||
And I click on "Reset template" "button"
|
||||
And I click on "Reset template" "button" in the "Reset template?" "dialogue"
|
||||
And I should see "Template reset"
|
||||
And I navigate to "Database" in current page administration
|
||||
And I should not see "New header!"
|
||||
And I should not see "This is the template content"
|
||||
And I should not see "New footer!"
|
||||
And I should see "Student entry 1"
|
||||
And I should see "Some content 1"
|
||||
Then the following "mod_data > fields" exist:
|
||||
| database | type | name | description |
|
||||
| data1 | text | field3 | Test field 3 description |
|
||||
And I navigate to "Database" in current page administration
|
||||
And I click on "Add entry" "button"
|
||||
And I should see "field1"
|
||||
And I should see "field2"
|
||||
And I should see "field3"
|
||||
@@ -21,13 +21,6 @@ Feature: Users can edit the database templates
|
||||
| database | type | name | description |
|
||||
| data1 | text | field1 | Test field description |
|
||||
| data1 | text | field2 | Test field 2 description |
|
||||
And the following "mod_data > templates" exist:
|
||||
| database | name |
|
||||
| data1 | singletemplate |
|
||||
| data1 | listtemplate |
|
||||
| data1 | addtemplate |
|
||||
| data1 | asearchtemplate |
|
||||
| data1 | rsstemplate |
|
||||
And the following "mod_data > entries" exist:
|
||||
| database | field1 | field2 |
|
||||
| data1 | Student entry 1 | Some content 1 |
|
||||
@@ -113,3 +106,27 @@ Feature: Users can edit the database templates
|
||||
When I navigate to "Database" in current page administration
|
||||
Then I should not see "Nope"
|
||||
And I should see "Yep!"
|
||||
|
||||
@javascript
|
||||
Scenario: Reset database activity template
|
||||
Given I set the following fields to these values:
|
||||
| Header | New header! |
|
||||
| Repeated entry | This is the template content |
|
||||
| Footer | New footer! |
|
||||
And I click on "Save template" "button"
|
||||
And I navigate to "Database" in current page administration
|
||||
And I should see "New header!"
|
||||
And I should see "This is the template content"
|
||||
And I should see "New footer!"
|
||||
And I should not see "Student entry 1"
|
||||
And I should not see "Some content 1"
|
||||
When I navigate to "Templates" in current page administration
|
||||
And I click on "Reset template" "button"
|
||||
And I click on "Reset template" "button" in the "Reset template?" "dialogue"
|
||||
Then I should see "Template reset"
|
||||
And I navigate to "Database" in current page administration
|
||||
And I should not see "New header!"
|
||||
And I should not see "This is the template content"
|
||||
And I should not see "New footer!"
|
||||
And I should see "Student entry 1"
|
||||
And I should see "Some content 1"
|
||||
|
||||
@@ -30,8 +30,6 @@ Feature: Users can edit approved entries in database activities
|
||||
And I add a "Short text" field to "Test database name" database and I fill the form with:
|
||||
| Field name | Test field name |
|
||||
| Field description | Test field description |
|
||||
# To generate the default templates.
|
||||
And I navigate to "Templates" in current page administration
|
||||
And I log out
|
||||
# Add an entry as a student.
|
||||
And I am on the "Test database name" "data activity" page logged in as student1
|
||||
@@ -62,8 +60,6 @@ Feature: Users can edit approved entries in database activities
|
||||
And I add a "Short text" field to "Test database name" database and I fill the form with:
|
||||
| Field name | Test field name |
|
||||
| Field description | Test field description |
|
||||
# To generate the default templates.
|
||||
And I navigate to "Templates" in current page administration
|
||||
And I log out
|
||||
# Add an entry as a student.
|
||||
And I am on the "Test database name" "data activity" page logged in as student1
|
||||
|
||||
@@ -19,109 +19,29 @@ Feature: Users can be required to specify certain fields when adding entries to
|
||||
And the following "activities" exist:
|
||||
| activity | name | intro | course | idnumber |
|
||||
| data | Test database name | n | C1 | data1 |
|
||||
And I log in as "teacher1"
|
||||
And I am on "Course 1" course homepage
|
||||
And I add a "Short text" field to "Test database name" database and I fill the form with:
|
||||
| Field name | Base Text input |
|
||||
| Required | yes |
|
||||
| Field description | Base Text input |
|
||||
And I add a "Checkbox" field to "Test database name" database and I fill the form with:
|
||||
| Field name | Required Checkbox |
|
||||
| Field description | Required Checkbox |
|
||||
| Required | yes |
|
||||
| Options | Required Checkbox Option 1 |
|
||||
And I follow "Fields"
|
||||
And I select "Checkbox" from the "newtype" singleselect
|
||||
And I set the following fields to these values:
|
||||
| Field name | Required Two-Option Checkbox |
|
||||
| Field description | Required Two-Option Checkbox |
|
||||
| Required | yes |
|
||||
And I set the field "Options" to multiline:
|
||||
"""
|
||||
RTOC Option 1
|
||||
RTOC Option 2
|
||||
"""
|
||||
And I press "Add"
|
||||
And I add a "Coordinates" field to "Test database name" database and I fill the form with:
|
||||
| Field name | Required Coordinates |
|
||||
| Field description | Required Coordinates |
|
||||
| Required | yes |
|
||||
And I add a "Dropdown list" field to "Test database name" database and I fill the form with:
|
||||
| Field name | Required Menu |
|
||||
| Field description | Required Menu |
|
||||
| Required | yes |
|
||||
| Options | Option 1 |
|
||||
And I add a "Number" field to "Test database name" database and I fill the form with:
|
||||
| Field name | Required Number |
|
||||
| Field description | Required Number |
|
||||
| Required | yes |
|
||||
And I add a "Radio button" field to "Test database name" database and I fill the form with:
|
||||
| Field name | Required Radio |
|
||||
| Field description | Required Radio |
|
||||
| Required | yes |
|
||||
| Options | Required Radio Option 1 |
|
||||
And I add a "Short text" field to "Test database name" database and I fill the form with:
|
||||
| Field name | Required Text input |
|
||||
| Field description | Required Text input |
|
||||
| Required | yes |
|
||||
And I add a "Text area" field to "Test database name" database and I fill the form with:
|
||||
| Field name | Required Text area |
|
||||
| Field description | Required Text area |
|
||||
| Required | yes |
|
||||
And I add a "URL" field to "Test database name" database and I fill the form with:
|
||||
| Field name | Required URL |
|
||||
| Field description | Required URL |
|
||||
| Required | yes |
|
||||
And I add a "Multi-select list" field to "Test database name" database and I fill the form with:
|
||||
| Field name | Required Multimenu |
|
||||
| Field description | Required Multimenu |
|
||||
| Required | yes |
|
||||
| Options | Option 1 |
|
||||
And I follow "Fields"
|
||||
And I select "Multi-select list" from the "newtype" singleselect
|
||||
And I set the following fields to these values:
|
||||
| Field name | Required Two-Option Multimenu |
|
||||
| Field description | Required Two-Option Multimenu |
|
||||
| Required | yes |
|
||||
And I set the field "Options" to multiline:
|
||||
"""
|
||||
Option 1
|
||||
Option 2
|
||||
"""
|
||||
And I press "Add"
|
||||
And I add a "Checkbox" field to "Test database name" database and I fill the form with:
|
||||
| Field name | Not required Checkbox |
|
||||
| Field description | Not required Checkbox |
|
||||
| Options | Not required Checkbox Option 1 |
|
||||
And I add a "Coordinates" field to "Test database name" database and I fill the form with:
|
||||
| Field name | Not required Coordinates |
|
||||
| Field description | Not required Coordinates |
|
||||
And I add a "Dropdown list" field to "Test database name" database and I fill the form with:
|
||||
| Field name | Not required Menu |
|
||||
| Field description | Not required Menu |
|
||||
| Options | Option 1 |
|
||||
And I add a "Number" field to "Test database name" database and I fill the form with:
|
||||
| Field name | Not required Number |
|
||||
| Field description | Not required Number |
|
||||
And I add a "Radio button" field to "Test database name" database and I fill the form with:
|
||||
| Field name | Not required Radio |
|
||||
| Field description | Not required Radio |
|
||||
| Options | Not required Radio Option 1 |
|
||||
And I add a "Short text" field to "Test database name" database and I fill the form with:
|
||||
| Field name | Not required Text input |
|
||||
| Field description | Not required Text input |
|
||||
And I add a "Text area" field to "Test database name" database and I fill the form with:
|
||||
| Field name | Not required Text area |
|
||||
| Field description | Not required Text area |
|
||||
And I add a "URL" field to "Test database name" database and I fill the form with:
|
||||
| Field name | Not required URL |
|
||||
| Field description | Not required URL |
|
||||
And I add a "Multi-select list" field to "Test database name" database and I fill the form with:
|
||||
| Field name | Not required Multimenu |
|
||||
| Field description | Not required Multimenu |
|
||||
| Options | Option 1 |
|
||||
And I navigate to "Templates" in current page administration
|
||||
And I log out
|
||||
And the following "mod_data > fields" exist:
|
||||
| database | type | name | required | description | param1 |
|
||||
| data1 | text | Base Text input | 1 | Base Text input | |
|
||||
| data1 | checkbox | Required Checkbox | 1 | Base Text input | Required Checkbox Option 1 |
|
||||
| data1 | checkbox | Required Two-Option Checkbox | 1 | Required Two-Option Checkbox | RTOC Option 1\nRTOC Option 2 |
|
||||
| data1 | latlong | Required Coordinates | 1 | Required Coordinates | |
|
||||
| data1 | menu | Required Menu | 1 | Required Menu | Option 1 |
|
||||
| data1 | number | Required Number | 1 | Required Number | |
|
||||
| data1 | radiobutton | Required Radio | 1 | Required Radio | Required Radio Option 1 |
|
||||
| data1 | text | Required Text input | 1 | Required Text input | |
|
||||
| data1 | textarea | Required Text area | 1 | Required Text area | |
|
||||
| data1 | url | Required URL | 1 | Required URL | |
|
||||
| data1 | multimenu | Required Multimenu | 1 | Required Multimenu | Option 1 |
|
||||
| data1 | multimenu | Required Two-Option Multimenu | 1 | Required Two-Option Multimenu | Option 1\nOption 2 |
|
||||
| data1 | checkbox | Not required Checkbox | 0 | Not required Checkbox | Not required Checkbox Option 1 |
|
||||
| data1 | latlong | Not required Coordinates | 0 | Not required Coordinates | |
|
||||
| data1 | menu | Not required Menu | 0 | Not required Menu | Option 1 |
|
||||
| data1 | number | Not required Number | 0 | Not required Number | |
|
||||
| data1 | radiobutton | Not required Radio | 0 | Not required Radio | Not required Radio Option 1 |
|
||||
| data1 | text | Not required Text input | 0 | Not required Text input | |
|
||||
| data1 | textarea | Not required Text area | 0 | Not required Text area | |
|
||||
| data1 | url | Not required URL | 0 | Not required URL | |
|
||||
| data1 | multimenu | Not required Multimenu | 0 | Not required Multimenu | Option 1 |
|
||||
|
||||
Scenario: Students receive errors for empty required fields but not for optional fields
|
||||
When I log in as "student1"
|
||||
|
||||
@@ -29,13 +29,6 @@ Feature: Users can view and search database entries
|
||||
| data1 | text | Test field name | Test field description |
|
||||
| data1 | text | Test field 2 name | Test field 2 description |
|
||||
| data1 | url | Test field 3 name | Test field 3 description |
|
||||
And the following "mod_data > templates" exist:
|
||||
| database | name |
|
||||
| data1 | singletemplate |
|
||||
| data1 | listtemplate |
|
||||
| data1 | addtemplate |
|
||||
| data1 | asearchtemplate |
|
||||
| data1 | rsstemplate |
|
||||
|
||||
@javascript
|
||||
Scenario: Students can view, list and search entries
|
||||
|
||||
@@ -120,6 +120,11 @@ class mod_data_generator extends testing_module_generator {
|
||||
$record['description'] = " This is testField - " . $this->databasefieldcount;
|
||||
}
|
||||
|
||||
if (isset($record['param1']) && !empty($record['param1'])) {
|
||||
// Some fields have multiline entries.
|
||||
$record['param1'] = str_replace('\n', "\n", $record['param1']);
|
||||
}
|
||||
|
||||
if (!isset($record['param1'])) {
|
||||
if ($record['type'] == 'checkbox') {
|
||||
$record['param1'] = implode("\n", array('opt1', 'opt2', 'opt3', 'opt4'));
|
||||
@@ -178,8 +183,6 @@ class mod_data_generator extends testing_module_generator {
|
||||
$field = data_get_field($record, $data);
|
||||
$field->insert_field();
|
||||
|
||||
data_generate_default_template($data, 'addtemplate', 0, false, true);
|
||||
|
||||
return $field;
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user