11 |
efrain |
1 |
@editor @editor_tiny @tiny_autosave
|
1 |
efrain |
2 |
Feature: Tiny editor autosave
|
|
|
3 |
In order to prevent data loss
|
|
|
4 |
As a content creator
|
|
|
5 |
I need my content to be saved automatically
|
|
|
6 |
|
|
|
7 |
Background:
|
|
|
8 |
Given the following "courses" exist:
|
|
|
9 |
| fullname | shortname | category | groupmode | description | summaryformat |
|
|
|
10 |
| Course 1 | C1 | 0 | 1 | | 1 |
|
|
|
11 |
And the following "users" exist:
|
|
|
12 |
| username | firstname | lastname | email |
|
|
|
13 |
| teacher1 | Teacher | 1 | teacher1@example.com |
|
|
|
14 |
| teacher2 | Teacher | 2 | teacher2@example.com |
|
|
|
15 |
And the following "course enrolments" exist:
|
|
|
16 |
| user | course | role |
|
|
|
17 |
| teacher1 | C1 | editingteacher |
|
|
|
18 |
| teacher2 | C1 | editingteacher |
|
|
|
19 |
|
|
|
20 |
@javascript
|
|
|
21 |
Scenario: Restore a draft on user profile page
|
|
|
22 |
Given I log in as "teacher1"
|
|
|
23 |
And I open my profile in edit mode
|
|
|
24 |
And I set the field "Description" to "This is my draft"
|
|
|
25 |
And I log out
|
|
|
26 |
When I log in as "teacher1"
|
|
|
27 |
And I open my profile in edit mode
|
|
|
28 |
Then the field "Description" matches value "This is my draft"
|
|
|
29 |
|
|
|
30 |
@javascript
|
|
|
31 |
Scenario: Do not restore a draft if files have been modified
|
11 |
efrain |
32 |
Given the following "user private file" exists:
|
|
|
33 |
| user | teacher2 |
|
|
|
34 |
| filepath | lib/editor/tiny/tests/behat/fixtures/tinyscreenshot.png |
|
|
|
35 |
And I am on the "Course 1" course page logged in as teacher1
|
1 |
efrain |
36 |
And I navigate to "Settings" in current page administration
|
|
|
37 |
And I set the field "Course summary" to "This is my draft"
|
|
|
38 |
And I log out
|
11 |
efrain |
39 |
And I am on the "Course 1" course page logged in as teacher2
|
1 |
efrain |
40 |
And I navigate to "Settings" in current page administration
|
|
|
41 |
And I set the field "Course summary" to "<p>Image test</p>"
|
|
|
42 |
And I select the "p" element in position "1" of the "Course summary" TinyMCE editor
|
|
|
43 |
And I click on the "Image" button for the "Course summary" TinyMCE editor
|
|
|
44 |
And I click on "Browse repositories" "button"
|
|
|
45 |
And I click on "Private files" "link" in the ".fp-repo-area" "css_element"
|
|
|
46 |
And I click on "tinyscreenshot.png" "link"
|
|
|
47 |
And I click on "Select this file" "button"
|
11 |
efrain |
48 |
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 |
49 |
And I click on "Save" "button" in the "Image details" "dialogue"
|
|
|
50 |
And I click on "Save and display" "button"
|
|
|
51 |
When I am on the "Course 1" course page logged in as teacher1
|
|
|
52 |
And I navigate to "Settings" in current page administration
|
|
|
53 |
Then I should not see "This is my draft"
|
|
|
54 |
|
|
|
55 |
@javascript
|
|
|
56 |
Scenario: Do not restore a draft if text has been modified
|
|
|
57 |
Given I am on the "Course 1" course page logged in as teacher1
|
|
|
58 |
And I navigate to "Settings" in current page administration
|
|
|
59 |
And I set the field "Course summary" to "This is my draft"
|
|
|
60 |
And I am on the "Course 1" course page logged in as teacher2
|
|
|
61 |
And I navigate to "Settings" in current page administration
|
|
|
62 |
And I set the field "Course summary" to "Modified text"
|
|
|
63 |
And I click on "Save and display" "button"
|
|
|
64 |
When I am on the "Course 1" course page logged in as teacher1
|
|
|
65 |
And I navigate to "Settings" in current page administration
|
|
|
66 |
Then I should not see "This is my draft" in the "#id_summary_editor" "css_element"
|
|
|
67 |
And the field "Course summary" matches value "<p>Modified text</p>"
|
|
|
68 |
|
|
|
69 |
@javascript
|
|
|
70 |
Scenario: Draft should not be restored if the form was submitted via Javascript
|
|
|
71 |
Given I am on the "Course 1" course page logged in as teacher1
|
|
|
72 |
And I follow "Calendar" in the user menu
|
|
|
73 |
And I click on "New event" "button"
|
|
|
74 |
And I click on "Show more..." "link" in the "New event" "dialogue"
|
|
|
75 |
And I set the field "Event title" to "Test course event"
|
|
|
76 |
And I set the field "Description" to "This is my draft"
|
|
|
77 |
And I click on "Save" "button"
|
|
|
78 |
And I click on "New event" "button"
|
|
|
79 |
When I click on "Show more..." "link" in the "New event" "dialogue"
|
|
|
80 |
Then the field "Description" matches value ""
|
1441 |
ariadna |
81 |
|
|
|
82 |
@javascript
|
|
|
83 |
Scenario: Permissions can be configured to control access to autosave
|
|
|
84 |
Given the following "roles" exist:
|
|
|
85 |
| name | shortname | description | archetype |
|
|
|
86 |
| Custom teacher | custom1 | Limited permissions | editingteacher |
|
|
|
87 |
And the following "users" exist:
|
|
|
88 |
| username | firstname | lastname | email |
|
|
|
89 |
| teacher3 | Teacher | 3 | teacher3@example.com |
|
|
|
90 |
And the following "course enrolments" exist:
|
|
|
91 |
| user | course | role |
|
|
|
92 |
| teacher3 | C1 | custom1 |
|
|
|
93 |
And the following "activity" exists:
|
|
|
94 |
| activity | assign |
|
|
|
95 |
| course | C1 |
|
|
|
96 |
| name | Test assignment |
|
|
|
97 |
And the following "permission overrides" exist:
|
|
|
98 |
| capability | permission | role | contextlevel | reference |
|
|
|
99 |
| tiny/autosave:use | Prohibit | custom1 | Course | C1 |
|
|
|
100 |
# Check plugin access as a role with prohibited permissions.
|
|
|
101 |
And I log in as "teacher3"
|
|
|
102 |
And I am on the "Test assignment" Activity page
|
|
|
103 |
And I navigate to "Settings" in current page administration
|
|
|
104 |
And I set the field "Activity instructions" to "This is my draft"
|
|
|
105 |
And I log out
|
|
|
106 |
And I log in as "teacher3"
|
|
|
107 |
And I am on the "Test assignment" Activity page
|
|
|
108 |
When I navigate to "Settings" in current page administration
|
|
|
109 |
Then the field "Activity instructions" matches value ""
|
|
|
110 |
# Check plugin access as a role with allowed permissions.
|
|
|
111 |
And I log in as "teacher1"
|
|
|
112 |
And I am on the "Test assignment" Activity page
|
|
|
113 |
And I navigate to "Settings" in current page administration
|
|
|
114 |
And I set the field "Activity instructions" to "This is my draft"
|
|
|
115 |
And I log out
|
|
|
116 |
And I log in as "teacher1"
|
|
|
117 |
And I am on the "Test assignment" Activity page
|
|
|
118 |
And I navigate to "Settings" in current page administration
|
|
|
119 |
And the field "Activity instructions" matches value "This is my draft"
|