MDL-79496 webservice: Fix webservice behat tests

- Move all webservice related behat tests to the correct namespace.
- Add missing @core_webservice tags
- Fix behat scenarios after systemreport conversion.
This commit is contained in:
Mikel Martín 2023-10-25 14:08:59 +02:00
parent 2c830cb233
commit 2d37fadca4
4 changed files with 63 additions and 32 deletions

View File

@ -1,4 +1,4 @@
@core @core_admin
@core @core_admin @core_webservice
Feature: Manage external services tokens
In order to manage external service usage
As an admin
@ -11,7 +11,6 @@ Feature: Manage external services tokens
| user2 | user2 | Firstname2 | Lastname2 |
| user3 | user3 | Firstname3 | Lastname3 |
| user4 | user4 | Firstname4 | Lastname4 |
And I change window size to "small"
@javascript
Scenario: Add a token to user identified by name and then delete that token
@ -25,7 +24,7 @@ Feature: Manage external services tokens
And I set the field "IP restriction" to "127.0.0.1"
When I press "Save changes"
Then the following should exist in the "generaltable" table:
| Name | First name | Service | IP restriction | Last access |
| Name | User | Service | IP restriction | Last access |
| Webservice1 | Firstname1 Lastname1 | Moodle mobile web service | 127.0.0.1 | Never |
# Verify the message and the "Copy to clipboard" button.
@ -38,7 +37,7 @@ Feature: Manage external services tokens
And "Copy to clipboard" "button" should not exist
# Delete token.
And I click on "Delete" "link" in the "Webservice1" "table_row"
And I press "Delete" action in the "Webservice1" report row
And I should see "Do you really want to delete this web service token for Firstname1 Lastname1 on the service Moodle mobile web service?"
And I press "Delete"
And "Webservice1" "table_row" should not exist
@ -53,10 +52,10 @@ Feature: Manage external services tokens
| service | siteinfo |
| functions | core_webservice_get_site_info |
And the following "core_webservice > Tokens" exist:
| user | service | name |
| user2 | siteinfo | WEBservice1 |
| user3 | moodle_mobile_app | webservicE3 |
| user4 | siteinfo | New service2 |
| user | service | name | validuntil |
| user2 | siteinfo | WEBservice1 | ## yesterday ## |
| user3 | moodle_mobile_app | webservicE3 | ## +1 year ## |
| user4 | siteinfo | New service2 | ## +1 year ## |
When I log in as "admin"
And I navigate to "Server > Web services > Manage tokens" in site administration
@ -66,38 +65,70 @@ Feature: Manage external services tokens
And I should see "Moodle mobile web service" in the "Firstname3 Lastname3" "table_row"
And I should see "Site information" in the "Firstname4 Lastname4" "table_row"
# Filter tokens by by name (case-insensitive).
And I click on "Tokens filter" "link"
And I set the field "Name" to "webservice"
And I press "Show only matching tokens"
# Filter tokens by by name.
And I click on "Filters" "button"
And I set the following fields in the "Name" "core_reportbuilder > Filter" to these values:
| Name operator | Contains |
| Name value | webservice |
And I click on "Apply" "button" in the "[data-region='report-filters']" "css_element"
And I should see "Site information" in the "Firstname2 Lastname2" "table_row"
And I should see "Moodle mobile web service" in the "Firstname3 Lastname3" "table_row"
And "Firstname4 Lastname4" "table_row" should not exist
And I click on "Reset all" "button" in the "[data-region='report-filters']" "css_element"
# Reset the filter.
And I press "Show all tokens"
# Filter tokens by user.
And I set the following fields in the "User" "core_reportbuilder > Filter" to these values:
| User operator | Contains |
| User value | Firstname2 |
And I click on "Apply" "button" in the "[data-region='report-filters']" "css_element"
Then "Firstname3 Lastname3" "table_row" should not exist
And "Firstname4 Lastname4" "table_row" should not exist
And I should see "Site information" in the "Firstname2 Lastname2" "table_row"
And I should see "Moodle mobile web service" in the "Firstname3 Lastname3" "table_row"
And I should see "Site information" in the "Firstname4 Lastname4" "table_row"
And I click on "Reset all" "button" in the "[data-region='report-filters']" "css_element"
# Filter tokens by user (note we can select the user by the identity field here).
When I click on "Tokens filter" "link"
And I set the field "User" to "user2@example.com"
And I press "Show only matching tokens"
# Filter tokens by service.
And I set the following fields in the "Service" "core_reportbuilder > Filter" to these values:
| Service value | Site information |
And I click on "Apply" "button" in the "[data-region='report-filters']" "css_element"
And I should see "Site information" in the "Firstname2 Lastname2" "table_row"
And I should see "Site information" in the "Firstname4 Lastname4" "table_row"
And "Firstname3 Lastname3" "table_row" should not exist
And I click on "Reset all" "button" in the "[data-region='report-filters']" "css_element"
# Filter tokens by valid date.
And I set the following fields in the "Valid until" "core_reportbuilder > Filter" to these values:
| Valid until operator | Last |
| Valid until value | 2 |
| Valid until unit | day(s) |
And I click on "Apply" "button" in the "[data-region='report-filters']" "css_element"
Then "Firstname3 Lastname3" "table_row" should not exist
And "Firstname4 Lastname4" "table_row" should not exist
And I should see "Site information" in the "Firstname2 Lastname2" "table_row"
# Reset the filter.
And I press "Show all tokens"
# Reset the filters.
And I click on "Reset all" "button" in the "[data-region='report-filters']" "css_element"
And I should see "Site information" in the "Firstname2 Lastname2" "table_row"
And I should see "Moodle mobile web service" in the "Firstname3 Lastname3" "table_row"
And I should see "Site information" in the "Firstname4 Lastname4" "table_row"
# Filter tokens by service.
And I click on "Tokens filter" "link"
And I set the field "Service" to "Site information"
And I press "Show only matching tokens"
And I should see "Site information" in the "Firstname2 Lastname2" "table_row"
And I should see "Site information" in the "Firstname4 Lastname4" "table_row"
And "Firstname3 Lastname3" "table_row" should not exist
@javascript
Scenario: Tokens table should display missing capabilities
Given the following "core_webservice > Services" exist:
| name | shortname | enabled |
| Test Service 1 | testservice1 | 1 |
| Test Service 2 | testservice2 | 1 |
And the following "core_webservice > Service functions" exist:
| service | functions |
| testservice1 | block_accessreview_get_module_data |
| testservice2 | core_block_fetch_addable_blocks |
And the following "core_webservice > Tokens" exist:
| user | service | name |
| user1 | testservice1 | Token 01 |
| user2 | testservice2 | Token 02 |
When I log in as "admin"
And I navigate to "Server > Web services > Manage tokens" in site administration
# Check the missing capabilities.
Then I should see "View the accessibility review" in the "Token 01" "table_row"
And I should see "block/accessreview:view" in the "Token 01" "table_row"
Then I should see "Manage blocks on a page" in the "Token 02" "table_row"
And I should see "moodle/site:manageblocks" in the "Token 02" "table_row"

View File

@ -1,4 +1,4 @@
@core @core_admin @javascript
@core @core_admin @core_webservice @javascript
Feature: Verify the breadcrumbs in external webservice site administration pages
Whenever I navigate to external webservice page in site administration
As an admin

View File

@ -1,4 +1,4 @@
@core @core_admin @javascript
@core @core_admin @core_webservice @javascript
Feature: Verify the breadcrumbs in webservice tokens site administration pages
Whenever I navigate to manage tokens page in site administration
As an admin
@ -19,7 +19,7 @@ Feature: Verify the breadcrumbs in webservice tokens site administration pages
And "Web services" "link" should exist in the ".breadcrumb" "css_element"
And I set the field "User" to "John Doe"
And I press "Save changes"
When I click on "Delete" "link"
When I press "Delete" action in the "John Doe" report row
Then "Delete token" "text" should exist in the ".breadcrumb" "css_element"
And "Manage tokens" "link" should exist in the ".breadcrumb" "css_element"
And "Web services" "link" should exist in the ".breadcrumb" "css_element"