Skip to content

Commit

Permalink
Review fixes: extract helpers method, remove tools modifications from…
Browse files Browse the repository at this point in the history
… history.
  • Loading branch information
Mateusz Samsel committed Nov 20, 2017
1 parent 372cb96 commit e682277
Show file tree
Hide file tree
Showing 5 changed files with 30 additions and 20 deletions.
19 changes: 19 additions & 0 deletions tests/plugins/inlinetoolbar/_helpers/default.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
/* exported replaceAppendStyleSheet, convertRgbaToRgb */

'use strict';

function replaceAppendStyleSheet() {
// Overwrite prototype to simulate missing css file.
var oldFn = CKEDITOR.dom.document.prototype.appendStyleSheet;
CKEDITOR.dom.document.prototype.appendStyleSheet = function( cssFileUrl ) {
// Simulate missing css in skin.
if ( !cssFileUrl.match( /(inlinetoolbar|balloonpanel)\.css/ ) ) {
oldFn.call( CKEDITOR.document, cssFileUrl );
}
};
}

function convertRgbaToRgb( input ) {
var re = /^rgba\(\s*\d+\s*,\s*\d+\s*,\s*\d+\s*,\s*\d+\s*\)$/gi;
return re.test( input ) ? input.replace( /,\s*?\d+?\s*?\)$/, ')' ).replace( 'rgba(', 'rgb(' ) : input;
}
14 changes: 4 additions & 10 deletions tests/plugins/inlinetoolbar/cssdefault.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
/* bender-tags: inlinetoolbar */
/* bender-ckeditor-plugins: toolbar,inlinetoolbar,basicstyles */
/* bender-include: ./_helpers/default.js */
/* global replaceAppendStyleSheet */

( function() {
'use strict';
Expand Down Expand Up @@ -32,17 +34,9 @@
}
};

// We need to set up skin at the very beginning before files start to load.
// We need to set up skin at the very beginning before loading files.
CKEDITOR.skinName = 'moono';

// Overwrite prototype to simulate missing css file.
var oldFn = CKEDITOR.dom.document.prototype.appendStyleSheet;
CKEDITOR.dom.document.prototype.appendStyleSheet = function( cssFileUrl ) {
// Simulate missing css in skin.
if ( !cssFileUrl.match( /(inlinetoolbar|balloonpanel)\.css/ ) ) {
oldFn.call( CKEDITOR.document, cssFileUrl );
}
};
replaceAppendStyleSheet();

var tests = {
'test check default.css file usage when skin miss adequate css': function( editor ) {
Expand Down
6 changes: 4 additions & 2 deletions tests/plugins/inlinetoolbar/cssskin.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
/* bender-tags: inlinetoolbar */
/* bender-ckeditor-plugins: toolbar,inlinetoolbar,basicstyles */
/* bender-include: ./_helpers/default.js */
/* global convertRgbaToRgb */

( function() {
'use strict';
Expand Down Expand Up @@ -32,7 +34,7 @@
}
};

// We need to set up skin at the very beginning befor files start to load.
// We need to set up skin at the very beginning before loading files.
CKEDITOR.skinName = 'moono';

var tests = {
Expand All @@ -51,7 +53,7 @@
panel.attach( editor.editable().findOne( 'p' ) );
// IE use cke_reset styles, that' why there is transparent.
assert.areSame( CKEDITOR.env.ie ? 'background-color:transparent;' : 'background-color:#000000;',
CKEDITOR.tools.normalizeCssText( 'background-color:' + panel._view.parts.panel.getComputedStyle( 'background-color' ) + ';' ),
CKEDITOR.tools.normalizeCssText( 'background-color:' + convertRgbaToRgb( panel._view.parts.panel.getComputedStyle( 'background-color' ) ) + ';' ),
'Background color is incorrect.' );
}
};
Expand Down
8 changes: 1 addition & 7 deletions tests/plugins/inlinetoolbar/manual/fallbackstyles.html
Original file line number Diff line number Diff line change
Expand Up @@ -61,13 +61,7 @@
}

// Overwrite prototype to simulate missing css file.
var oldFn = CKEDITOR.dom.document.prototype.appendStyleSheet;
CKEDITOR.dom.document.prototype.appendStyleSheet = function( cssFileUrl ) {
// Simulate missing css in skin.
if ( !cssFileUrl.match( /(inlinetoolbar|balloonpanel)\.css/ ) ) {
oldFn.call( CKEDITOR.document, cssFileUrl );
}
};
replaceAppendStyleSheet()

CKEDITOR.replace( 'editor1', {
skin: 'moono',
Expand Down
3 changes: 2 additions & 1 deletion tests/plugins/inlinetoolbar/manual/fallbackstyles.md
Original file line number Diff line number Diff line change
@@ -1,13 +1,14 @@
@bender-ui: collapsed
@bender-tags: 4.8.0, bug, inlinetoolbar
@bender-ckeditor-plugins: wysiwygarea,toolbar,basicstyles,floatingspace,inlinetoolbar,link,image,resize,language,stylescombo
@bender-include: ../_helpers/default.js

Perform below steps in both editors:
1. Click image.
1. Check how inline toolbar looks like.

_Note:_ Please be aware that buttons in inline toolbar use main skin.

**Expected:** Inline toolbar background should be different from used skin (fallback css should be load).
**Expected:** Inline toolbar background should be different from used skin (fallback `default.css` should be loaded).

**Unexpected:** Inline toolbar is not visible. Inline toolbar has the same skin as editor (grey gradient at ballon background).

0 comments on commit e682277

Please sign in to comment.