|
|
@@ -15,11 +15,11 @@ import global from '@ckeditor/ckeditor5-utils/src/dom/global';
|
|
|
import { setData } from '@ckeditor/ckeditor5-engine/src/dev-utils/model';
|
|
|
import DomEventData from '@ckeditor/ckeditor5-engine/src/view/observer/domeventdata';
|
|
|
import EventInfo from '@ckeditor/ckeditor5-utils/src/eventinfo';
|
|
|
+import CKEditorError from '@ckeditor/ckeditor5-utils/src/ckeditorerror';
|
|
|
|
|
|
import MentionUI from '../src/mentionui';
|
|
|
import MentionEditing from '../src/mentionediting';
|
|
|
import MentionsView from '../src/ui/mentionsview';
|
|
|
-import CKEditorError from '@ckeditor/ckeditor5-utils/src/ckeditorerror';
|
|
|
|
|
|
describe( 'MentionUI', () => {
|
|
|
let editor, model, doc, editingView, mentionUI, editorElement, mentionsView, panelView;
|
|
|
@@ -344,25 +344,33 @@ describe( 'MentionUI', () => {
|
|
|
writer.insertText( '@', doc.selection.getFirstPosition() );
|
|
|
} );
|
|
|
|
|
|
+ const arrowDownEvtData = {
|
|
|
+ keyCode: keyCodes.arrowdown,
|
|
|
+ preventDefault: sinon.spy(),
|
|
|
+ stopPropagation: sinon.spy()
|
|
|
+ };
|
|
|
+
|
|
|
+ const arrowUpEvtData = {
|
|
|
+ keyCode: keyCodes.arrowup,
|
|
|
+ preventDefault: sinon.spy(),
|
|
|
+ stopPropagation: sinon.spy()
|
|
|
+ };
|
|
|
+
|
|
|
return waitForDebounce()
|
|
|
.then( () => {
|
|
|
- expect( panelView.isVisible ).to.be.true;
|
|
|
+ expect( panelView.isVisible, 'A' ).to.be.true;
|
|
|
|
|
|
- expectChildViewsIsOnState( [ true, false, false, false, false, false, false, false, false, false ] );
|
|
|
-
|
|
|
- const arrowDownEvtData = {
|
|
|
- keyCode: keyCodes.arrowdown,
|
|
|
- preventDefault: sinon.spy(),
|
|
|
- stopPropagation: sinon.spy()
|
|
|
- };
|
|
|
+ // Set arbitrary height of each item in the panel view since Travis has different base styles. See #47.
|
|
|
+ Array.from( mentionsView.items ).forEach( item => {
|
|
|
+ item.children.get( 0 ).element.style = 'height: 50px';
|
|
|
+ } );
|
|
|
|
|
|
- const arrowUpEvtData = {
|
|
|
- keyCode: keyCodes.arrowup,
|
|
|
- preventDefault: sinon.spy(),
|
|
|
- stopPropagation: sinon.spy()
|
|
|
- };
|
|
|
+ expectChildViewsIsOnState( [ true, false, false, false, false, false, false, false, false, false ] );
|
|
|
|
|
|
fireKeyDownEvent( arrowDownEvtData );
|
|
|
+ } )
|
|
|
+ .then( waitForDebounce )
|
|
|
+ .then( () => {
|
|
|
expect( mentionsView.element.scrollTop ).to.equal( 0 );
|
|
|
|
|
|
expectChildViewsIsOnState( [ false, true, false, false, false, false, false, false, false, false ] );
|
|
|
@@ -375,7 +383,10 @@ describe( 'MentionUI', () => {
|
|
|
|
|
|
fireKeyDownEvent( arrowDownEvtData );
|
|
|
expectChildViewsIsOnState( [ true, false, false, false, false, false, false, false, false, false ] );
|
|
|
- expect( mentionsView.element.scrollTop ).to.equal( 0 );
|
|
|
+
|
|
|
+ // The panel view should scroll back to 0 but on travis it gives random results. See #47.
|
|
|
+ // Use 50 as a height of one element so if it is scrolled below first it is good enough.
|
|
|
+ expect( mentionsView.element.scrollTop ).to.be.within( 0, 50 );
|
|
|
} );
|
|
|
} );
|
|
|
} );
|