MDL-79107 editor_tiny: Inform Behat of field type

This commit is contained in:
Andrew Nicols 2023-08-22 22:10:05 +08:00 committed by Jun Pataleta
parent 4adae8e489
commit 4ce427c2ac
No known key found for this signature in database
GPG Key ID: F83510526D99E2C7
4 changed files with 35 additions and 2 deletions

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

View File

@ -512,11 +512,15 @@ export const setupForTarget = async(target, options = {}) => {
// At this point any plugin which has configuration options registered will have them applied for this instance.
const [editor] = await tinyMCE.init(instanceConfig);
// Update the textarea when the editor to set the field type for Behat.
target.dataset.fieldtype = 'editor';
// Store the editor instance in the instanceMap and register a listener on removal to remove it from the map.
instanceMap.set(target, editor);
editor.on('remove', ({target}) => {
// Handle removal of the editor from the map on destruction.
instanceMap.delete(target.targetElm);
target.dataset.fieldtype = null;
});
// If the editor is part of a form, also listen to the jQuery submit event.

View File

@ -0,0 +1,29 @@
@editor_tiny @qtype_essay @javascript
Feature: Set tiny editor values when the editor is not in a form
As an automated tester
In order to use a non-form editor
I need to set values
Background:
Given the following "users" exist:
| username |
| teacher |
And the following "courses" exist:
| fullname | shortname | category |
| Course 1 | C1 | 0 |
And the following "course enrolments" exist:
| user | course | role |
| teacher | C1 | editingteacher |
And the following "question categories" exist:
| contextlevel | reference | name |
| Course | C1 | Test questions |
And the following "questions" exist:
| questioncategory | qtype | name | template |
| Test questions | essay | essay | editorfilepicker |
Scenario: Preview an Essay question that uses the HTML editor with embedded files.
When I am on the "essay" "core_question > preview" page logged in as teacher
And I expand all fieldsets
And I set the following fields to these values:
| Answer text Question 1 | <p>The <b>cat</b> sat on the mat. Then it ate a <b>frog</b>.</p> |
And I press "Submit and finish"