From e08458cc23f06389f2399a5c38f463827ed62359 Mon Sep 17 00:00:00 2001 From: Amaia Anabitarte Date: Wed, 13 Jul 2022 12:45:37 +0200 Subject: [PATCH] MDL-75137 mod_data: Fix and improve behat tests --- mod/data/tests/behat/add_entries.feature | 20 +++++++++++- .../behat/data_activity_completion.feature | 4 +++ ...ata_activity_completion_pass_grade.feature | 8 +++-- mod/data/tests/behat/required_entries.feature | 2 +- mod/data/tests/behat/zero_state.feature | 31 +++++++++++++++++++ 5 files changed, 60 insertions(+), 5 deletions(-) create mode 100644 mod/data/tests/behat/zero_state.feature diff --git a/mod/data/tests/behat/add_entries.feature b/mod/data/tests/behat/add_entries.feature index f339caaa582..230d3340978 100644 --- a/mod/data/tests/behat/add_entries.feature +++ b/mod/data/tests/behat/add_entries.feature @@ -73,7 +73,7 @@ Feature: Users can add entries to database activities And I press "Select all" And I press "Delete selected" And I press "Delete" - And I should see "No entries in database" + And I should see "No entries yet" @javascript @editor @editor_atto @atto @atto_h5p Scenario: If a new text area entry is added, the filepicker is displayed in the H5P Atto button @@ -128,3 +128,21 @@ Feature: Users can add entries to database activities And I log out When I am on the "Test database name" "data activity" page logged in as "guest" Then I should not see "Add entry" + + @javascript + 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 + 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 "Text input" 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 + Then I should see "Add entry" + + Examples: + | user | + | teacher1 | + | student1 | diff --git a/mod/data/tests/behat/data_activity_completion.feature b/mod/data/tests/behat/data_activity_completion.feature index 23793030429..fe4df594000 100644 --- a/mod/data/tests/behat/data_activity_completion.feature +++ b/mod/data/tests/behat/data_activity_completion.feature @@ -42,6 +42,10 @@ Feature: View activity completion in the database activity Scenario: View automatic completion items as a teacher Given I am on the "Music history" "data activity" page logged in as teacher1 +# We add an entry to let the user change to a different view. + When I add an entry to "Music history" database with: + | Instrument types | Drums | + And I press "Save" 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 "Receive a grade" completion condition diff --git a/mod/data/tests/behat/data_activity_completion_pass_grade.feature b/mod/data/tests/behat/data_activity_completion_pass_grade.feature index 8db9772c23a..a1e2355bc08 100644 --- a/mod/data/tests/behat/data_activity_completion_pass_grade.feature +++ b/mod/data/tests/behat/data_activity_completion_pass_grade.feature @@ -55,9 +55,11 @@ Feature: Completion pass grade And I log out Scenario: View automatic completion items as a teacher - Given I log in as "teacher1" - And I am on "Course 1" course homepage - When I follow "Music history" + Given I am on the "Music history" "data activity" page logged in as teacher1 +# We add an entry to let the user change to a different view. + When I add an entry to "Music history" database with: + | Instrument types | Drums | + And I press "Save" 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 "Receive a grade" completion condition diff --git a/mod/data/tests/behat/required_entries.feature b/mod/data/tests/behat/required_entries.feature index 4e2fb47c1ff..4e39a6c952a 100644 --- a/mod/data/tests/behat/required_entries.feature +++ b/mod/data/tests/behat/required_entries.feature @@ -151,7 +151,7 @@ Feature: Users can be required to specify certain fields when adding entries to And ".alert" "css_element" should not exist in the "Not required Multimenu" "table_row" 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 yet" Scenario: Students recieve no error for filled in required fields When I log in as "student1" diff --git a/mod/data/tests/behat/zero_state.feature b/mod/data/tests/behat/zero_state.feature new file mode 100644 index 00000000000..10380dd2029 --- /dev/null +++ b/mod/data/tests/behat/zero_state.feature @@ -0,0 +1,31 @@ +@mod @mod_data +Feature: Zero state page (no fields created) + + 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 | n | C1 | data1 | + + @javascript + Scenario: Teachers see buttons to manage database when there is no field created + Given I am on the "Test database name" "data activity" page logged in as "teacher1" + And "Import a preset" "button" should exist + When I click on "Import a preset" "button" + Then I should see "Import from zip file" + And I am on the "Test database name" "data activity" page + And "Create a new field" "button" should exist + And I click on "Create a new field" "button" + And I should see "Manage fields" + And I am on the "Test database name" "data activity" page + And "Use preset" "button" should exist + And I click on "Use preset" "button" + And I should see "Presets"