diff --git a/lib/behat/form_field/behat_form_editor.php b/lib/behat/form_field/behat_form_editor.php index 3d5df09af66..96e8c0a92ae 100644 --- a/lib/behat/form_field/behat_form_editor.php +++ b/lib/behat/form_field/behat_form_editor.php @@ -51,6 +51,8 @@ class behat_form_editor extends behat_form_textarea { $editorid = $this->field->getAttribute('id'); if ($this->running_javascript()) { $value = addslashes($value); + // This will be transported in JSON, which doesn't allow newlines in strings, so we must escape them. + $value = str_replace("\n", "\\n", $value); $js = ' (function() { var editor = Y.one(document.getElementById("'.$editorid.'editable")); diff --git a/lib/editor/atto/tests/behat/clean.feature b/lib/editor/atto/tests/behat/clean.feature new file mode 100644 index 00000000000..aea3fee77bd --- /dev/null +++ b/lib/editor/atto/tests/behat/clean.feature @@ -0,0 +1,169 @@ +@editor @editor_atto @atto @editor_moodleform +Feature: Atto HTML cleanup. + In order to test html cleaning functionality, I write in a HTML atto text field. + + @javascript + Scenario: Extra UL close and orphan LI items + Given I log in as "admin" + When I open my profile in edit mode + And I click on "Show more buttons" "button" + And I click on "HTML" "button" + And I set the field "Description" to multiline: + """ +
  • A
  • +
  • B
  • + + +
  • D
  • +
  • E
  • + """ + And I click on "HTML" "button" + Then the field "Description" matches multiline: + """ +
    1. A
    2. +
    3. B
    4. +
    + + + """ + + @javascript + Scenario: Missing LI close tags, extra closing OL, missing closing UL tag + Given I log in as "admin" + When I open my profile in edit mode + And I click on "Show more buttons" "button" + And I click on "HTML" "button" + And I set the field "Description" to multiline: + """ +
      +
    1. A
    2. +
    3. B +
    +