| 1 | efrain | 1 | @block @block_dash
 | 
        
           |  |  | 2 | Feature: Enable the widget in dash block on the dashboard page and view it's contents
 | 
        
           |  |  | 3 |   In order to enable the widgets in dash block on the dashboard
 | 
        
           |  |  | 4 |   As an admin
 | 
        
           |  |  | 5 |   I can add the dash block to the dashboard
 | 
        
           |  |  | 6 |   | 
        
           |  |  | 7 |   Background:
 | 
        
           |  |  | 8 |     Given the following "categories" exist:
 | 
        
           |  |  | 9 |       | name       | category | idnumber |
 | 
        
           |  |  | 10 |       | Category 1 | 0        | CAT1     |
 | 
        
           |  |  | 11 |       | Category 2 | 0        | CAT2     |
 | 
        
           |  |  | 12 |       | Category 3 | CAT2     | CAT3     |
 | 
        
           |  |  | 13 |     And the following "courses" exist:
 | 
        
           |  |  | 14 |       | fullname | shortname | category | enablecompletion |
 | 
        
           |  |  | 15 |       | Course 1 | C1        | 0        | 1                |
 | 
        
           |  |  | 16 |       | Course 2 | C2        | CAT1     | 0                |
 | 
        
           |  |  | 17 |       | Course 3 | C3        | CAT2     | 1                |
 | 
        
           |  |  | 18 |       | Course 4 | C4        | CAT3     | 1                |
 | 
        
           |  |  | 19 |     And the following "users" exist:
 | 
        
           |  |  | 20 |       | username | firstname | lastname | email                |
 | 
        
           |  |  | 21 |       | student1 | Student   | First    | student1@example.com |
 | 
        
           |  |  | 22 |       | teacher1 | Teacher   | First    | teacher1@example.com |
 | 
        
           |  |  | 23 |       | student2 | Student   | Two      | student2@example.com |
 | 
        
           |  |  | 24 |   | 
        
           |  |  | 25 |     And the following "activities" exist:
 | 
        
           |  |  | 26 |       | activity | course | idnumber | section | name             | intro                 | completion | completionview |
 | 
        
           |  |  | 27 |       | page     | C1     | page1    | 0       | Test page name   | Test page description | 2          | 1              |
 | 
        
           |  |  | 28 |       | page     | C1     | page2    | 1       | Test page name 2 | Test page description | 2          | 1              |
 | 
        
           |  |  | 29 |   | 
        
           |  |  | 30 |     And the following "course enrolments" exist:
 | 
        
           |  |  | 31 |       | user     | course | role    |
 | 
        
           |  |  | 32 |       | student1 | C1     | student |
 | 
        
           |  |  | 33 |       | teacher1 | C1     | teacher |
 | 
        
           |  |  | 34 |       | student1 | C2     | student |
 | 
        
           |  |  | 35 |       | student1 | C3     | student |
 | 
        
           |  |  | 36 |   | 
        
           |  |  | 37 |     And I log in as "admin"
 | 
        
           |  |  | 38 |     And I navigate to "Appearance > Default Dashboard page" in site administration
 | 
        
           |  |  | 39 |     And I turn dash block editing mode on
 | 
        
           |  |  | 40 |     And I add the "Dash" block
 | 
        
           |  |  | 41 |     And I click on "My learning" "radio"
 | 
        
           |  |  | 42 |     And I configure the "New Dash" block
 | 
        
           |  |  | 43 |     And I set the following fields to these values:
 | 
        
           |  |  | 44 |       | Block title  | My Learning                 |
 | 
        
           |  |  | 45 |       | Region  | content                          |
 | 
        
           |  |  | 46 |       | Content | My learaning empty state content |
 | 
        
           |  |  | 47 |     And I press "Save changes"
 | 
        
           |  |  | 48 |     And I click on "Reset Dashboard for all users" "button"
 | 
        
           |  |  | 49 |     And I log out
 | 
        
           |  |  | 50 |   | 
        
           |  |  | 51 |   @javascript
 | 
        
           |  |  | 52 |   Scenario: Add the dash mylearning widget block on the dashboard
 | 
        
           |  |  | 53 |     Given I log in as "student1"
 | 
        
           |  |  | 54 |     Then I should see "Course 1" in the "My Learning" "block"
 | 
        
           |  |  | 55 |     And I should see "Course 2" in the "My Learning" "block"
 | 
        
           |  |  | 56 |     And I should see "Course 3" in the "My Learning" "block"
 | 
        
           |  |  | 57 |     And I should not see "Course 4" in the "My Learning" "block"
 | 
        
           |  |  | 58 |   | 
        
           |  |  | 59 |   @javascript
 | 
        
           |  |  | 60 |   Scenario: Course completion status in mylearning widget
 | 
        
           |  |  | 61 |     Given I log in as "admin"
 | 
        
           |  |  | 62 |     And I am on "Course 1" course homepage with editing mode on
 | 
        
           |  |  | 63 |     And I navigate to "Course completion" in current page administration
 | 
        
           |  |  | 64 |     And I expand all fieldsets
 | 
        
           |  |  | 65 |     And I set the following fields to these values:
 | 
        
           |  |  | 66 |       | Test page name   | 1 |
 | 
        
           |  |  | 67 |       | Test page name 2 | 1 |
 | 
        
           |  |  | 68 |     And I press "Save changes"
 | 
        
           |  |  | 69 |     And I log out
 | 
        
           |  |  | 70 |     When I log in as "student1"
 | 
        
           |  |  | 71 |     Then I should see "Course 1" in the "My Learning" "block"
 | 
        
           |  |  | 72 |     And I should see "0" in the ".card-header:nth-child(1)" "css_element"
 | 
        
           |  |  | 73 |     And I click on "General" "button" in the "My Learning" "block"
 | 
        
           |  |  | 74 |     Then I click on "Test page name" "link"
 | 
        
           |  |  | 75 |     And I follow dashboard
 | 
        
           |  |  | 76 |     Then the "class" attribute of ".block_dash-info-element .card:nth-child(1)" "css_element" should contain "completed-bg"
 | 
        
           |  |  | 77 |     And ".fa.fa-check" "css_element" should exist in the ".block_dash-info-element .card:nth-child(1)" "css_element"
 | 
        
           |  |  | 78 |   | 
        
           |  |  | 79 |   @javascript @_file_upload
 | 
        
           |  |  | 80 |   Scenario: Course badges list in Mylearning widget
 | 
        
           |  |  | 81 |     Given I log in as "admin"
 | 
        
           |  |  | 82 |     And I am on "Course 1" course homepage
 | 
        
           |  |  | 83 |     And I navigate to "Badges > Add a new badge" in current page administration
 | 
        
           |  |  | 84 |     And I set the following fields to these values:
 | 
        
           |  |  | 85 |       | id_name        | Badge 1 |
 | 
        
           |  |  | 86 |       | id_description | Badge 1 |
 | 
        
           |  |  | 87 |     And I upload "blocks/badges/tests/fixtures/badge.png" file to "Image" filemanager
 | 
        
           |  |  | 88 |     And I press "Create badge"
 | 
        
           |  |  | 89 |     And I select "Manual issue by role" from the "Add badge criteria" singleselect
 | 
        
           |  |  | 90 |     And I set the field "Teacher" to "1"
 | 
        
           |  |  | 91 |     And I press "Save"
 | 
        
           |  |  | 92 |     And I press "Enable access"
 | 
        
           |  |  | 93 |     And I press "Continue"
 | 
        
           |  |  | 94 |     And I follow badge recipients
 | 
        
           |  |  | 95 |     And I press "Award badge"
 | 
        
           |  |  | 96 |     And I set the field "potentialrecipients[]" to "Student First (student1@example.com)"
 | 
        
           |  |  | 97 |     And I press "Award badge"
 | 
        
           |  |  | 98 |     And I log out
 | 
        
           |  |  | 99 |     When I log in as "student1"
 | 
        
           |  |  | 100 |     Then ".collected .activatebadge[alt=\"Badge 1\"]" "css_element" should exist in the "My Learning" "block"
 | 
        
           |  |  | 101 |   | 
        
           |  |  | 102 |   @javascript
 | 
        
           |  |  | 103 |   Scenario: Check the empty state option.
 | 
        
           |  |  | 104 |     Given I log in as "student2"
 | 
        
           |  |  | 105 |     Then I should see "My learaning empty state content" in the "My Learning" "block"
 | 
        
           |  |  | 106 |     And I log out
 | 
        
           |  |  | 107 |     When I log in as "student1"
 | 
        
           |  |  | 108 |     Then I should not see "My learaning empty state content" in the "My Learning" "block"
 | 
        
           |  |  | 109 |     And I log out
 |