| 1 | efrain | 1 | @editor @editor_tiny @tiny_equation
 | 
        
           |  |  | 2 | Feature: Equation editor
 | 
        
           |  |  | 3 |   To teach maths to students, I need to write equations
 | 
        
           |  |  | 4 |   | 
        
           |  |  | 5 |   @javascript
 | 
        
           |  |  | 6 |   Scenario: Create an equation using TinyMCE
 | 
        
           |  |  | 7 |     Given I log in as "admin"
 | 
        
           |  |  | 8 |     When I open my profile in edit mode
 | 
        
           |  |  | 9 |     And I set the field "Description" to "<p>Equation test</p>"
 | 
        
           |  |  | 10 |     # Set field on the bottom of page, so equation editor dialogue is visible.
 | 
        
           |  |  | 11 |     And I expand all fieldsets
 | 
        
           |  |  | 12 |     And I set the field "Picture description" to "Test"
 | 
        
           |  |  | 13 |     And I expand all toolbars for the "Description" TinyMCE editor
 | 
        
           |  |  | 14 |     And I click on the "Equation editor" button for the "Description" TinyMCE editor
 | 
        
           |  |  | 15 |     And the "class" attribute of "Edit equation using" "field" should contain "text-ltr"
 | 
        
           |  |  | 16 |     And I set the field "Edit equation using" to " = 1 \div 0"
 | 
        
           |  |  | 17 |     And I click on "\infty" "button"
 | 
        
           |  |  | 18 |     And I click on "Save equation" "button"
 | 
        
           |  |  | 19 |     And I click on "Update profile" "button"
 | 
        
           |  |  | 20 |     And I follow "Profile" in the user menu
 | 
        
           | 1441 | ariadna | 21 |     # MathJax 3.2.2 renders matemathical equation using css classes, so it will not work against the pre-rendered code like "\infty".
 | 
        
           |  |  | 22 |     # That said, we can instead check the rendered text using the rendered equation or symbol "∞".
 | 
        
           |  |  | 23 |     Then "∞" "text" should exist
 | 
        
           | 1 | efrain | 24 |   | 
        
           |  |  | 25 |   @javascript
 | 
        
           |  |  | 26 |   Scenario: Edit an equation using TinyMCE
 | 
        
           |  |  | 27 |     Given I log in as "admin"
 | 
        
           |  |  | 28 |     When I open my profile in edit mode
 | 
        
           |  |  | 29 |     And I set the field "Description" to "<p>\( \pi \)</p>"
 | 
        
           |  |  | 30 |     # Set field on the bottom of page, so equation editor dialogue is visible.
 | 
        
           |  |  | 31 |     And I expand all fieldsets
 | 
        
           |  |  | 32 |     And I set the field "Picture description" to "Test"
 | 
        
           |  |  | 33 |     And I expand all toolbars for the "Description" TinyMCE editor
 | 
        
           |  |  | 34 |     And I click on the "Equation editor" button for the "Description" TinyMCE editor
 | 
        
           |  |  | 35 |     And the "class" attribute of "Edit equation using" "field" should contain "text-ltr"
 | 
        
           |  |  | 36 |     Then the field "Edit equation using" matches value " \pi "
 | 
        
           |  |  | 37 |     And I click on "Save equation" "button"
 | 
        
           |  |  | 38 |     And the field "Description" matches value "<p>\( \pi \)</p>"
 | 
        
           | 1441 | ariadna | 39 |   | 
        
           |  |  | 40 |   @javascript
 | 
        
           |  |  | 41 |   Scenario: Permissions can be configured to control access to equation editor
 | 
        
           |  |  | 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/equation: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 "Insert" menu item for the "Activity instructions" TinyMCE editor
 | 
        
           |  |  | 68 |     Then I should not see "Equation editor"
 | 
        
           |  |  | 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 "Insert" menu item for the "Activity instructions" TinyMCE editor
 | 
        
           |  |  | 74 |     And I should see "Equation editor"
 |