-
Notifications
You must be signed in to change notification settings - Fork 2.5k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add custom detach editor test for mobile
- Loading branch information
Showing
4 changed files
with
137 additions
and
0 deletions.
There are no files selected for viewing
49 changes: 49 additions & 0 deletions
49
tests/core/creators/manual/detachedcustomcallbackmobile.html
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,49 @@ | ||
<div id="message"></div> | ||
<button id="startButton">Try to create editor</button> | ||
<button id="attachButton">Invoke config callback to finish editor creation</button> | ||
<div> | ||
<div id="editor"> | ||
<p>Lorem ipsum dolor sit amet.</p> | ||
</div> | ||
</div> | ||
|
||
<script> | ||
if ( !bender.tools.env.mobile ) { | ||
bender.ignore(); | ||
} | ||
|
||
var editor = document.getElementById( 'editor' ), | ||
attachButton = CKEDITOR.document.getById( 'attachButton' ), | ||
startButton = CKEDITOR.document.getById( 'startButton' ), | ||
messageElement = CKEDITOR.document.getById( 'message' ), | ||
editorParent = editor.parentNode, | ||
editorCreationCallback; | ||
|
||
editorParent.removeChild( editor ); | ||
|
||
startButton.on( 'click', function() { | ||
CKEDITOR.replace( editor, { | ||
delayIfDetached: true, | ||
delayIfDetached_callback: registerCallback, | ||
on: { | ||
instanceReady: function() { | ||
messageElement.setHtml( 'Editor is ready!' ); | ||
} | ||
} | ||
} ); | ||
|
||
messageElement.setHtml( 'Creation attempt finished. Callback is ready to use.' ); | ||
} ); | ||
|
||
attachButton.on( 'click', function() { | ||
editorParent.appendChild( editor ); | ||
|
||
messageElement.setHtml( 'Editor attached to DOM' ); | ||
|
||
editorCreationCallback(); | ||
} ); | ||
|
||
function registerCallback( editorCreationFunc ) { | ||
editorCreationCallback = editorCreationFunc; | ||
} | ||
</script> |
16 changes: 16 additions & 0 deletions
16
tests/core/creators/manual/detachedcustomcallbackmobile.md
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,16 @@ | ||
@bender-tags: 4.17.0, feature, 4461 | ||
@bender-ui: collapsed | ||
@bender-ckeditor-plugins: toolbar, wysiwygarea, sourcearea, undo, clipboard, basicstyles, elementspath | ||
|
||
1. Click `Try to create editor` button. | ||
2. Click the second button to attach editor to DOM element and invoke config callback to finish editor creation. | ||
|
||
**Expected** | ||
* Editor is created. | ||
* Editor contains initial data. | ||
* Editor data is editable. | ||
|
||
**Unexpected** | ||
* Editor isn't created. | ||
* Editor data is empty. | ||
* Editor data is not editable. |
56 changes: 56 additions & 0 deletions
56
tests/core/creators/manual/detachedcustomintervalmobile.html
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,56 @@ | ||
<div id="message"></div> | ||
<button id="startButton">Start Test</button> | ||
<span id="testTimer"></span> | ||
|
||
<div> | ||
<div id="editor"> | ||
<p>Lorem ipsum dolor sit amet.</p> | ||
</div> | ||
</div> | ||
|
||
<script> | ||
if ( !bender.tools.env.mobile ) { | ||
bender.ignore(); | ||
} | ||
|
||
var editorElement = document.getElementById( 'editor' ), | ||
startButton = CKEDITOR.document.getById( 'startButton' ), | ||
timerElement = CKEDITOR.document.getById( 'testTimer' ), | ||
messageElement = CKEDITOR.document.getById( 'message' ), | ||
editorParent = editorElement.parentNode, | ||
waitTime = 3000, | ||
timerInterval = 50, | ||
timerIntervalToken; | ||
|
||
startButton.on( 'click', function ( evt ) { | ||
evt && evt.removeListener(); | ||
|
||
timerIntervalToken = setInterval( function() { | ||
waitTime -= timerInterval; | ||
if ( waitTime <= 0 ) { | ||
messageElement.setHtml( 'Editor is going to be created...' ); | ||
|
||
waitTime = 0; | ||
clearInterval( timerIntervalToken ); | ||
} | ||
|
||
timerElement.setText( waitTime + 'ms'); | ||
}, timerInterval ); | ||
|
||
editorParent.removeChild( editorElement ); | ||
|
||
CKEDITOR.tools.setTimeout( function() { | ||
editorParent.appendChild( editorElement ); | ||
}, 50 ); | ||
|
||
CKEDITOR.replace( editorElement, { | ||
delayIfDetached: true, | ||
delayIfDetached_interval: waitTime, | ||
on: { | ||
instanceReady: function() { | ||
messageElement.setHtml( 'Editor is ready!' ); | ||
} | ||
} | ||
} ); | ||
} ); | ||
</script> |
16 changes: 16 additions & 0 deletions
16
tests/core/creators/manual/detachedcustomintervalmobile.md
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,16 @@ | ||
@bender-tags: 4.17.0, feature, 4461 | ||
@bender-ui: collapsed | ||
@bender-ckeditor-plugins: toolbar, wysiwygarea, sourcearea, undo, clipboard, basicstyles, elementspath | ||
|
||
1. Click the button to start the test. | ||
2. Wait three seconds for editor creation. | ||
|
||
**Expected** | ||
* Editor is created. | ||
* Editor contains initial data. | ||
* Editor data is editable. | ||
|
||
**Unexpected** | ||
* Editor isn't created. | ||
* Editor data is empty. | ||
* Editor data is not editable. |