| 11 | 
           efrain | 
           1 | 
           @editor @editor_tiny @tiny_link
  | 
        
        
           | 1 | 
           efrain | 
           2 | 
           Feature: Add links to TinyMCE
  | 
        
        
            | 
            | 
           3 | 
             To write rich text - I need to add links.
  | 
        
        
            | 
            | 
           4 | 
              | 
        
        
            | 
            | 
           5 | 
             @javascript
  | 
        
        
            | 
            | 
           6 | 
             Scenario: Insert a link
  | 
        
        
           | 11 | 
           efrain | 
           7 | 
               Given the following "user private file" exists:
  | 
        
        
            | 
            | 
           8 | 
                 | user     | admin                                                |
  | 
        
        
            | 
            | 
           9 | 
                 | filepath | lib/editor/tiny/tests/behat/fixtures/moodle-logo.png |
  | 
        
        
           | 1 | 
           efrain | 
           10 | 
               And I log in as "admin"
  | 
        
        
            | 
            | 
           11 | 
               And I open my profile in edit mode
  | 
        
        
            | 
            | 
           12 | 
               And I set the field "Description" to "Super cool"
  | 
        
        
            | 
            | 
           13 | 
               When I select the "p" element in position "0" of the "Description" TinyMCE editor
  | 
        
        
            | 
            | 
           14 | 
               And I click on the "Link" button for the "Description" TinyMCE editor
  | 
        
        
            | 
            | 
           15 | 
               Then the field "Text to display" matches value "Super cool"
  | 
        
        
            | 
            | 
           16 | 
               And I click on "Browse repositories..." "button" in the "Create link" "dialogue"
  | 
        
        
            | 
            | 
           17 | 
               And I select "Private files" repository in file picker
  | 
        
        
            | 
            | 
           18 | 
               And I click on "moodle-logo.png" "link"
  | 
        
        
            | 
            | 
           19 | 
               And I click on "Select this file" "button"
  | 
        
        
            | 
            | 
           20 | 
               And I click on "Update profile" "button"
  | 
        
        
            | 
            | 
           21 | 
               And I follow "Preferences" in the user menu
  | 
        
        
            | 
            | 
           22 | 
               And I follow "Editor preferences"
  | 
        
        
            | 
            | 
           23 | 
               And I set the field "Text editor" to "Plain text area"
  | 
        
        
            | 
            | 
           24 | 
               And I press "Save changes"
  | 
        
        
            | 
            | 
           25 | 
               And I click on "Edit profile" "link" in the "region-main" "region"
  | 
        
        
            | 
            | 
           26 | 
               And I should see "Super cool</a>"
  | 
        
        
            | 
            | 
           27 | 
              | 
        
        
            | 
            | 
           28 | 
             @javascript
  | 
        
        
            | 
            | 
           29 | 
             Scenario: Insert a link without providing text to display
  | 
        
        
            | 
            | 
           30 | 
               Given I log in as "admin"
  | 
        
        
            | 
            | 
           31 | 
               When I open my profile in edit mode
  | 
        
        
            | 
            | 
           32 | 
               And I click on the "Link" button for the "Description" TinyMCE editor
  | 
        
        
            | 
            | 
           33 | 
               And I set the field "URL" to "https://moodle.org/"
  | 
        
        
            | 
            | 
           34 | 
               Then the field "Text to display" matches value "https://moodle.org/"
  | 
        
        
            | 
            | 
           35 | 
               And I click on "Create link" "button" in the "Create link" "dialogue"
  | 
        
        
            | 
            | 
           36 | 
               And the field "Description" matches value "<p><a href=\"https://moodle.org/\">https://moodle.org/</a></p>"
  | 
        
        
            | 
            | 
           37 | 
               And I select the "a" element in position "0" of the "Description" TinyMCE editor
  | 
        
        
            | 
            | 
           38 | 
               And I click on the "Link" button for the "Description" TinyMCE editor
  | 
        
        
            | 
            | 
           39 | 
               And the field "Text to display" matches value "https://moodle.org/"
  | 
        
        
            | 
            | 
           40 | 
               And the field "URL" matches value "https://moodle.org/"
  | 
        
        
            | 
            | 
           41 | 
               And I click on "Close" "button" in the "Create link" "dialogue"
  | 
        
        
            | 
            | 
           42 | 
              | 
        
        
            | 
            | 
           43 | 
             @javascript
  | 
        
        
            | 
            | 
           44 | 
             Scenario: Insert a link with providing text to display
  | 
        
        
            | 
            | 
           45 | 
               Given I log in as "admin"
  | 
        
        
            | 
            | 
           46 | 
               When I open my profile in edit mode
  | 
        
        
            | 
            | 
           47 | 
               And I click on "Link" "button"
  | 
        
        
            | 
            | 
           48 | 
               And I set the field "Text to display" to "Moodle - Open-source learning platform"
  | 
        
        
            | 
            | 
           49 | 
               And I set the field "Enter a URL" to "https://moodle.org/"
  | 
        
        
            | 
            | 
           50 | 
               And I click on "Create link" "button" in the "Create link" "dialogue"
  | 
        
        
            | 
            | 
           51 | 
               Then the field "Description" matches value "<p><a href=\"https://moodle.org/\">Moodle - Open-source learning platform</a></p>"
  | 
        
        
            | 
            | 
           52 | 
               And I select the "a" element in position "0" of the "Description" TinyMCE editor
  | 
        
        
            | 
            | 
           53 | 
               And I click on the "Link" button for the "Description" TinyMCE editor
  | 
        
        
            | 
            | 
           54 | 
               And the field "Text to display" matches value "Moodle - Open-source learning platform"
  | 
        
        
            | 
            | 
           55 | 
               And the field "Enter a URL" matches value "https://moodle.org/"
  | 
        
        
            | 
            | 
           56 | 
               And I click on "Close" "button" in the "Create link" "dialogue"
  | 
        
        
            | 
            | 
           57 | 
              | 
        
        
            | 
            | 
           58 | 
             @javascript
  | 
        
        
            | 
            | 
           59 | 
             Scenario: Edit a link that already had a custom text to display
  | 
        
        
            | 
            | 
           60 | 
               Given I log in as "admin"
  | 
        
        
            | 
            | 
           61 | 
               And I follow "Preferences" in the user menu
  | 
        
        
            | 
            | 
           62 | 
               And I follow "Editor preferences"
  | 
        
        
            | 
            | 
           63 | 
               And I set the field "Text editor" to "Plain text area"
  | 
        
        
            | 
            | 
           64 | 
               And I press "Save changes"
  | 
        
        
            | 
            | 
           65 | 
               And I click on "Edit profile" "link" in the "region-main" "region"
  | 
        
        
            | 
            | 
           66 | 
               And I set the field "Description" to "<a href=\"https://moodle.org/\">Moodle - Open-source learning platform</a>"
  | 
        
        
            | 
            | 
           67 | 
               And I click on "Update profile" "button"
  | 
        
        
            | 
            | 
           68 | 
               And I follow "Preferences" in the user menu
  | 
        
        
            | 
            | 
           69 | 
               And I follow "Editor preferences"
  | 
        
        
            | 
            | 
           70 | 
               And I set the field "Text editor" to "TinyMCE editor"
  | 
        
        
            | 
            | 
           71 | 
               And I press "Save changes"
  | 
        
        
            | 
            | 
           72 | 
               When I click on "Edit profile" "link" in the "region-main" "region"
  | 
        
        
            | 
            | 
           73 | 
               Then the field "Description" matches value "<p><a href=\"https://moodle.org/\">Moodle - Open-source learning platform</a></p>"
  | 
        
        
            | 
            | 
           74 | 
               And I select the "a" element in position "0" of the "Description" TinyMCE editor
  | 
        
        
            | 
            | 
           75 | 
               And I click on the "Link" button for the "Description" TinyMCE editor
  | 
        
        
            | 
            | 
           76 | 
               And the field "Text to display" matches value "Moodle - Open-source learning platform"
  | 
        
        
            | 
            | 
           77 | 
               And the field "Enter a URL" matches value "https://moodle.org/"
  | 
        
        
            | 
            | 
           78 | 
              | 
        
        
            | 
            | 
           79 | 
             @javascript
  | 
        
        
            | 
            | 
           80 | 
             Scenario: Insert and update link in the TinyMCE editor
  | 
        
        
            | 
            | 
           81 | 
               Given I log in as "admin"
  | 
        
        
            | 
            | 
           82 | 
               When I open my profile in edit mode
  | 
        
        
            | 
            | 
           83 | 
               And I click on "Link" "button"
  | 
        
        
            | 
            | 
           84 | 
               And I set the field "Text to display" to "Moodle - Open-source learning platform"
  | 
        
        
            | 
            | 
           85 | 
               And I set the field "Enter a URL" to "https://moodle.org/"
  | 
        
        
            | 
            | 
           86 | 
               And I click on "Create link" "button" in the "Create link" "dialogue"
  | 
        
        
            | 
            | 
           87 | 
               Then the field "Description" matches value "<p><a href=\"https://moodle.org/\">Moodle - Open-source learning platform</a></p>"
  | 
        
        
            | 
            | 
           88 | 
               And I select the "a" element in position "0" of the "Description" TinyMCE editor
  | 
        
        
            | 
            | 
           89 | 
               And I click on the "Link" button for the "Description" TinyMCE editor
  | 
        
        
            | 
            | 
           90 | 
               And the field "Text to display" matches value "Moodle - Open-source learning platform"
  | 
        
        
            | 
            | 
           91 | 
               And the field "Enter a URL" matches value "https://moodle.org/"
  | 
        
        
            | 
            | 
           92 | 
               And I set the field "Enter a URL" to "https://moodle.com/"
  | 
        
        
            | 
            | 
           93 | 
               And "Create link" "button" should not exist in the "Create link" "dialogue"
  | 
        
        
            | 
            | 
           94 | 
               And "Update link" "button" should exist in the "Create link" "dialogue"
  | 
        
        
            | 
            | 
           95 | 
               And I click on "Update link" "button" in the "Create link" "dialogue"
  | 
        
        
            | 
            | 
           96 | 
               And the field "Description" matches value "<p><a href=\"https://moodle.com/\">Moodle - Open-source learning platform</a></p>"
  | 
        
        
            | 
            | 
           97 | 
              | 
        
        
            | 
            | 
           98 | 
             @javascript
  | 
        
        
            | 
            | 
           99 | 
             Scenario: Insert a link for an image using TinyMCE editor
  | 
        
        
           | 11 | 
           efrain | 
           100 | 
               Given the following "user private file" exists:
  | 
        
        
            | 
            | 
           101 | 
                 | user     | admin                                                |
  | 
        
        
            | 
            | 
           102 | 
                 | filepath | lib/editor/tiny/tests/behat/fixtures/moodle-logo.png |
  | 
        
        
            | 
            | 
           103 | 
               And I log in as "admin"
  | 
        
        
           | 1 | 
           efrain | 
           104 | 
               And I open my profile in edit mode
  | 
        
        
            | 
            | 
           105 | 
               And I click on the "Image" button for the "Description" TinyMCE editor
  | 
        
        
            | 
            | 
           106 | 
               And I click on "Browse repositories" "button" in the "Insert image" "dialogue"
  | 
        
        
            | 
            | 
           107 | 
               And I select "Private files" repository in file picker
  | 
        
        
            | 
            | 
           108 | 
               And I click on "moodle-logo.png" "link"
  | 
        
        
            | 
            | 
           109 | 
               And I click on "Select this file" "button"
  | 
        
        
           | 11 | 
           efrain | 
           110 | 
               And I set the field "How would you describe this image to someone who can't see it?" to "It's the Moodle"
  | 
        
        
           | 1 | 
           efrain | 
           111 | 
               And I click on "Save" "button" in the "Image details" "dialogue"
  | 
        
        
            | 
            | 
           112 | 
               And I select the "img" element in position "0" of the "Description" TinyMCE editor
  | 
        
        
            | 
            | 
           113 | 
               And I click on the "Link" button for the "Description" TinyMCE editor
  | 
        
        
            | 
            | 
           114 | 
               And I set the field "Enter a URL" to "https://moodle.org/"
  | 
        
        
            | 
            | 
           115 | 
               And I set the field "Text to display" to "Moodle - Open-source learning platform"
  | 
        
        
           | 1441 | 
           ariadna | 
           116 | 
               And I click on "Create link" "button" in the "Create link" "dialogue"
  | 
        
        
           | 1 | 
           efrain | 
           117 | 
               # TODO: Verify the HTML by the improved code plugin in MDL-75265
  | 
        
        
            | 
            | 
           118 | 
               And I click on "Update profile" "button"
  | 
        
        
            | 
            | 
           119 | 
               And I follow "Preferences" in the user menu
  | 
        
        
            | 
            | 
           120 | 
               And I follow "Editor preferences"
  | 
        
        
            | 
            | 
           121 | 
               And I set the field "Text editor" to "Plain text area"
  | 
        
        
            | 
            | 
           122 | 
               And I press "Save changes"
  | 
        
        
            | 
            | 
           123 | 
               When I click on "Edit profile" "link" in the "region-main" "region"
  | 
        
        
            | 
            | 
           124 | 
               Then I should see "<a title=\"Moodle - Open-source learning platform\" href=\"https://moodle.org/\"><img"
  | 
        
        
            | 
            | 
           125 | 
               And I follow "Preferences" in the user menu
  | 
        
        
            | 
            | 
           126 | 
               And I follow "Editor preferences"
  | 
        
        
            | 
            | 
           127 | 
               And I set the field "Text editor" to "TinyMCE editor"
  | 
        
        
            | 
            | 
           128 | 
               And I press "Save changes"
  | 
        
        
            | 
            | 
           129 | 
               And I click on "Edit profile" "link" in the "region-main" "region"
  | 
        
        
            | 
            | 
           130 | 
               And I select the "img" element in position "0" of the "Description" TinyMCE editor
  | 
        
        
            | 
            | 
           131 | 
               And I click on the "Image" button for the "Description" TinyMCE editor
  | 
        
        
           | 11 | 
           efrain | 
           132 | 
               And the field "How would you describe this image to someone who can't see it?" matches value "It's the Moodle"
  | 
        
        
           | 1 | 
           efrain | 
           133 | 
               And I click on "Close" "button" in the "Image details" "dialogue"
  | 
        
        
            | 
            | 
           134 | 
               And I click on the "Link" button for the "Description" TinyMCE editor
  | 
        
        
            | 
            | 
           135 | 
               And the field "Text to display" matches value "Moodle - Open-source learning platform"
  | 
        
        
            | 
            | 
           136 | 
               And the field "Enter a URL" matches value "https://moodle.org/"
  | 
        
        
            | 
            | 
           137 | 
              | 
        
        
            | 
            | 
           138 | 
             @javascript
  | 
        
        
            | 
            | 
           139 | 
             Scenario: Unset a link
  | 
        
        
            | 
            | 
           140 | 
               Given I log in as "admin"
  | 
        
        
            | 
            | 
           141 | 
               And I follow "Preferences" in the user menu
  | 
        
        
            | 
            | 
           142 | 
               And I follow "Editor preferences"
  | 
        
        
            | 
            | 
           143 | 
               And I set the field "Text editor" to "Plain text area"
  | 
        
        
            | 
            | 
           144 | 
               And I press "Save changes"
  | 
        
        
            | 
            | 
           145 | 
               And I click on "Edit profile" "link" in the "region-main" "region"
  | 
        
        
            | 
            | 
           146 | 
               And I set the field "Description" to "<a href=\"https://moodle.org/\">Moodle - Open-source learning platform</a>"
  | 
        
        
            | 
            | 
           147 | 
               And I click on "Update profile" "button"
  | 
        
        
            | 
            | 
           148 | 
               And I follow "Preferences" in the user menu
  | 
        
        
            | 
            | 
           149 | 
               And I follow "Editor preferences"
  | 
        
        
            | 
            | 
           150 | 
               And I set the field "Text editor" to "TinyMCE editor"
  | 
        
        
            | 
            | 
           151 | 
               And I press "Save changes"
  | 
        
        
            | 
            | 
           152 | 
               And I click on "Edit profile" "link" in the "region-main" "region"
  | 
        
        
            | 
            | 
           153 | 
               And I select the "a" element in position "0" of the "Description" TinyMCE editor
  | 
        
        
            | 
            | 
           154 | 
               When I click on the "Unlink" button for the "Description" TinyMCE editor
  | 
        
        
            | 
            | 
           155 | 
               Then the field "Description" matches value "<p>Moodle - Open-source learning platform</p>"
  | 
        
        
           | 1441 | 
           ariadna | 
           156 | 
              | 
        
        
            | 
            | 
           157 | 
             @javascript
  | 
        
        
            | 
            | 
           158 | 
             Scenario: Permissions can be configured to control access to link
  | 
        
        
            | 
            | 
           159 | 
               Given the following "users" exist:
  | 
        
        
            | 
            | 
           160 | 
                 | username | firstname | lastname | email                |
  | 
        
        
            | 
            | 
           161 | 
                 | teacher1 | Teacher   | 1        | teacher1@example.com |
  | 
        
        
            | 
            | 
           162 | 
                 | teacher2 | Teacher   | 2        | teacher2@example.com |
  | 
        
        
            | 
            | 
           163 | 
               And the following "courses" exist:
  | 
        
        
            | 
            | 
           164 | 
                 | fullname | shortname | format |
  | 
        
        
            | 
            | 
           165 | 
                 | Course 1 | C1        | topics |
  | 
        
        
            | 
            | 
           166 | 
               And the following "roles" exist:
  | 
        
        
            | 
            | 
           167 | 
                 | name           | shortname | description         | archetype      |
  | 
        
        
            | 
            | 
           168 | 
                 | Custom teacher | custom1   | Limited permissions | editingteacher |
  | 
        
        
            | 
            | 
           169 | 
               And the following "course enrolments" exist:
  | 
        
        
            | 
            | 
           170 | 
                 | user     | course | role           |
  | 
        
        
            | 
            | 
           171 | 
                 | teacher1 | C1     | editingteacher |
  | 
        
        
            | 
            | 
           172 | 
                 | teacher2 | C1     | custom1        |
  | 
        
        
            | 
            | 
           173 | 
               And the following "activity" exists:
  | 
        
        
            | 
            | 
           174 | 
                 | activity | assign          |
  | 
        
        
            | 
            | 
           175 | 
                 | course   | C1              |
  | 
        
        
            | 
            | 
           176 | 
                 | name     | Test assignment |
  | 
        
        
            | 
            | 
           177 | 
               And the following "permission overrides" exist:
  | 
        
        
            | 
            | 
           178 | 
                 | capability    | permission | role    | contextlevel | reference |
  | 
        
        
            | 
            | 
           179 | 
                 | tiny/link:use | Prohibit   | custom1 | Course       | C1        |
  | 
        
        
            | 
            | 
           180 | 
               # Check plugin access as a role with prohibited permissions.
  | 
        
        
            | 
            | 
           181 | 
               And I log in as "teacher2"
  | 
        
        
            | 
            | 
           182 | 
               And I am on the "Test assignment" Activity page
  | 
        
        
            | 
            | 
           183 | 
               And I navigate to "Settings" in current page administration
  | 
        
        
            | 
            | 
           184 | 
               When I click on the "Insert" menu item for the "Activity instructions" TinyMCE editor
  | 
        
        
            | 
            | 
           185 | 
               Then I should not see "Link"
  | 
        
        
            | 
            | 
           186 | 
               # Check plugin access as a role with allowed permissions.
  | 
        
        
            | 
            | 
           187 | 
               And I log in as "teacher1"
  | 
        
        
            | 
            | 
           188 | 
               And I am on the "Test assignment" Activity page
  | 
        
        
            | 
            | 
           189 | 
               And I navigate to "Settings" in current page administration
  | 
        
        
            | 
            | 
           190 | 
               And I click on the "Insert" menu item for the "Activity instructions" TinyMCE editor
  | 
        
        
            | 
            | 
           191 | 
               And I should see "Link"
  |