From 178be88e974967b1f42f6492370094adde2fbc4a Mon Sep 17 00:00:00 2001 From: "ferran.recio" Date: Thu, 29 Aug 2019 16:23:41 +0200 Subject: [PATCH] MDL-66332 tool_capability: adding acceptance tests --- .../tests/behat/show_capabilies.feature | 104 ++++++++++++++++++ .../tests/behat/show_differences.feature | 67 +++++++++++ .../moodle-tool_capability-search-debug.js | Bin 4477 -> 4499 bytes .../moodle-tool_capability-search-min.js | Bin 1856 -> 1878 bytes .../moodle-tool_capability-search.js | Bin 4477 -> 4499 bytes .../capability/yui/src/search/js/search.js | 2 +- 6 files changed, 172 insertions(+), 1 deletion(-) create mode 100644 admin/tool/capability/tests/behat/show_capabilies.feature create mode 100644 admin/tool/capability/tests/behat/show_differences.feature diff --git a/admin/tool/capability/tests/behat/show_capabilies.feature b/admin/tool/capability/tests/behat/show_capabilies.feature new file mode 100644 index 00000000000..d0ec7c653fd --- /dev/null +++ b/admin/tool/capability/tests/behat/show_capabilies.feature @@ -0,0 +1,104 @@ +@tool @tool_capability +Feature: show capabilities for selected roles + In order to check roles capabilities + As an admin + I need to be able to customize capabilities report viewing only specific roles and capabilities + + Background: + Given the following "roles" exist: + | shortname | name | archetype | + | studenteq | Studenteq | student | + | studentdf | Studentdf | student | + And the following "permission overrides" exist: + | capability | permission | role | contextlevel | reference | + | moodle/course:changefullname | Allow | studentdf | System | | + | moodle/course:changeshortname | Prohibit | studentdf | System | | + | moodle/course:changeidnumber | Prevent | studentdf | System | | + And I log in as "admin" + And I navigate to "Users > Permissions > Capability overview" in site administration + + Scenario: visualize capabilities table with a limited number of capabilities + When I set the following fields to these values: + | Capability: | moodle/course:changefullname, moodle/course:changeshortname | + | Roles: | Studentdf | + And I click on "Get the overview" "button" + Then I should see "moodle/course:changefullname" in the "comparisontable" "table" + And I should see "moodle/course:changeshortname" in the "comparisontable" "table" + And I should not see "moodle/course:changecategory" in the "comparisontable" "table" + + Scenario: visualize an allow capability + When I set the following fields to these values: + | Capability: | moodle/course:changefullname | + | Roles: | Studentdf | + And I click on "Get the overview" "button" + Then I should see "Allow" in the "comparisontable" "table" + And I should not see "Prevent" in the "comparisontable" "table" + And I should not see "Prohibit" in the "comparisontable" "table" + And I should not see "Not set" in the "comparisontable" "table" + + Scenario: visualize a prohibit capability + When I set the following fields to these values: + | Capability: | moodle/course:changeshortname | + | Roles: | Studentdf | + And I click on "Get the overview" "button" + Then I should not see "Allow" in the "comparisontable" "table" + And I should not see "Prevent" in the "comparisontable" "table" + And I should see "Prohibit" in the "comparisontable" "table" + And I should not see "Not set" in the "comparisontable" "table" + + Scenario: visualize a not set capability + When I set the following fields to these values: + | Capability: | moodle/course:changecategory | + | Roles: | Studentdf | + And I click on "Get the overview" "button" + Then I should not see "Allow" in the "comparisontable" "table" + And I should not see "Prevent" in the "comparisontable" "table" + And I should not see "Prohibit" in the "comparisontable" "table" + And I should see "Not set" in the "comparisontable" "table" + + Scenario: visualize more than one role + When I set the following fields to these values: + | Capability: | moodle/course:changecategory | + | Roles: | Student, Studentdf | + And I click on "Get the overview" "button" + Then I should see "Student" in the "comparisontable" "table" + And I should see "Studentdf" in the "comparisontable" "table" + And I should not see "Teacher" in the "comparisontable" "table" + + Scenario: visualize all roles without selecting any role + When I set the following fields to these values: + | Capability: | moodle/course:changecategory | + And I click on "Get the overview" "button" + Then I should see "Student" in the "comparisontable" "table" + And I should see "Studentdf" in the "comparisontable" "table" + And I should see "Teacher" in the "comparisontable" "table" + + Scenario: visualize all roles by selecting All option + When I set the following fields to these values: + | Capability: | moodle/course:changecategory | + | Roles: | All | + And I click on "Get the overview" "button" + Then I should see "Student" in the "comparisontable" "table" + And I should see "Studentdf" in the "comparisontable" "table" + And I should see "Teacher" in the "comparisontable" "table" + + @javascript + Scenario: filter capability list using javascript + Given I should see "moodle/site:config" in the "Capability" "field" + And I should see "moodle/course:change" in the "Capability" "field" + When I wait until the page is ready + And I set the field "capabilitysearch" to "moodle/course:change" + Then I should see "moodle/course:change" in the "Capability" "field" + And I should not see "moodle/site:config" in the "Capability" "field" + + @javascript + Scenario: selecting capabilities using filters + Given I should see "moodle/course:change" in the "Capability" "field" + When I wait until the page is ready + And I set the field "capabilitysearch" to "moodle/course:change" + When I set the following fields to these values: + | Capability: | moodle/course:changecategory | + | Roles: | Student | + And I set the field "capabilitysearch" to "" + And I click on "Get the overview" "button" + Then I should see "moodle/course:changecategory" in the "comparisontable" "table" diff --git a/admin/tool/capability/tests/behat/show_differences.feature b/admin/tool/capability/tests/behat/show_differences.feature new file mode 100644 index 00000000000..1c907a42186 --- /dev/null +++ b/admin/tool/capability/tests/behat/show_differences.feature @@ -0,0 +1,67 @@ +@tool @tool_capability +Feature: show only differences between roles for selected capabilities + In order to check roles capabilities + As an admin + I need to be able to filter capabilities report viewing only role differences + + Background: + Given the following "roles" exist: + | shortname | name | archetype | + | studenteq | Studenteq | student | + | studentdf | Studentdf | student | + And the following "permission overrides" exist: + | capability | permission | role | contextlevel | reference | + | moodle/course:changefullname | Allow | studentdf | System | | + | moodle/course:changeshortname | Prohibit | studentdf | System | | + And I log in as "admin" + And I navigate to "Users > Permissions > Capability overview" in site administration + + Scenario: Compare identical roles + When I set the following fields to these values: + | Capability: | moodle/course:changefullname, moodle/course:changeshortname, moodle/course:changeidnumber, moodle/course:changesummary | + | Roles: | Student, Studenteq | + And I set the field "Show differences only" to "1" + And I click on "Get the overview" "button" + Then I should see "There are no differences to show between selected roles in this context" + + Scenario: Compare different roles + When I set the following fields to these values: + | Capability: | moodle/course:changefullname, moodle/course:changeshortname, moodle/course:changeidnumber, moodle/course:changesummary | + | Roles: | Student, Studentdf | + And I set the field "Show differences only" to "1" + And I click on "Get the overview" "button" + Then I should not see "There are no differences to show between selected roles in this context" + And I should see "moodle/course:changefullname" in the "comparisontable" "table" + And I should see "moodle/course:changeshortname" in the "comparisontable" "table" + And I should not see "moodle/course:changesummary" in the "comparisontable" "table" + + Scenario: Compare different roles but comparing capabilities that are equals on both + When I set the following fields to these values: + | Capability: | moodle/course:changeidnumber, moodle/course:changesummary | + | Roles: | Student, Studentdf | + And I set the field "Show differences only" to "1" + And I click on "Get the overview" "button" + Then I should see "There are no differences to show between selected roles in this context" + + Scenario: Compare all roles without selecting specific role + When I set the following fields to these values: + | Capability: | moodle/course:changefullname, moodle/site:config | + And I set the field "Show differences only" to "1" + And I click on "Get the overview" "button" + Then I should not see "moodle/site:config" in the "comparisontable" "table" + And I should see "moodle/course:changefullname" in the "comparisontable" "table" + + Scenario: Compare all roles without selecting specific role on not defined capability + When I set the following fields to these values: + | Capability: | moodle/site:config | + And I set the field "Show differences only" to "1" + And I click on "Get the overview" "button" + Then I should see "There are no differences to show between selected roles in this context" + + Scenario: Comparing only one role + When I set the following fields to these values: + | Capability: | moodle/course:changefullname, moodle/course:changeshortname, moodle/course:changeidnumber, moodle/course:changesummary | + | Roles: | Student | + And I set the field "Show differences only" to "1" + And I click on "Get the overview" "button" + Then I should see "There are no differences to show between selected roles in this context" diff --git a/admin/tool/capability/yui/build/moodle-tool_capability-search/moodle-tool_capability-search-debug.js b/admin/tool/capability/yui/build/moodle-tool_capability-search/moodle-tool_capability-search-debug.js index 6b8b3686dd75dc5b84decb758824289b0029a1ff..1c0553405bcfe2c9ebe00d1dd7396cdd559758fb 100644 GIT binary patch delta 34 pcmeyXG+B9r2#2UbN@7W(Zdzt)PD)8-L8`4%NoqyOW?_yjP5{+Y3&{Wg delta 12 TcmbQN{8wp%2*+kEj!aGf9@_)? diff --git a/admin/tool/capability/yui/build/moodle-tool_capability-search/moodle-tool_capability-search-min.js b/admin/tool/capability/yui/build/moodle-tool_capability-search/moodle-tool_capability-search-min.js index 7e1baef5c5dd409407acb02dec80aae404cc3624..697a2149049222618dc9d99a81481153dee4a590 100644 GIT binary patch delta 34 pcmX@Wca3jDJCmqFN@7W(Zdzt)PD)8-L8`4%NoqyO<~F8XECAmw49frj delta 12 Tcmcb{cYtq0JJaU5OgmWsBUl9c diff --git a/admin/tool/capability/yui/build/moodle-tool_capability-search/moodle-tool_capability-search.js b/admin/tool/capability/yui/build/moodle-tool_capability-search/moodle-tool_capability-search.js index 6b8b3686dd75dc5b84decb758824289b0029a1ff..1c0553405bcfe2c9ebe00d1dd7396cdd559758fb 100644 GIT binary patch delta 34 pcmeyXG+B9r2#2UbN@7W(Zdzt)PD)8-L8`4%NoqyOW?_yjP5{+Y3&{Wg delta 12 TcmbQN{8wp%2*+kEj!aGf9@_)? diff --git a/admin/tool/capability/yui/src/search/js/search.js b/admin/tool/capability/yui/src/search/js/search.js index b3b152721fb..1e4b96c9d91 100644 --- a/admin/tool/capability/yui/src/search/js/search.js +++ b/admin/tool/capability/yui/src/search/js/search.js @@ -74,7 +74,7 @@ SEARCH.prototype = { this.button = this.form.all('input[type=submit]'); this.lastsearch = this.form.one('input[name=search]'); - var div = Y.Node.create('
'), + var div = Y.Node.create('
'), label = Y.Node.create(''); this.input = Y.Node.create(''); -- 2.43.0