MDL-86488 mod_data: Fix Behat tests for checking action menu items

This commit is contained in:
Jun Pataleta
2025-09-18 17:25:21 +08:00
parent 05d0c9b002
commit 4e09d70272
2 changed files with 33 additions and 48 deletions
+16 -24
View File
@@ -33,16 +33,11 @@ Feature: Users can view and manage data presets
And I should see "Saved preset 2"
And I should see "Saved preset by teacher1"
# Plugin presets can't be removed.
And I should not see "Actions" in the "Image gallery" "table_row"
And the "Delete" item should not exist in the "Actions" action menu of the "Image gallery" "table_row"
# The admin should be able to delete saved presets.
But I open the action menu in "Saved preset 1" "table_row"
And I should see "Delete"
And I press the escape key
And I open the action menu in "Saved preset 2" "table_row"
And I should see "Delete"
And I press the escape key
And I open the action menu in "Saved preset by teacher1" "table_row"
And I should see "Delete"
But the "Delete" item should exist in the "Actions" action menu of the "Saved preset 1" "table_row"
And the "Delete" item should exist in the "Actions" action menu of the "Saved preset 2" "table_row"
And the "Delete" item should exist in the "Actions" action menu of the "Saved preset by teacher1" "table_row"
@javascript
Scenario: Teachers can see and use presets
@@ -57,12 +52,11 @@ Feature: Users can view and manage data presets
And I should see "Saved preset by teacher1"
And I should see "This preset has also a description" in the "Saved preset by teacher1" "table_row"
# Plugin presets can't be removed.
And I should not see "Actions" in the "Image gallery" "table_row"
And the "Delete" item should not exist in the "Actions" action menu of the "Image gallery" "table_row"
# Teachers should be able to delete their saved presets.
And I open the action menu in "Saved preset by teacher1" "table_row"
And I should see "Delete"
And the "Delete" item should exist in the "Actions" action menu of the "Saved preset by teacher1" "table_row"
# Teachers can't delete the presets they haven't created.
And I should not see "Actions" in the "Saved preset 1" "table_row"
And the "Delete" item should not exist in the "Actions" action menu of the "Saved preset 1" "table_row"
# The "Use this preset" button should be enabled only when a preset is selected.
And the "Use this preset" "button" should be disabled
And I click on "fullname" "radio" in the "Image gallery" "table_row"
@@ -148,9 +142,9 @@ Feature: Users can view and manage data presets
Given I am on the "Mountain landscapes" "data activity" page logged in as teacher1
When I follow "Presets"
# Plugin presets can't be edited.
Then I should not see "Actions" in the "Image gallery" "table_row"
Then the "Edit" item should not exist in the "Actions" action menu of the "Image gallery" "table_row"
# Teachers can't edit the presets they haven't created.
And I should not see "Actions" in the "Saved preset 1" "table_row"
And the "Edit" item should not exist in the "Actions" action menu of the "Saved preset 1" "table_row"
# Teachers should be able to edit their saved presets.
And I open the action menu in "Saved preset by teacher1" "table_row"
And I choose "Edit" in the open action menu
@@ -254,12 +248,12 @@ Feature: Users can view and manage data presets
And I should see "Saved preset 1"
And I should see "Saved preset by teacher1"
# Plugin presets can't be removed.
And I should not see "Actions" in the "Image gallery" "table_row"
And the "Delete" item should not exist in the "Actions" action menu of the "Image gallery" "table_row"
# The teacher should not be able to delete presets saved by others.
And I should not see "Actions" in the "Saved preset 1" "table_row"
And the "Delete" item should not exist in the "Actions" action menu of the "Saved preset 1" "table_row"
# The teacher should be able to delete their own preset.
And I open the action menu in "Saved preset by teacher" "table_row"
And I follow "Delete"
And I choose "Delete" in the open action menu
And I click on "Delete" "button" in the "Delete preset Saved preset by teacher1?" "dialogue"
And I should see "Preset deleted"
And I should not see "Saved preset by teacher1"
@@ -295,14 +289,12 @@ Feature: Users can view and manage data presets
Given I am on the "Mountain landscapes" "data activity" page logged in as teacher1
When I follow "Presets"
# Plugin presets can't be exported.
And I should not see "Actions" in the "Image gallery" "table_row"
And the "Export" item should not exist in the "Actions" action menu of the "Image gallery" "table_row"
# The teacher should be able to export any saved preset.
And I open the action menu in "Saved preset by teacher1" "table_row"
Then I should see "Export"
And the "Export" item should exist in the "Actions" action menu of the "Saved preset by teacher1" "table_row"
And following "Export" in the "Saved preset by teacher1" "table_row" should download a file that:
| Contains file in zip | preset.xml |
And I open the action menu in "Saved preset 1" "table_row"
And I should see "Export"
And the "Export" item should exist in the "Actions" action menu of the "Saved preset 1" "table_row"
And following "Export" in the "Saved preset 1" "table_row" should download a file that:
| Contains file in zip | preset.xml |
@@ -343,7 +335,7 @@ Feature: Users can view and manage data presets
Given I am on the "Mountain landscapes" "data activity" page logged in as teacher1
And I follow "Presets"
And I open the action menu in "<Preset Name>" "table_row"
When I click on "Preview" "link" in the "<Preset Name>" "table_row"
When I choose "Preview" in the open action menu
Then I should see "Preview of <Preset preview name>"
Examples:
@@ -44,39 +44,35 @@ Feature: Users can navigate through the database activity using the tertiary nav
Scenario: The tertiary navigation in the Database page.
Given I navigate to "Database" in current page administration
# Teacher: List view.
And I should not see "List view" in the "data-listview-content" "region"
When I click on "Actions" "button"
Then I should see "Import entries" in the ".entriesactions" "css_element"
And I should see "Export entries" in the ".entriesactions" "css_element"
And I should see "Export to portfolio" in the ".entriesactions" "css_element"
And I press the escape key
Then I should not see "List view" in the "data-listview-content" "region"
And the "Import entries" item should exist in the "Actions" action menu of the ".tertiary-navigation" "css_element"
And the "Export entries" item should exist in the "Actions" action menu of the ".tertiary-navigation" "css_element"
And the "Export to portfolio" item should exist in the "Actions" action menu of the ".tertiary-navigation" "css_element"
# Teacher: Single view.
And I set the field "View mode tertiary navigation" to "Single view"
And I should not see "Single view" in the "data-singleview-content" "region"
And I click on "Actions" "button"
And I should see "Import entries" in the ".entriesactions" "css_element"
And I should see "Export entries" in the ".entriesactions" "css_element"
And I should not see "Export to portfolio" in the ".entriesactions" "css_element"
And the "Import entries" item should exist in the "Actions" action menu of the ".tertiary-navigation" "css_element"
And the "Export entries" item should exist in the "Actions" action menu of the ".tertiary-navigation" "css_element"
And the "Export to portfolio" item should not exist in the "Actions" action menu of the ".tertiary-navigation" "css_element"
# Teacher: Database without fields.
And I am on the "Database without fields" "data activity" page
And I should not see "Actions"
And "Actions" "actionmenu" should not exist
# Student without entries: List view.
And I am on the "Test database name" "data activity" page logged in as student1
And I should not see "Actions"
And "Actions" "actionmenu" should not exist in the ".tertiary-navigation" "css_element"
# Student without entries: Single view.
And I set the field "View mode tertiary navigation" to "Single view"
And I should not see "Actions"
And I should not see "Actions" in the ".tertiary-navigation" "css_element"
# Student with entries: Single view.
But the following "mod_data > entries" exist:
| database | user | field1 | field2 |
| data1 | student1 | Student entry 3 | Some content 3 |
And I should not see "Actions"
And I should not see "Actions" in the ".tertiary-navigation" "css_element"
# Student with entries: List view.
And I set the field "View mode tertiary navigation" to "List view"
And I click on "Actions" "button"
And I should not see "Import entries" in the ".entriesactions" "css_element"
And I should not see "Export entries" in the ".entriesactions" "css_element"
And I should see "Export to portfolio" in the ".entriesactions" "css_element"
And the "Import entries" item should not exist in the "Actions" action menu of the ".tertiary-navigation" "css_element"
And the "Export entries" item should not exist in the "Actions" action menu of the ".tertiary-navigation" "css_element"
And the "Export to portfolio" item should exist in the "Actions" action menu of the ".tertiary-navigation" "css_element"
@javascript
Scenario: The tertiary navigation in the Presets page.
@@ -104,14 +100,11 @@ Feature: Users can navigate through the database activity using the tertiary nav
And I should see "Preview of Saved preset by teacher1"
And "Use this preset" "button" should exist
@javascript
Scenario: The tertiary navigation in the Fields page.
Given I navigate to "Fields" in current page administration
When I open the action menu in "field1" "table_row"
Then I should see "Edit"
And I should see "Delete"
And I press the escape key
And I should not see "Actions"
Then the "Edit" item should exist in the "Actions" action menu of the "field1" "table_row"
And the "Delete" item should exist in the "Actions" action menu of the "field1" "table_row"
And I should not see "Actions" in the ".tertiary-navigation" "css_element"
@javascript
Scenario: The tertiary navigation in the Templates page.