1 |
efrain |
1 |
@customfield @customfield_textarea @javascript @editor_tiny
|
|
|
2 |
Feature: Default value for the textarea custom field can contain images
|
|
|
3 |
In order to see images on custom fields
|
|
|
4 |
As a manager
|
|
|
5 |
I need to be able to add images to the default value
|
|
|
6 |
|
|
|
7 |
Background:
|
|
|
8 |
Given the following "users" exist:
|
|
|
9 |
| username | firstname | lastname | email |
|
|
|
10 |
| teacher | Teacher | 1 | teacher1@example.com |
|
|
|
11 |
| manager | Manager | 1 | manager1@example.com |
|
|
|
12 |
And the following "courses" exist:
|
|
|
13 |
| fullname | shortname | format |
|
|
|
14 |
| Course 1 | C1 | topics |
|
|
|
15 |
And the following "course enrolments" exist:
|
|
|
16 |
| user | course | role |
|
|
|
17 |
| teacher | C1 | editingteacher |
|
|
|
18 |
And the following "system role assigns" exist:
|
|
|
19 |
| user | course | role |
|
|
|
20 |
| manager | Acceptance test site | manager |
|
|
|
21 |
And the following "custom field categories" exist:
|
|
|
22 |
| name | component | area | itemid |
|
|
|
23 |
| Category for test | core_course | course | 0 |
|
|
|
24 |
And the following "user private files" exist:
|
11 |
efrain |
25 |
| user | filepath |
|
|
|
26 |
| admin | lib/tests/fixtures/gd-logo.png |
|
1 |
efrain |
27 |
And I log in as "admin"
|
|
|
28 |
And I navigate to "Courses > Default settings > Course custom fields" in site administration
|
|
|
29 |
And I click on "Add a new custom field" "link"
|
|
|
30 |
And I click on "Text area" "link"
|
|
|
31 |
And I set the following fields to these values:
|
|
|
32 |
| Name | Test field |
|
|
|
33 |
| Short name | testfield |
|
|
|
34 |
# Embed the image into Default value.
|
|
|
35 |
And I click on "Image" "button" in the "Default value" "form_row"
|
|
|
36 |
And I click on "Browse repositories" "button"
|
|
|
37 |
And I click on "Private files" "link" in the ".fp-repo-area" "css_element"
|
|
|
38 |
And I click on "gd-logo.png" "link"
|
|
|
39 |
And I click on "Select this file" "button"
|
11 |
efrain |
40 |
And I set the field "How would you describe this image to someone who can't see it?" to "Example"
|
1 |
efrain |
41 |
And I click on "Save" "button" in the "Image details" "dialogue"
|
|
|
42 |
And I click on "Save changes" "button" in the "Adding a new Text area" "dialogue"
|
|
|
43 |
And I log out
|
|
|
44 |
|
|
|
45 |
Scenario: For the courses that existed before the custom field was created the default value is displayed
|
|
|
46 |
When I am on site homepage
|
|
|
47 |
Then the image at "//*[contains(@class, 'frontpage-course-list-all')]//*[contains(@class, 'customfield_textarea')]//img[contains(@src, 'pluginfile.php') and contains(@src, '/customfield_textarea/defaultvalue/') and @alt='Example']" "xpath_element" should be identical to "lib/tests/fixtures/gd-logo.png"
|
|
|
48 |
|
|
|
49 |
Scenario: Teacher will see textarea default value when editing a course created before custom field was created
|
|
|
50 |
# Teacher will see the image when editing existing course.
|
|
|
51 |
When I log in as "teacher"
|
|
|
52 |
And I am on "Course 1" course homepage
|
|
|
53 |
And I navigate to "Settings" in current page administration
|
|
|
54 |
And I expand all fieldsets
|
|
|
55 |
And I switch to the "Test field" TinyMCE editor iframe
|
|
|
56 |
Then "//img[contains(@src, 'draftfile.php') and contains(@src, '/gd-logo.png') and @alt='Example']" "xpath_element" should exist
|
|
|
57 |
And I switch to the main frame
|
|
|
58 |
# Save the course without changing the default value.
|
|
|
59 |
And I press "Save and display"
|
|
|
60 |
And I log out
|
|
|
61 |
# Now the same image is displayed as "value" and not as "defaultvalue".
|
|
|
62 |
And I am on site homepage
|
|
|
63 |
Then "//img[contains(@src, '/customfield_textarea/defaultvalue/')]" "xpath_element" should not exist
|
|
|
64 |
And the image at "//*[contains(@class, 'frontpage-course-list-all')]//*[contains(@class, 'customfield_textarea')]//img[contains(@src, 'pluginfile.php') and contains(@src, '/customfield_textarea/value/') and @alt='Example']" "xpath_element" should be identical to "lib/tests/fixtures/gd-logo.png"
|
|
|
65 |
|
|
|
66 |
Scenario: Manager can create a course and the default value for textarea custom field will apply.
|
|
|
67 |
When I log in as "manager"
|
|
|
68 |
And I go to the courses management page
|
|
|
69 |
And I click on "Create new course" "link" in the "#course-listing" "css_element"
|
|
|
70 |
And I set the following fields to these values:
|
|
|
71 |
| Course full name | Course 2 |
|
|
|
72 |
| Course short name | C2 |
|
|
|
73 |
And I expand all fieldsets
|
|
|
74 |
And I switch to the "Test field" TinyMCE editor iframe
|
|
|
75 |
Then "//img[contains(@src, 'draftfile.php') and contains(@src, '/gd-logo.png') and @alt='Example']" "xpath_element" should exist
|
|
|
76 |
And I switch to the main frame
|
|
|
77 |
And I press "Save and display"
|
|
|
78 |
And I log out
|
|
|
79 |
# Now the same image is displayed as "value" and not as "defaultvalue".
|
|
|
80 |
And I am on site homepage
|
|
|
81 |
Then the image at "//*[contains(@class, 'frontpage-course-list-all')]//*[contains(@class, 'customfield_textarea')]//img[contains(@src, 'pluginfile.php') and contains(@src, '/customfield_textarea/value/') and @alt='Example']" "xpath_element" should be identical to "lib/tests/fixtures/gd-logo.png"
|