Proyectos de Subversion Moodle

Rev

Ir a la última revisión | | Ultima modificación | Ver Log |

Rev Autor Línea Nro. Línea
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 "blocks" exist:
25
      | blockname     | contextlevel | reference | pagetypepattern | defaultregion |
26
      | private_files | System       | 1         | my-index        | side-post     |
27
    And the following "user private files" exist:
28
      | user  | filepath                       | filename    |
29
      | admin | lib/tests/fixtures/gd-logo.png | gd-logo.png |
30
    And I log in as "admin"
31
    And I navigate to "Courses > Default settings > Course custom fields" in site administration
32
    And I click on "Add a new custom field" "link"
33
    And I click on "Text area" "link"
34
    And I set the following fields to these values:
35
      | Name       | Test field |
36
      | Short name | testfield  |
37
    # Embed the image into Default value.
38
    And I click on "Image" "button" in the "Default value" "form_row"
39
    And I click on "Browse repositories" "button"
40
    And I click on "Private files" "link" in the ".fp-repo-area" "css_element"
41
    And I click on "gd-logo.png" "link"
42
    And I click on "Select this file" "button"
43
    And I set the field "How would you describe this image to someone who can't see it:" to "Example"
44
    And I click on "Save" "button" in the "Image details" "dialogue"
45
    And I click on "Save changes" "button" in the "Adding a new Text area" "dialogue"
46
    And I log out
47
 
48
  Scenario: For the courses that existed before the custom field was created the default value is displayed
49
    When I am on site homepage
50
    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"
51
 
52
  Scenario: Teacher will see textarea default value when editing a course created before custom field was created
53
     # Teacher will see the image when editing existing course.
54
    When I log in as "teacher"
55
    And I am on "Course 1" course homepage
56
    And I navigate to "Settings" in current page administration
57
    And I expand all fieldsets
58
    And I switch to the "Test field" TinyMCE editor iframe
59
    Then "//img[contains(@src, 'draftfile.php') and contains(@src, '/gd-logo.png') and @alt='Example']" "xpath_element" should exist
60
    And I switch to the main frame
61
    # Save the course without changing the default value.
62
    And I press "Save and display"
63
    And I log out
64
    # Now the same image is displayed as "value" and not as "defaultvalue".
65
    And I am on site homepage
66
    Then "//img[contains(@src, '/customfield_textarea/defaultvalue/')]" "xpath_element" should not exist
67
    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"
68
 
69
  Scenario: Manager can create a course and the default value for textarea custom field will apply.
70
    When I log in as "manager"
71
    And I go to the courses management page
72
    And I click on "Create new course" "link" in the "#course-listing" "css_element"
73
    And I set the following fields to these values:
74
      | Course full name      | Course 2     |
75
      | Course short name     | C2           |
76
    And I expand all fieldsets
77
    And I switch to the "Test field" TinyMCE editor iframe
78
    Then "//img[contains(@src, 'draftfile.php') and contains(@src, '/gd-logo.png') and @alt='Example']" "xpath_element" should exist
79
    And I switch to the main frame
80
    And I press "Save and display"
81
    And I log out
82
    # Now the same image is displayed as "value" and not as "defaultvalue".
83
    And I am on site homepage
84
    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"