MDL-66332 tool_capability: adding acceptance tests
authorferran.recio <ferran.recio@upcnet.es>
Thu, 29 Aug 2019 14:23:41 +0000 (16:23 +0200)
committerFerran Recio <ferran@moodle.com>
Wed, 18 Dec 2019 13:24:38 +0000 (14:24 +0100)
admin/tool/capability/tests/behat/show_capabilies.feature [new file with mode: 0644]
admin/tool/capability/tests/behat/show_differences.feature [new file with mode: 0644]
admin/tool/capability/yui/build/moodle-tool_capability-search/moodle-tool_capability-search-debug.js
admin/tool/capability/yui/build/moodle-tool_capability-search/moodle-tool_capability-search-min.js
admin/tool/capability/yui/build/moodle-tool_capability-search/moodle-tool_capability-search.js
admin/tool/capability/yui/src/search/js/search.js

diff --git a/admin/tool/capability/tests/behat/show_capabilies.feature b/admin/tool/capability/tests/behat/show_capabilies.feature
new file mode 100644 (file)
index 0000000..d0ec7c6
--- /dev/null
@@ -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 (file)
index 0000000..1c907a4
--- /dev/null
@@ -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"
index 6b8b368..1c05534 100644 (file)
Binary files a/admin/tool/capability/yui/build/moodle-tool_capability-search/moodle-tool_capability-search-debug.js and b/admin/tool/capability/yui/build/moodle-tool_capability-search/moodle-tool_capability-search-debug.js differ
index 7e1baef..697a214 100644 (file)
Binary files a/admin/tool/capability/yui/build/moodle-tool_capability-search/moodle-tool_capability-search-min.js and b/admin/tool/capability/yui/build/moodle-tool_capability-search/moodle-tool_capability-search-min.js differ
index 6b8b368..1c05534 100644 (file)
Binary files a/admin/tool/capability/yui/build/moodle-tool_capability-search/moodle-tool_capability-search.js and b/admin/tool/capability/yui/build/moodle-tool_capability-search/moodle-tool_capability-search.js differ
index b3b1527..1e4b96c 100644 (file)
@@ -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('<div id="capabilitysearchui"></div>'),
+        var div = Y.Node.create('<div id="capabilitysearchui" data-fieldtype="text"></div>'),
             label = Y.Node.create('<label for="capabilitysearch">' + this.get('strsearch') + '</label>');
         this.input = Y.Node.create('<input type="text" id="capabilitysearch" />');