MDL-71913 mod_data: Update behat tests

This commit is contained in:
Mihail Geshoski 2021-07-26 16:11:13 +08:00
parent 671375115f
commit 6c0e1eee94
8 changed files with 57 additions and 63 deletions

View file

@ -24,14 +24,14 @@ Feature: Restore Moodle 2 course backups with different user data settings
And I add a "Text input" field to "Test database name" database and I fill the form with: And I add a "Text input" field to "Test database name" database and I fill the form with:
| Field name | Test field name | | Field name | Test field name |
| Field description | Test field description | | Field description | Test field description |
And I click on "Templates" "link" in the "region-main" "region" And I navigate to "Templates" in current page administration
And I wait until the page is ready And I wait until the page is ready
And I log out And I log out
And I log in as "student1" And I log in as "student1"
And I am on "Course 1" course homepage And I am on "Course 1" course homepage
And I add an entry to "Test database name" database with: And I add an entry to "Test database name" database with:
| Test field name | Student entry | | Test field name | Student entry |
And I press "Save and view" And I press "Save"
And I log out And I log out
And I log in as "admin" And I log in as "admin"
And I backup "Course 1" course using this options: And I backup "Course 1" course using this options:

View file

@ -26,7 +26,7 @@ Feature: Using the database activities which support point scale
And I add a "Text input" field to "Test database name" database and I fill the form with: And I add a "Text input" field to "Test database name" database and I fill the form with:
| Field name | Test field name | | Field name | Test field name |
| Field description | Test field description | | Field description | Test field description |
And I follow "Templates" And I navigate to "Templates" in current page administration
And I wait until the page is ready And I wait until the page is ready
And I am on the "Test database name" "data activity editing" page And I am on the "Test database name" "data activity editing" page
And I expand all fieldsets And I expand all fieldsets
@ -39,10 +39,10 @@ Feature: Using the database activities which support point scale
And I add an entry to "Test database name" database with: And I add an entry to "Test database name" database with:
| Test field name | Student original entry | | Test field name | Student original entry |
| Test field name | Student original entry 2 | | Test field name | Student original entry 2 |
And I press "Save and view" And I press "Save"
And I log out And I log out
And I am on the "Test database name" "data activity" page logged in as teacher1 And I am on the "Test database name" "data activity" page logged in as teacher1
And I follow "View single" And I select "Single view" from the "jump" singleselect
And I set the field "rating" to "51" And I set the field "rating" to "51"
And I am on the "Test database name" "data activity editing" page And I am on the "Test database name" "data activity editing" page
And I expand all fieldsets And I expand all fieldsets

View file

@ -30,25 +30,25 @@ Feature: Users can add entries to database activities
| Field name | Test field 2 name | | Field name | Test field 2 name |
| Field description | Test field 2 description | | Field description | Test field 2 description |
# To generate the default templates. # To generate the default templates.
And I follow "Templates" And I navigate to "Templates" in current page administration
And I wait until the page is ready And I wait until the page is ready
And I log out And I log out
When I am on the "Course 1" course page logged in as student1 When I am on the "Course 1" course page logged in as student1
And I add an entry to "Test database name" database with: And I add an entry to "Test database name" database with:
| Test field name | Student original entry | | Test field name | Student original entry |
| Test field 2 name | Student original entry 2 | | Test field 2 name | Student original entry 2 |
And I press "Save and view" And I press "Save"
Then I should see "Student original entry" Then I should see "Student original entry"
And I follow "Edit" And I follow "Edit"
And I set the following fields to these values: And I set the following fields to these values:
| Test field name | Student original entry | | Test field name | Student original entry |
| Test field 2 name | | | Test field 2 name | |
And I press "Save and view" And I press "Save"
Then I should not see "Student original entry 2" Then I should not see "Student original entry 2"
And I follow "Edit" And I follow "Edit"
And I set the following fields to these values: And I set the following fields to these values:
| Test field name | Student edited entry | | Test field name | Student edited entry |
And I press "Save and view" And I press "Save"
And I should see "Student edited entry" And I should see "Student edited entry"
And I add an entry to "Test database name" database with: And I add an entry to "Test database name" database with:
| Test field name | Student second entry | | Test field name | Student second entry |
@ -56,8 +56,8 @@ Feature: Users can add entries to database activities
And the field "Test field name" does not match value "Student second entry" And the field "Test field name" does not match value "Student second entry"
And I add an entry to "Test database name" database with: And I add an entry to "Test database name" database with:
| Test field name | Student third entry | | Test field name | Student third entry |
And I press "Save and view" And I press "Save"
And I follow "View list" And I select "List view" from the "jump" singleselect
And I should see "Student edited entry" And I should see "Student edited entry"
And I should see "Student second entry" And I should see "Student second entry"
And I should see "Student third entry" And I should see "Student third entry"
@ -80,6 +80,7 @@ Feature: Users can add entries to database activities
Given I am on the "Course 1" course page logged in as teacher1 Given I am on the "Course 1" course page logged in as teacher1
And I add a "Text area" field to "Test database name" database and I fill the form with: And I add a "Text area" field to "Test database name" database and I fill the form with:
| Field name | Textarea field name | | Field name | Textarea field name |
And I am on "Course 1" course homepage
When I add an entry to "Test database name" database with: When I add an entry to "Test database name" database with:
| Textarea field name | This is the content | | Textarea field name | This is the content |
And I click on "Insert H5P" "button" And I click on "Insert H5P" "button"

View file

@ -50,14 +50,9 @@ class behat_mod_data extends behat_base {
public function i_add_a_field_to_database_and_i_fill_the_form_with($fieldtype, $activityname, TableNode $fielddata) { public function i_add_a_field_to_database_and_i_fill_the_form_with($fieldtype, $activityname, TableNode $fielddata) {
$this->execute('behat_navigation::i_am_on_page_instance', [$this->escape($activityname), 'data activity']); $this->execute('behat_navigation::i_am_on_page_instance', [$this->escape($activityname), 'data activity']);
// Open "Fields" tab if it is not already open.
$fieldsstr = get_string('fields', 'mod_data'); $fieldsstr = get_string('fields', 'mod_data');
$xpath = '//ul[contains(@class,\'nav-tabs\')]//*[contains(@class,\'active\') and contains(normalize-space(.), \'' .
$fieldsstr . '\')]';
if (!$this->getSession()->getPage()->findAll('xpath', $xpath)) {
$this->execute("behat_general::i_click_on_in_the", array($fieldsstr, 'link', '.nav-tabs', 'css_element'));
}
$this->execute("behat_navigation::i_navigate_to_in_current_page_administration", $fieldsstr);
$this->execute('behat_forms::i_set_the_field_to', array('newtype', $this->escape($fieldtype))); $this->execute('behat_forms::i_set_the_field_to', array('newtype', $this->escape($fieldtype)));
if (!$this->running_javascript()) { if (!$this->running_javascript()) {

View file

@ -36,8 +36,7 @@ Feature: View activity completion in the database activity
And I press "Save and display" And I press "Save and display"
And I add a "Text input" field to "Music history" database and I fill the form with: And I add a "Text input" field to "Music history" database and I fill the form with:
| Field name | Instrument types | | Field name | Instrument types |
And I follow "Templates" And I navigate to "Templates" in current page administration
And I press "Save template"
And I log out And I log out
Scenario: View automatic completion items as a teacher and confirm all tabs display conditions Scenario: View automatic completion items as a teacher and confirm all tabs display conditions
@ -45,31 +44,30 @@ Feature: View activity completion in the database activity
Then "Music history" should have the "View" completion condition Then "Music history" should have the "View" completion condition
And "Music history" should have the "Make entries: 2" completion condition And "Music history" should have the "Make entries: 2" completion condition
And "Music history" should have the "Receive a grade" completion condition And "Music history" should have the "Receive a grade" completion condition
And I follow "View single" And I select "Single view" from the "jump" singleselect
And "Music history" should have the "View" completion condition And "Music history" should have the "View" completion condition
And "Music history" should have the "Make entries: 2" completion condition And "Music history" should have the "Make entries: 2" completion condition
And "Music history" should have the "Receive a grade" completion condition And "Music history" should have the "Receive a grade" completion condition
And I follow "Search" And I press "Add entry"
And "Music history" should have the "View" completion condition And "Music history" should have the "View" completion condition
And "Music history" should have the "Make entries: 2" completion condition And "Music history" should have the "Make entries: 2" completion condition
And "Music history" should have the "Receive a grade" completion condition And "Music history" should have the "Receive a grade" completion condition
And I follow "Add entry" And I set the following fields to these values:
| Instrument types | Hurdygurdy |
And I press "Save"
And I press "Export entries"
And "Music history" should have the "View" completion condition And "Music history" should have the "View" completion condition
And "Music history" should have the "Make entries: 2" completion condition And "Music history" should have the "Make entries: 2" completion condition
And "Music history" should have the "Receive a grade" completion condition And "Music history" should have the "Receive a grade" completion condition
And I follow "Export" And I navigate to "Templates" in current page administration
And "Music history" should have the "View" completion condition And "Music history" should have the "View" completion condition
And "Music history" should have the "Make entries: 2" completion condition And "Music history" should have the "Make entries: 2" completion condition
And "Music history" should have the "Receive a grade" completion condition And "Music history" should have the "Receive a grade" completion condition
And I follow "Templates" And I navigate to "Fields" in current page administration
And "Music history" should have the "View" completion condition And "Music history" should have the "View" completion condition
And "Music history" should have the "Make entries: 2" completion condition And "Music history" should have the "Make entries: 2" completion condition
And "Music history" should have the "Receive a grade" completion condition And "Music history" should have the "Receive a grade" completion condition
And I follow "Fields" And I navigate to "Presets" in current page administration
And "Music history" should have the "View" completion condition
And "Music history" should have the "Make entries: 2" completion condition
And "Music history" should have the "Receive a grade" completion condition
And I follow "Presets"
And "Music history" should have the "View" completion condition And "Music history" should have the "View" completion condition
And "Music history" should have the "Make entries: 2" completion condition And "Music history" should have the "Make entries: 2" completion condition
And "Music history" should have the "Receive a grade" completion condition And "Music history" should have the "Receive a grade" completion condition
@ -82,7 +80,7 @@ Feature: View activity completion in the database activity
And I am on "Course 1" course homepage And I am on "Course 1" course homepage
And I add an entry to "Music history" database with: And I add an entry to "Music history" database with:
| Instrument types | Drums | | Instrument types | Drums |
And I press "Save and view" And I press "Save"
# One entry is not enough to mark as complete. # One entry is not enough to mark as complete.
And the "View" completion condition of "Music history" is displayed as "done" And the "View" completion condition of "Music history" is displayed as "done"
And the "Make entries: 2" completion condition of "Music history" is displayed as "todo" And the "Make entries: 2" completion condition of "Music history" is displayed as "todo"
@ -90,14 +88,14 @@ Feature: View activity completion in the database activity
And I am on "Course 1" course homepage And I am on "Course 1" course homepage
And I add an entry to "Music history" database with: And I add an entry to "Music history" database with:
| Instrument types | Hurdygurdy | | Instrument types | Hurdygurdy |
And I press "Save and view" And I press "Save"
Then the "View" completion condition of "Music history" is displayed as "done" Then the "View" completion condition of "Music history" is displayed as "done"
And the "Make entries: 2" completion condition of "Music history" is displayed as "done" And the "Make entries: 2" completion condition of "Music history" is displayed as "done"
And the "Receive a grade" completion condition of "Music history" is displayed as "todo" And the "Receive a grade" completion condition of "Music history" is displayed as "todo"
And I log out And I log out
And I am on the "Music history" "data activity" page logged in as teacher1 And I am on the "Music history" "data activity" page logged in as teacher1
And I follow "View single" And I select "Single view" from the "jump" singleselect
And I set the field "rating" to "3" And I set the field "rating" to "3"
And I press "Rate" And I press "Rate"
And I log out And I log out

View file

@ -31,13 +31,13 @@ Feature: Users can edit approved entries in database activities
| Field name | Test field name | | Field name | Test field name |
| Field description | Test field description | | Field description | Test field description |
# To generate the default templates. # To generate the default templates.
And I follow "Templates" And I navigate to "Templates" in current page administration
And I log out And I log out
# Add an entry as a student. # Add an entry as a student.
And I am on the "Test database name" "data activity" page logged in as student1 And I am on the "Test database name" "data activity" page logged in as student1
And I add an entry to "Test database name" database with: And I add an entry to "Test database name" database with:
| Test field name | Student entry | | Test field name | Student entry |
And I press "Save and view" And I press "Save"
And I log out And I log out
# Approve the student's entry as a teacher. # Approve the student's entry as a teacher.
And I am on the "Test database name" "data activity" page logged in as teacher1 And I am on the "Test database name" "data activity" page logged in as teacher1
@ -63,13 +63,13 @@ Feature: Users can edit approved entries in database activities
| Field name | Test field name | | Field name | Test field name |
| Field description | Test field description | | Field description | Test field description |
# To generate the default templates. # To generate the default templates.
And I follow "Templates" And I navigate to "Templates" in current page administration
And I log out And I log out
# Add an entry as a student. # Add an entry as a student.
And I am on the "Test database name" "data activity" page logged in as student1 And I am on the "Test database name" "data activity" page logged in as student1
And I add an entry to "Test database name" database with: And I add an entry to "Test database name" database with:
| Test field name | Student entry | | Test field name | Student entry |
And I press "Save and view" And I press "Save"
And I log out And I log out
# Approve the student's entry as a teacher. # Approve the student's entry as a teacher.
And I am on the "Test database name" "data activity" page logged in as teacher1 And I am on the "Test database name" "data activity" page logged in as teacher1

View file

@ -120,7 +120,7 @@ Feature: Users can be required to specify certain fields when adding entries to
| Field name | Not required Multimenu | | Field name | Not required Multimenu |
| Field description | Not required Multimenu | | Field description | Not required Multimenu |
| Options | Option 1 | | Options | Option 1 |
And I follow "Templates" And I navigate to "Templates" in current page administration
And I log out And I log out
Scenario: Students receive errors for empty required fields but not for optional fields Scenario: Students receive errors for empty required fields but not for optional fields
@ -128,7 +128,7 @@ Feature: Users can be required to specify certain fields when adding entries to
And I am on "Course 1" course homepage And I am on "Course 1" course homepage
And I add an entry to "Test database name" database with: And I add an entry to "Test database name" database with:
| Base Text input | Some input to allow us to submit the otherwise empty form | | Base Text input | Some input to allow us to submit the otherwise empty form |
And I press "Save and view" And I press "Save"
Then ".alert" "css_element" should exist in the "Required Checkbox" "table_row" Then ".alert" "css_element" should exist in the "Required Checkbox" "table_row"
And ".alert" "css_element" should exist in the "Required Two-Option Checkbox" "table_row" And ".alert" "css_element" should exist in the "Required Two-Option Checkbox" "table_row"
And ".alert" "css_element" should exist in the "Required Latlong" "table_row" And ".alert" "css_element" should exist in the "Required Latlong" "table_row"
@ -149,7 +149,8 @@ Feature: Users can be required to specify certain fields when adding entries to
And ".alert" "css_element" should not exist in the "Not required Text area" "table_row" And ".alert" "css_element" should not exist in the "Not required Text area" "table_row"
And ".alert" "css_element" should not exist in the "Not required URL" "table_row" And ".alert" "css_element" should not exist in the "Not required URL" "table_row"
And ".alert" "css_element" should not exist in the "Not required Multimenu" "table_row" And ".alert" "css_element" should not exist in the "Not required Multimenu" "table_row"
And I follow "View list" And I am on "Course 1" course homepage
And I follow "Test database name"
And I should see "No entries in database" And I should see "No entries in database"
Scenario: Students recieve no error for filled in required fields Scenario: Students recieve no error for filled in required fields
@ -169,8 +170,8 @@ Feature: Users can be required to specify certain fields when adding entries to
| Required URL | http://example.com/ | | Required URL | http://example.com/ |
| Required Multimenu | 1 | | Required Multimenu | 1 |
| Required Two-Option Multimenu | 1 | | Required Two-Option Multimenu | 1 |
And I press "Save and view" And I press "Save"
And I follow "View list" And I select "List view" from the "jump" singleselect
Then I should not see "No entries in database" Then I should not see "No entries in database"
And I should see "New entry text" And I should see "New entry text"
@ -189,7 +190,7 @@ Feature: Users can be required to specify certain fields when adding entries to
| Required URL | http://example.com/ | | Required URL | http://example.com/ |
| Required Multimenu | 1 | | Required Multimenu | 1 |
| Required Two-Option Multimenu | 1 | | Required Two-Option Multimenu | 1 |
And I press "Save and view" And I press "Save"
Then the following fields match these values: Then the following fields match these values:
| Base Text input | | | Base Text input | |
| Latitude | 0 | | Latitude | 0 |
@ -220,7 +221,7 @@ Feature: Users can be required to specify certain fields when adding entries to
| Required Multimenu | 1 | | Required Multimenu | 1 |
| Required Two-Option Multimenu | 1 | | Required Two-Option Multimenu | 1 |
And I set the field with xpath "//div[@title='Not required Latlong']//tr[td/label[normalize-space(.)='Latitude']]/td/input" to "20" And I set the field with xpath "//div[@title='Not required Latlong']//tr[td/label[normalize-space(.)='Latitude']]/td/input" to "20"
And I press "Save and view" And I press "Save"
Then ".alert" "css_element" should exist in the "Required Latlong" "table_row" Then ".alert" "css_element" should exist in the "Required Latlong" "table_row"
And ".alert" "css_element" should exist in the "Not required Latlong" "table_row" And ".alert" "css_element" should exist in the "Not required Latlong" "table_row"
@ -241,7 +242,7 @@ Feature: Users can be required to specify certain fields when adding entries to
| Required URL | http://example.com/ | | Required URL | http://example.com/ |
| Required Multimenu | 1 | | Required Multimenu | 1 |
| Required Two-Option Multimenu | 1 | | Required Two-Option Multimenu | 1 |
And I press "Save and view" And I press "Save"
And I follow "View list" And I select "List view" from the "jump" singleselect
Then I should not see "No entries in database" Then I should not see "No entries in database"
And I should see "Some input to allow us to submit the otherwise empty form" And I should see "Some input to allow us to submit the otherwise empty form"

View file

@ -33,13 +33,12 @@ Feature: Users can view and search database entries
| Field name | Test field 2 name | | Field name | Test field 2 name |
| Field description | Test field 2 description | | Field description | Test field 2 description |
# To generate the default templates. # To generate the default templates.
And I follow "Templates" And I navigate to "Templates" in current page administration
And I log out And I log out
@javascript
Scenario: Students can add view, list and search entries Scenario: Students can add view, list and search entries
Given I log in as "student1" Given I am on the "Test database name" "data activity" page logged in as student1
And I am on "Course 1" course homepage
And I follow "Test database name"
And I add an entry to "Test database name" database with: And I add an entry to "Test database name" database with:
| Test field name | Student entry 1 | | Test field name | Student entry 1 |
And I press "Save and add another" And I press "Save and add another"
@ -48,12 +47,12 @@ Feature: Users can view and search database entries
And I press "Save and add another" And I press "Save and add another"
And I add an entry to "Test database name" database with: And I add an entry to "Test database name" database with:
| Test field name | Student entry 3 | | Test field name | Student entry 3 |
And I press "Save and view" And I press "Save"
And I follow "Test database name" And I am on the "Test database name" "data activity" page
Then I should see "Student entry 1" Then I should see "Student entry 1"
And I should see "Student entry 2" And I should see "Student entry 2"
And I should see "Student entry 3" And I should see "Student entry 3"
And I follow "View single" And I select "Single view" from the "jump" singleselect
And I should see "Student entry 1" And I should see "Student entry 1"
And I should not see "Student entry 2" And I should not see "Student entry 2"
And "2" "link" should exist And "2" "link" should exist
@ -68,13 +67,13 @@ Feature: Users can view and search database entries
And I should see "Student entry 2" And I should see "Student entry 2"
And I should not see "Student entry 1" And I should not see "Student entry 1"
And I should not see "Student entry 3" And I should not see "Student entry 3"
And I follow "Search" And I select "List view" from the "jump" singleselect
And I click on "Advanced search" "checkbox"
And I set the field "Test field name" to "Student entry 1" And I set the field "Test field name" to "Student entry 1"
And I press "Save settings" And I press "Save settings"
And I should see "Student entry 1" And I should see "Student entry 1"
And I should not see "Student entry 2" And I should not see "Student entry 2"
And I should not see "Student entry 3" And I should not see "Student entry 3"
And I follow "Search"
And I set the field "Test field name" to "Student entry" And I set the field "Test field name" to "Student entry"
And I set the field "Order" to "Descending" And I set the field "Order" to "Descending"
And I press "Save settings" And I press "Save settings"
@ -94,14 +93,15 @@ Feature: Users can view and search database entries
| Test field name | Student original entry tagged | | Test field name | Student original entry tagged |
| Test field 2 name | Student original entry tagged 2 | | Test field 2 name | Student original entry tagged 2 |
And I set the field with xpath "//div[@class='datatagcontrol']//input[@type='text']" to "Tag1" And I set the field with xpath "//div[@class='datatagcontrol']//input[@type='text']" to "Tag1"
And I press "Save and view" And I press "Save"
And I should see "Student original entry" And I should see "Student original entry"
And I should see "Tag1" in the "div.tag_list" "css_element" And I should see "Tag1" in the "div.tag_list" "css_element"
And I follow "Edit" And I follow "Edit"
And I should see "Tag1" in the ".form-autocomplete-selection" "css_element" And I should see "Tag1" in the ".form-autocomplete-selection" "css_element"
And I follow "View list" And I follow "Cancel"
And I select "List view" from the "jump" singleselect
And I should see "Tag1" in the "div.tag_list" "css_element" And I should see "Tag1" in the "div.tag_list" "css_element"
And I follow "Search" And I click on "Advanced search" "checkbox"
And I set the field with xpath "//div[@class='datatagcontrol']//input[@type='text']" to "Tag1" And I set the field with xpath "//div[@class='datatagcontrol']//input[@type='text']" to "Tag1"
And I click on "[data-value='Tag1']" "css_element" And I click on "[data-value='Tag1']" "css_element"
When I press "Save settings" When I press "Save settings"
@ -110,23 +110,22 @@ Feature: Users can view and search database entries
And I should not see "Student original entry untagged" And I should not see "Student original entry untagged"
And I should not see "Student original entry untagged 2" And I should not see "Student original entry untagged 2"
@javascript
Scenario: Check that searching by first and last name works as expected Scenario: Check that searching by first and last name works as expected
Given I log in as "student1" Given I log in as "student1"
And I am on "Course 1" course homepage And I am on "Course 1" course homepage
And I add an entry to "Test database name" database with: And I add an entry to "Test database name" database with:
| Test field name | Student entry 1 | | Test field name | Student entry 1 |
And I press "Save and view" And I press "Save"
And I log out And I log out
And I log in as "student2" And I log in as "student2"
And I am on "Course 1" course homepage And I am on "Course 1" course homepage
And I add an entry to "Test database name" database with: And I add an entry to "Test database name" database with:
| Test field name | Student entry 2 | | Test field name | Student entry 2 |
And I press "Save and view" And I press "Save"
And I log out And I log out
When I log in as "teacher1" When I am on the "Test database name" "data activity" page logged in as teacher1
And I am on "Course 1" course homepage And I click on "Advanced search" "checkbox"
And I follow "Test database name"
And I follow "Search"
And I set the field "Author first name" to "Bob" And I set the field "Author first name" to "Bob"
And I press "Save settings" And I press "Save settings"
Then I should see "Student entry 1" Then I should see "Student entry 1"