From 4f3d1266e362c0b8caa4d5963de7e2d631c81dbf Mon Sep 17 00:00:00 2001 From: Shamim Rezaie Date: Wed, 9 Oct 2019 15:19:11 +1100 Subject: [PATCH] MDL-66371 mod_forum: Improving behat tests --- mod/forum/tests/behat/forum_export.feature | 27 +++++++++++++--------- 1 file changed, 16 insertions(+), 11 deletions(-) diff --git a/mod/forum/tests/behat/forum_export.feature b/mod/forum/tests/behat/forum_export.feature index 639566a45da..0fc6c544f50 100644 --- a/mod/forum/tests/behat/forum_export.feature +++ b/mod/forum/tests/behat/forum_export.feature @@ -1,8 +1,8 @@ @mod @mod_forum @javascript Feature: Export forum - In order to export forum content + In order to parse forum data for linguistic analysis As a teacher - I need to add a forum activity and discussions + I need to export the forum data for select users Background: Add a forum and a discussion Given the following "users" exist: @@ -30,6 +30,7 @@ Feature: Export forum And I should see "Student 1" in the ".form-autocomplete-suggestions" "css_element" And I should see "Teacher 1" in the ".form-autocomplete-suggestions" "css_element" And I should not see "Student 2" in the ".form-autocomplete-suggestions" "css_element" + # This will fail if an exception is thrown. This is the best we can do without the ability to use the download. Hence, there is no "Then" step. And I click on "Export" "button" And I log out @@ -39,15 +40,19 @@ Feature: Export forum When I follow "Test forum 1" Then "Export" "link" should not exist in current page administration And I log out - And I log in as "admin" + + Scenario: User with the capability can export + Given the following "permission overrides" exist: + | capability | permission | role | contextlevel | reference | + | mod/forum:exportforum | Allow | student | Course | C1 | + When I log in as "student1" And I am on "Course 1" course homepage - And I navigate to "Users > Permissions" in current page administration - And I override the system permissions of "Student" role with: - | capability | permission | - | mod/forum:exportforum | Allow | - And I log out - Given I log in as "student1" - And I am on "Course 1" course homepage - When I follow "Test forum 1" + And I follow "Test forum 1" And I navigate to "Export" in current page administration + And I open the autocomplete suggestions list + And I should see "Student 1" in the ".form-autocomplete-suggestions" "css_element" + And I should see "Teacher 1" in the ".form-autocomplete-suggestions" "css_element" + And I should not see "Student 2" in the ".form-autocomplete-suggestions" "css_element" + # This will fail if an exception is thrown. This is the best we can do without the ability to use the download. Hence, there is no "Then" step. And I click on "Export" "button" + And I log out