Skip to content

Commit

Permalink
Manual tests for XHR upload.
Browse files Browse the repository at this point in the history
  • Loading branch information
Mateusz Samsel committed Dec 18, 2017
1 parent 4db9cc5 commit c3c075b
Show file tree
Hide file tree
Showing 2 changed files with 68 additions and 0 deletions.
50 changes: 50 additions & 0 deletions tests/plugins/filebrowser/manual/uploadxhr.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,50 @@
<textarea id="classic">

</textarea>

<div id="output" style="background-color:lightgreen;"></div>

<script>
var xhr, requests;

CKEDITOR.on( 'instanceLoaded', function() {
if ( !CKEDITOR.fileTools.isFileUploadSupported ) {
bender.ignore();
} else {
// Mock XHR
xhr = sinon.useFakeXMLHttpRequest();
requests = [];
xhr.onCreate = function( xhr ) {
requests.push( xhr );
};
window.onunload = function() {
xhr.restore();
server.restore();
}
}
} );

var classic = CKEDITOR.replace( 'classic', {
xmlHttpRequestHeaders: {
'hello': 'world',
'foo': 'bar'
},
filebrowserUploadUrl: 'fake-url'
} );

// Display XHR details when CKEDITOR process entire request.
classic.on( 'fileUploadRequest', function( evt ) {
var output = document.getElementById( 'output' );
var outputString = CKEDITOR.tools.array.reduce( requests, function( acc, item ) {
var line = '';
for ( header in item.requestHeaders ) {
if ( item.requestHeaders.hasOwnProperty( header ) ) {
line += '| <code>header: ' + header + ', value: ' + item.requestHeaders[ header ] + '</code> |';
}
}
acc += '<li>' + line + '</li>';
return acc;
}, '' );
output.innerHTML = '<ol>' + outputString + '</ol>';
}, null, null, 1000 )
</script>
18 changes: 18 additions & 0 deletions tests/plugins/filebrowser/manual/uploadxhr.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
@bender-tags: 4.8.1, feature, tp3117
@bender-ui: collapsed
@bender-ckeditor-plugins: wysiwygarea, toolbar, filebrowser, filetools, image, link, flash

----
1. Open image dialog
2. Go to upload tab
3. Select some image and send it to server
4. Close dialog (There might appear warning that image url is not set up)

Repeat those steps for Link and Flash plugin.

_Note:_ When new upload request is made, it should be visible as separate line below.

**Expected:** Below editor will appear green div with listed headers attempted to send. There are 2 headers in single line:
`hello: world, foo: bar`.

**Unexpected:** Headers are not listed below.

0 comments on commit c3c075b

Please sign in to comment.