| 1 | 
           efrain | 
           1 | 
           @editor @editor_tiny @tiny_noautolink
  | 
        
        
            | 
            | 
           2 | 
           Feature: Tiny noautolink
  | 
        
        
           | 11 | 
           efrain | 
           3 | 
               In order to prevent auto-linking in TinyMCE
  | 
        
        
            | 
            | 
           4 | 
               As a User
  | 
        
        
            | 
            | 
           5 | 
               I need be able to apply the auto-link prevention feature to the selected text
  | 
        
        
           | 1 | 
           efrain | 
           6 | 
              | 
        
        
           | 11 | 
           efrain | 
           7 | 
             Background:
  | 
        
        
           | 1 | 
           efrain | 
           8 | 
               Given I log in as "admin"
  | 
        
        
            | 
            | 
           9 | 
               And I navigate to "Plugins > Text editors > TinyMCE editor > General settings" in site administration
  | 
        
        
           | 1441 | 
           ariadna | 
           10 | 
               And I toggle the "Enable No auto-link" admin switch "on"
  | 
        
        
            | 
            | 
           11 | 
               When I open my profile in edit mode
  | 
        
        
            | 
            | 
           12 | 
               And I set the field "Description" to "<p>https://moodle.org</p>"
  | 
        
        
           | 11 | 
           efrain | 
           13 | 
              | 
        
        
            | 
            | 
           14 | 
             @javascript
  | 
        
        
            | 
            | 
           15 | 
             Scenario: Add and remove auto-link prevention to URLs
  | 
        
        
            | 
            | 
           16 | 
               Given I open my profile in edit mode
  | 
        
        
           | 1 | 
           efrain | 
           17 | 
               And I set the field "Description" to "<p>https://moodle.org</p>"
  | 
        
        
            | 
            | 
           18 | 
               # Add auto-link prevention.
  | 
        
        
            | 
            | 
           19 | 
               And I select the "p" element in position "0" of the "Description" TinyMCE editor
  | 
        
        
           | 11 | 
           efrain | 
           20 | 
               When I click on the "No auto-link" button for the "Description" TinyMCE editor
  | 
        
        
            | 
            | 
           21 | 
               Then the field "Description" matches value "<p><span class='nolink'>https://moodle.org</span></p>"
  | 
        
        
            | 
            | 
           22 | 
               # Remove auto-link prevention.
  | 
        
        
            | 
            | 
           23 | 
               And I select the "span" element in position "0" of the "Description" TinyMCE editor
  | 
        
        
           | 1 | 
           efrain | 
           24 | 
               And I click on the "No auto-link" button for the "Description" TinyMCE editor
  | 
        
        
           | 11 | 
           efrain | 
           25 | 
               And the field "Description" matches value "<p>https://moodle.org</p>"
  | 
        
        
           | 1 | 
           efrain | 
           26 | 
              | 
        
        
           | 11 | 
           efrain | 
           27 | 
             @javascript
  | 
        
        
            | 
            | 
           28 | 
             Scenario: Add and remove auto-link prevention to simple text
  | 
        
        
            | 
            | 
           29 | 
               Given I open my profile in edit mode
  | 
        
        
            | 
            | 
           30 | 
               And I set the field "Description" to "Some text"
  | 
        
        
            | 
            | 
           31 | 
               # Add auto-link prevention.
  | 
        
        
            | 
            | 
           32 | 
               And I select the "p" element in position "0" of the "Description" TinyMCE editor
  | 
        
        
            | 
            | 
           33 | 
               When I click on the "No auto-link" button for the "Description" TinyMCE editor
  | 
        
        
            | 
            | 
           34 | 
               Then the field "Description" matches value "<p><span class='nolink'>Some text</span></p>"
  | 
        
        
           | 1 | 
           efrain | 
           35 | 
               # Remove auto-link prevention.
  | 
        
        
            | 
            | 
           36 | 
               And I select the "span" element in position "0" of the "Description" TinyMCE editor
  | 
        
        
            | 
            | 
           37 | 
               And I click on the "No auto-link" button for the "Description" TinyMCE editor
  | 
        
        
           | 11 | 
           efrain | 
           38 | 
               And the field "Description" matches value "<p>Some text</p>"
  | 
        
        
           | 1441 | 
           ariadna | 
           39 | 
              | 
        
        
            | 
            | 
           40 | 
             @javascript
  | 
        
        
            | 
            | 
           41 | 
             Scenario: Permissions can be configured to control access to no auto-link
  | 
        
        
            | 
            | 
           42 | 
               Given the following "users" exist:
  | 
        
        
            | 
            | 
           43 | 
                 | username | firstname | lastname | email                |
  | 
        
        
            | 
            | 
           44 | 
                 | teacher1 | Teacher   | 1        | teacher1@example.com |
  | 
        
        
            | 
            | 
           45 | 
                 | teacher2 | Teacher   | 2        | teacher2@example.com |
  | 
        
        
            | 
            | 
           46 | 
               And the following "courses" exist:
  | 
        
        
            | 
            | 
           47 | 
                 | fullname | shortname | format |
  | 
        
        
            | 
            | 
           48 | 
                 | Course 1 | C1        | topics |
  | 
        
        
            | 
            | 
           49 | 
               And the following "roles" exist:
  | 
        
        
            | 
            | 
           50 | 
                 | name           | shortname | description         | archetype      |
  | 
        
        
            | 
            | 
           51 | 
                 | Custom teacher | custom1   | Limited permissions | editingteacher |
  | 
        
        
            | 
            | 
           52 | 
               And the following "course enrolments" exist:
  | 
        
        
            | 
            | 
           53 | 
                 | user     | course | role           |
  | 
        
        
            | 
            | 
           54 | 
                 | teacher1 | C1     | editingteacher |
  | 
        
        
            | 
            | 
           55 | 
                 | teacher2 | C1     | custom1        |
  | 
        
        
            | 
            | 
           56 | 
               And the following "activity" exists:
  | 
        
        
            | 
            | 
           57 | 
                 | activity | assign          |
  | 
        
        
            | 
            | 
           58 | 
                 | course   | C1              |
  | 
        
        
            | 
            | 
           59 | 
                 | name     | Test assignment |
  | 
        
        
            | 
            | 
           60 | 
               And the following "permission overrides" exist:
  | 
        
        
            | 
            | 
           61 | 
                 | capability          | permission | role    | contextlevel | reference |
  | 
        
        
            | 
            | 
           62 | 
                 | tiny/noautolink:use | Prohibit   | custom1 | Course       | C1        |
  | 
        
        
            | 
            | 
           63 | 
               # Check plugin access as a role with prohibited permissions.
  | 
        
        
            | 
            | 
           64 | 
               And I log in as "teacher2"
  | 
        
        
            | 
            | 
           65 | 
               And I am on the "Test assignment" Activity page
  | 
        
        
            | 
            | 
           66 | 
               And I navigate to "Settings" in current page administration
  | 
        
        
            | 
            | 
           67 | 
               When I click on the "Format" menu item for the "Activity instructions" TinyMCE editor
  | 
        
        
            | 
            | 
           68 | 
               Then I should not see "No auto-link"
  | 
        
        
            | 
            | 
           69 | 
               # Check plugin access as a role with allowed permissions.
  | 
        
        
            | 
            | 
           70 | 
               And I log in as "teacher1"
  | 
        
        
            | 
            | 
           71 | 
               And I am on the "Test assignment" Activity page
  | 
        
        
            | 
            | 
           72 | 
               And I navigate to "Settings" in current page administration
  | 
        
        
            | 
            | 
           73 | 
               And I click on the "Format" menu item for the "Activity instructions" TinyMCE editor
  | 
        
        
            | 
            | 
           74 | 
               And I should see "No auto-link"
  |