Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
6 changed files
with
257 additions
and
3 deletions.
There are no files selected for viewing
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
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,8 @@ | ||
/* | ||
Copyright (c) 2003-2015, CKSource - Frederico Knabben. All rights reserved. | ||
For licensing, see LICENSE.md or http://ckeditor.com/license | ||
*/ | ||
CKEDITOR.plugins.setLang( 'autoembed', 'en', { | ||
embeddingInProgress: 'Trying to embed pasted URL...', | ||
embeddingFailed: 'This URL could not be automatically embedded.' | ||
} ); |
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
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
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,71 @@ | ||
/* bender-tags: editor,unit,13421 */ | ||
/* bender-ckeditor-plugins: embed,autoembed,enterkey,undo,link */ | ||
/* bender-include: ../embedbase/_helpers/tools.js */ | ||
|
||
/* global embedTools */ | ||
|
||
'use strict'; | ||
|
||
var jsonpCallback; | ||
|
||
embedTools.mockJsonp( function() { | ||
jsonpCallback.apply( this, arguments ); | ||
} ); | ||
|
||
bender.editor = { | ||
creator: 'inline' | ||
}; | ||
|
||
bender.test( { | ||
'test notifications showed when embedding is finished correctly': function() { | ||
var bot = this.editorBot, | ||
editor = bot.editor, | ||
pastedText = 'https://foo.bar/notifiacation/finish/correct', | ||
showNotificationSpy = sinon.spy( editor, 'showNotification' ); | ||
|
||
jsonpCallback = function( urlTemplate, urlParams, callback ) { | ||
resume( function() { | ||
callback( { | ||
'url': decodeURIComponent( urlParams.url ), | ||
'type': 'rich', | ||
'version': '1.0', | ||
'html': '<img src="' + decodeURIComponent( urlParams.url ) + '">' | ||
} ); | ||
|
||
showNotificationSpy.restore(); | ||
assert.isTrue( showNotificationSpy.calledOnce, 'Notification should be showed once.' ); | ||
assert.areEqual( showNotificationSpy.firstCall.returnValue.type, 'info', 'Notification should be "info" type.' ); | ||
} ); | ||
}; | ||
|
||
bot.setData( '', function() { | ||
bot.editor.focus(); | ||
this.editor.execCommand( 'paste', pastedText ); | ||
wait(); | ||
} ); | ||
}, | ||
|
||
'test notifications showed when embedding is finished with error': function() { | ||
var bot = this.editorBot, | ||
editor = bot.editor, | ||
pastedText = 'https://foo.bar/notifiacation/finish/error', | ||
showNotificationSpy = sinon.spy( editor, 'showNotification' ); | ||
|
||
jsonpCallback = function( urlTemplate, urlParams, callback, errorCallback ) { | ||
resume( function() { | ||
errorCallback(); | ||
|
||
showNotificationSpy.restore(); | ||
assert.isTrue( showNotificationSpy.calledTwice, 'Notification was showed twice.' ); | ||
assert.areEqual( showNotificationSpy.firstCall.returnValue.type, 'info', 'First notification should have "info" type.' ); | ||
assert.areEqual( showNotificationSpy.secondCall.returnValue.type, 'info', 'Second notification should have "info" type.' ); | ||
} ); | ||
}; | ||
|
||
bot.setData( '', function() { | ||
bot.editor.focus(); | ||
this.editor.execCommand( 'paste', pastedText ); | ||
wait(); | ||
} ); | ||
} | ||
} ); |
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,161 @@ | ||
/* bender-tags: editor,unit,13421 */ | ||
/* bender-ckeditor-plugins: embedbase,embed,toolbar,htmlwriter */ | ||
/* bender-include: ../widget/_helpers/tools.js, _helpers/tools.js */ | ||
/* global widgetTestsTools, embedTools */ | ||
|
||
'use strict'; | ||
|
||
bender.editors = { | ||
inline: { | ||
name: 'editor_inline', | ||
creator: 'inline' | ||
} | ||
}; | ||
|
||
var dataWithWidget = '<p>x</p><div data-oembed-url="foo" id="w1">foo</div><p>x</p>', | ||
getWidgetById = widgetTestsTools.getWidgetById, | ||
jsonpCallback; | ||
|
||
embedTools.mockJsonp( function() { | ||
jsonpCallback.apply( this, arguments ); | ||
} ); | ||
|
||
bender.test( { | ||
|
||
'test if embedding shows notifications during successful request': function() { | ||
var bot = this.editorBots.inline, | ||
editor = bot.editor, | ||
successCallbackSpy = sinon.spy(), | ||
errorCallbackSpy = sinon.spy(), | ||
createTaskSpy = sinon.spy( CKEDITOR.plugins.notificationAggregator.prototype, 'createTask' ); | ||
|
||
bot.setData( dataWithWidget, function() { | ||
var widget = getWidgetById( editor, 'w1' ); | ||
|
||
jsonpCallback = function( urlTemplate, urlParams, callback ) { | ||
resume( function() { | ||
callback( { | ||
type: 'rich', | ||
html: '<p>url:' + urlParams.url + '</p>' | ||
} ); | ||
|
||
createTaskSpy.restore(); | ||
assert.isTrue( successCallbackSpy.called, 'Success callback should be called.' ); | ||
assert.isFalse( errorCallbackSpy.called, 'Error callback should not be called.' ); | ||
assert.isTrue( createTaskSpy.calledOnce, 'Task should be created.' ); | ||
} ); | ||
}; | ||
|
||
widget.loadContent( '//show/notification', { | ||
callback: successCallbackSpy, | ||
errorCallback: errorCallbackSpy | ||
} ); | ||
|
||
wait(); | ||
} ); | ||
}, | ||
|
||
'test if embedding notifications can be blocked during successful request': function() { | ||
var bot = this.editorBots.inline, | ||
editor = bot.editor, | ||
successCallbackSpy = sinon.spy(), | ||
errorCallbackSpy = sinon.spy(), | ||
createTaskSpy = sinon.spy( CKEDITOR.plugins.notificationAggregator.prototype, 'createTask' ); | ||
|
||
bot.setData( dataWithWidget, function() { | ||
var widget = getWidgetById( editor, 'w1' ); | ||
|
||
jsonpCallback = function( urlTemplate, urlParams, callback ) { | ||
resume( function() { | ||
callback( { | ||
type: 'rich', | ||
html: '<p>url:' + urlParams.url + '</p>' | ||
} ); | ||
|
||
createTaskSpy.restore(); | ||
assert.isTrue( successCallbackSpy.called, 'Success callback should be called.' ); | ||
assert.isFalse( errorCallbackSpy.called, 'Error callback should not be called.' ); | ||
assert.isFalse( createTaskSpy.called, 'Task should not be created.' ); | ||
} ); | ||
}; | ||
|
||
widget.loadContent( '//show/no-notification', { | ||
callback: successCallbackSpy, | ||
errorCallback: errorCallbackSpy, | ||
noNotifications: true | ||
} ); | ||
|
||
wait(); | ||
} ); | ||
}, | ||
|
||
'test if embedding shows notifications during unsuccessful request': function() { | ||
var bot = this.editorBots.inline, | ||
editor = bot.editor, | ||
successCallbackSpy = sinon.spy(), | ||
errorCallbackSpy = sinon.spy(), | ||
createTaskSpy = sinon.spy( CKEDITOR.plugins.notificationAggregator.prototype, 'createTask' ), | ||
showNotificationSpy = sinon.spy( editor, 'showNotification' ); | ||
|
||
bot.setData( dataWithWidget, function() { | ||
var widget = getWidgetById( editor, 'w1' ); | ||
|
||
jsonpCallback = function( urlTemplate, urlParams, callback, errorCallback ) { | ||
resume( function() { | ||
errorCallback(); | ||
|
||
createTaskSpy.restore(); | ||
showNotificationSpy.restore(); | ||
|
||
assert.isFalse( successCallbackSpy.called, 'Success callback should not be called.' ); | ||
assert.isTrue( errorCallbackSpy.called, 'Error callback should be called.' ); | ||
assert.isTrue( createTaskSpy.calledOnce, 'Task should be created.' ); | ||
assert.isTrue( showNotificationSpy.calledOnce, 'Notification should be showed.' ); | ||
assert.areEqual( showNotificationSpy.firstCall.returnValue.type, 'warning', 'Notification should have "warning" type.' ); | ||
} ); | ||
}; | ||
|
||
widget.loadContent( '//error/show/notification', { | ||
callback: successCallbackSpy, | ||
errorCallback: errorCallbackSpy | ||
} ); | ||
|
||
wait(); | ||
} ); | ||
}, | ||
|
||
'test if embedding notifications can be blocked during unsuccessful request': function() { | ||
var bot = this.editorBots.inline, | ||
editor = bot.editor, | ||
successCallbackSpy = sinon.spy(), | ||
errorCallbackSpy = sinon.spy(), | ||
createTaskSpy = sinon.spy( CKEDITOR.plugins.notificationAggregator.prototype, 'createTask' ), | ||
showNotificationSpy = sinon.spy( editor, 'showNotification' ); | ||
|
||
bot.setData( dataWithWidget, function() { | ||
var widget = getWidgetById( editor, 'w1' ); | ||
|
||
jsonpCallback = function( urlTemplate, urlParams, callback, errorCallback ) { | ||
resume( function() { | ||
errorCallback(); | ||
|
||
createTaskSpy.restore(); | ||
showNotificationSpy.restore(); | ||
|
||
assert.isFalse( successCallbackSpy.called, 'Success callback should not be called.' ); | ||
assert.isTrue( errorCallbackSpy.called, 'Error callback should be called.' ); | ||
assert.isFalse( createTaskSpy.called, 'Task should not be created.' ); | ||
assert.isFalse( showNotificationSpy.called, 'Notification should not be showed.' ); | ||
} ); | ||
}; | ||
|
||
widget.loadContent( '//error/show/no-notification', { | ||
callback: successCallbackSpy, | ||
errorCallback: errorCallbackSpy, | ||
noNotifications: true | ||
} ); | ||
|
||
wait(); | ||
} ); | ||
} | ||
} ); |