From 456b8a602c612ac0259efc45d5c2f2bcd89fa2b0 Mon Sep 17 00:00:00 2001 From: Stephen Bourget Date: Mon, 2 May 2016 11:28:09 -0400 Subject: [PATCH] MDL-54003 Behat: tests for recent badges block --- .../badges/tests/behat/block_badges.feature | 34 ++++++++ .../tests/behat/block_badges_course.feature | 73 ++++++++++++++++++ .../behat/block_badges_dashboard.feature | 39 ++++++++++ .../behat/block_badges_frontpage.feature | 44 +++++++++++ blocks/badges/tests/fixtures/badge.png | Bin 0 -> 2116 bytes 5 files changed, 190 insertions(+) create mode 100644 blocks/badges/tests/behat/block_badges.feature create mode 100644 blocks/badges/tests/behat/block_badges_course.feature create mode 100644 blocks/badges/tests/behat/block_badges_dashboard.feature create mode 100644 blocks/badges/tests/behat/block_badges_frontpage.feature create mode 100644 blocks/badges/tests/fixtures/badge.png diff --git a/blocks/badges/tests/behat/block_badges.feature b/blocks/badges/tests/behat/block_badges.feature new file mode 100644 index 00000000000..e9da78ac5ae --- /dev/null +++ b/blocks/badges/tests/behat/block_badges.feature @@ -0,0 +1,34 @@ +@block @block_badges +Feature: Enable Block Badges in a course without badges + In order to view the badges block in a course + As a teacher + I can add badges block to a course and view the contents + + Background: + Given the following "users" exist: + | username | firstname | lastname | email | idnumber | + | teacher1 | Teacher | 1 | teacher1@example.com | T1 | + And the following "courses" exist: + | fullname | shortname | category | + | Course 1 | C1 | 0 | + And the following "course enrolments" exist: + | user | course | role | + | teacher1 | C1 | editingteacher | + + Scenario: Add the block to a the course when badges are disabled + Given I log in as "admin" + And the following config values are set as admin: + | enablebadges | 0 | + And I log out + And I log in as "teacher1" + And I follow "Course 1" + And I turn editing mode on + When I add the "Latest badges" block + Then I should see "Badges are not enabled on this site." in the "Latest badges" "block" + + Scenario: Add the block to a the course when badges are enabled + Given I log in as "teacher1" + And I follow "Course 1" + And I turn editing mode on + When I add the "Latest badges" block + Then I should see "You have no badges to display" in the "Latest badges" "block" diff --git a/blocks/badges/tests/behat/block_badges_course.feature b/blocks/badges/tests/behat/block_badges_course.feature new file mode 100644 index 00000000000..75942ff5e6d --- /dev/null +++ b/blocks/badges/tests/behat/block_badges_course.feature @@ -0,0 +1,73 @@ +@block @block_badges @core_badges @_file_upload @javascript +Feature: Enable Block Badges in a course + In order to enable the badges block in a course + As a teacher + I can add badges block to a course + + Background: + Given the following "users" exist: + | username | firstname | lastname | email | idnumber | + | teacher1 | Teacher | 1 | teacher1@example.com | T1 | + And the following "courses" exist: + | fullname | shortname | category | + | Course 1 | C1 | 0 | + And the following "course enrolments" exist: + | user | course | role | + | teacher1 | C1 | editingteacher | + And I log in as "teacher1" + And I follow "Course 1" + # Issue badge 1 of 2 + And I navigate to "Add a new badge" node in "Badges" + And I set the following fields to these values: + | id_name | Badge 1 | + | id_description | Badge 1 | + | id_issuername | Teacher 1 | + And I upload "blocks/badges/tests/fixtures/badge.png" file to "Image" filemanager + And I press "Create badge" + And I select "Manual issue by role" from the "Add badge criteria" singleselect + And I set the field "Teacher" to "1" + And I press "Save" + And I press "Enable access" + And I press "Continue" + And I follow "Recipients (0)" + And I press "Award badge" + And I set the field "potentialrecipients[]" to "Teacher 1 (teacher1@example.com)" + And I press "Award badge" + # Issue Badge 2 of 2 + And I navigate to "Add a new badge" node in "Badges" + And I set the following fields to these values: + | id_name | Badge 2 | + | id_description | Badge 2 | + | id_issuername | Teacher 1 | + And I upload "blocks/badges/tests/fixtures/badge.png" file to "Image" filemanager + And I press "Create badge" + And I select "Manual issue by role" from the "Add badge criteria" singleselect + And I set the field "Teacher" to "1" + And I press "Save" + And I press "Enable access" + And I press "Continue" + And I follow "Recipients (0)" + And I press "Award badge" + And I set the field "potentialrecipients[]" to "Teacher 1 (teacher1@example.com)" + And I press "Award badge" + And I log out + + Scenario: Add the recent badges block to a course. + Given I log in as "teacher1" + And I follow "Course 1" + And I turn editing mode on + When I add the "Latest badges" block + Then I should see "Badge 1" in the "Latest badges" "block" + And I should see "Badge 2" in the "Latest badges" "block" + + Scenario: Add the recent badges block to a course and limit it to only display 1 badge. + Given I log in as "teacher1" + And I follow "Course 1" + And I turn editing mode on + When I add the "Latest badges" block + And I configure the "Latest badges" block + And I set the following fields to these values: + | id_config_numberofbadges | 1 | + And I press "Save changes" + Then I should see "Badge 2" in the "Latest badges" "block" + And I should not see "Badge 1" in the "Latest badges" "block" diff --git a/blocks/badges/tests/behat/block_badges_dashboard.feature b/blocks/badges/tests/behat/block_badges_dashboard.feature new file mode 100644 index 00000000000..6bc3d1ffb66 --- /dev/null +++ b/blocks/badges/tests/behat/block_badges_dashboard.feature @@ -0,0 +1,39 @@ +@block @block_badges @core_badges @_file_upload @javascript +Feature: Enable Block Badges on the dashboard and view awarded badges + In order to view recent badges on the dashboard + As a teacher + I can add badges block to the dashboard + + Scenario: Add the recent badges block to a course. + Given the following "users" exist: + | username | firstname | lastname | email | idnumber | + | teacher1 | Teacher | 1 | teacher1@example.com | T1 | + And the following "courses" exist: + | fullname | shortname | category | + | Course 1 | C1 | 0 | + And the following "course enrolments" exist: + | user | course | role | + | teacher1 | C1 | editingteacher | + And I log in as "teacher1" + And I follow "Course 1" + # Issue badge 1 of 2 + And I navigate to "Add a new badge" node in "Badges" + And I set the following fields to these values: + | id_name | Badge 1 | + | id_description | Badge 1 | + | id_issuername | Teacher 1 | + And I upload "blocks/badges/tests/fixtures/badge.png" file to "Image" filemanager + And I press "Create badge" + And I select "Manual issue by role" from the "Add badge criteria" singleselect + And I set the field "Teacher" to "1" + And I press "Save" + And I press "Enable access" + And I press "Continue" + And I follow "Recipients (0)" + And I press "Award badge" + And I set the field "potentialrecipients[]" to "Teacher 1 (teacher1@example.com)" + And I press "Award badge" + And I log out + When I log in as "teacher1" + And I click on "Dashboard" "link" in the "Navigation" "block" + Then I should see "Badge 1" in the "Latest badges" "block" diff --git a/blocks/badges/tests/behat/block_badges_frontpage.feature b/blocks/badges/tests/behat/block_badges_frontpage.feature new file mode 100644 index 00000000000..8b403578e64 --- /dev/null +++ b/blocks/badges/tests/behat/block_badges_frontpage.feature @@ -0,0 +1,44 @@ +@block @block_badges @core_badges @_file_upload @javascript +Feature: Enable Block Badges on the frontpage and view awarded badges + In order to enable the badges block on the frontpage + As a admin + I can add badges block to the frontpage + + Scenario: Add the recent badges block on the frontpage and view recent badges + Given the following "users" exist: + | username | firstname | lastname | email | idnumber | + | teacher1 | Teacher | 1 | teacher1@example.com | T1 | + And the following "courses" exist: + | fullname | shortname | category | + | Course 1 | C1 | 0 | + And the following "course enrolments" exist: + | user | course | role | + | teacher1 | C1 | editingteacher | + And I log in as "admin" + And I am on site homepage + And I navigate to "Turn editing on" node in "Front page settings" + And I add the "Latest badges" block + And I log out + And I log in as "teacher1" + And I follow "Course 1" + # Issue badge 1 of 2 + And I navigate to "Add a new badge" node in "Badges" + And I set the following fields to these values: + | id_name | Badge 1 | + | id_description | Badge 1 | + | id_issuername | Teacher 1 | + And I upload "blocks/badges/tests/fixtures/badge.png" file to "Image" filemanager + And I press "Create badge" + And I select "Manual issue by role" from the "Add badge criteria" singleselect + And I set the field "Teacher" to "1" + And I press "Save" + And I press "Enable access" + And I press "Continue" + And I follow "Recipients (0)" + And I press "Award badge" + And I set the field "potentialrecipients[]" to "Teacher 1 (teacher1@example.com)" + And I press "Award badge" + And I log out + When I log in as "teacher1" + And I am on site homepage + Then I should see "Badge 1" in the "Latest badges" "block" diff --git a/blocks/badges/tests/fixtures/badge.png b/blocks/badges/tests/fixtures/badge.png new file mode 100644 index 0000000000000000000000000000000000000000..73f2c07e52a24ed4d342635bf82c69d3ab047d79 GIT binary patch literal 2116 zcmV-K2)p-*P)R^Y*wr$(Ct?_2>V`JMqHeX%aw(Wb5ZQD-Ii~7)GWSnd!-JPVKG5*_l z)~e2`RdZI&sSdR&M&R>!9?{1z=N2KH4Pzcg|DF-fv|F8**@dL=)Z;= zy3>uT2G@TWM*Su1JvJ=5QXrAMeFa+>#M%QtK_IjgW!nu8=l>$yP);|fcBBu&c|Q-^ zc7>*vK!P7)H-kv);%5kiwxVqJi^9xj(v7G`W;`8sy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