Jelajahi Sumber

Merge branch 'master' into t/28

Maciej Gołaszewski 6 tahun lalu
induk
melakukan
b070f57ae3

+ 5 - 0
packages/ckeditor5-mention/.travis.yml

@@ -12,6 +12,7 @@ branches:
   except:
   - stable
 before_install:
+- export START_TIME=$( date +%s )
 - export DISPLAY=:99.0
 - sh -e /etc/init.d/xvfb start
 - npm i -g yarn
@@ -22,7 +23,11 @@ script:
 - ckeditor5-dev-tests-travis
 after_success:
 - ckeditor5-dev-tests-save-revision
+after_script:
+- export END_TIME=$( date +%s )
+- ckeditor5-dev-tests-notify-travis-status
 env:
   global:
   - secure: ZQA0E73V4IrxrhGCqVMnBDZR8gP0P8MlCgdOy2qUtSB2yR+syefZBcBVoa6YYTle8UmePO4ETta4y0FMH0zZdnSETEqQ5odKGdclhkFU8I4O9+7ZXGQEfQPVriZxXHjdCX66gRShphW+6tcg5M+jGs1TlBtmgNuMn4MU7Z16lLAouO4gaicOFfDQO/FF2yO5YJURY47ThO/IVfUJB5n1a5rAkRN9WmbAubkYqtC53wOg/Ipl7I6bquxaUAcPLd+2kT1T6g+SWISoOhfOTYwwaN9Tqapzdx3wwM47DgDmjZ3tDRuhIBPLTWx7Fk70VF+8wnRi0ydhXaZYoRh6dBbjZPO9IwOArMmV6SRANWt5KAmxW3glFuvjDih/ypR1r1YzDf2kKvLijPZCQpQKzeWPZ6X+kaVGeIe8mdRz0MCh2TBvCXVRBfmh9BNFmnLhg68ympJK1zBczFtTVdoNiTJ8eV4AsKb+NED6ZRdD0Ol7ydD4LOcl2LsIpWaYj04tXuvIe+hN7AjTGiOBFqEY0VGHSu9WyGziBCHR9yboDmy8il/ChBBgWOFYJXZNGnw+VHhFrkxAXDUYbLreVIZLPUMRscB31y982R0oiU0pVsGJTSP1v6i0JMAjNJ3ZsL7V4IoFwnqk2NbKj28JxTq2BMBx5g3ry9EW9WQ1fgzxJuWOo2I=
   - secure: dOp+yn/un5AyUPO7Zv7EY5LlEH59ASFb27DkyoIjKytcERp6iCMuHqGg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AeGHew+CQ8R780my/+HaS/9Q2Vig/IfbV006dEi/AcTCX9V+JTVd9hPgP3bWUrhaOFxn/BuWgweZFnxtvEj9liczQXlCFVLDGOzjx1I/Ruy0u2IbI+0R8St9QJa6VJU8dWyxaIxvu1X/SRWop5iXEAEL3nTmBkZrdIweaT9p8ZvgCsXo7Hg+AUkx42fzXnWinXMCNWxuDhMQoXD0jf8UfgV0y4yy9Ky2pi8cconBhGV4ZKFXVQ=

+ 29 - 19
packages/ckeditor5-mention/tests/mentionui.js

@@ -3,7 +3,7 @@
  * For licensing, see LICENSE.md or https://ckeditor.com/legal/ckeditor-oss-license
  */
 
-/* global window, document, setTimeout, Event */
+/* global document, setTimeout, Event */
 
 import ClassicTestEditor from '@ckeditor/ckeditor5-core/tests/_utils/classictesteditor';
 import Plugin from '@ckeditor/ckeditor5-core/src/plugin';
@@ -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;
@@ -259,7 +259,7 @@ describe( 'MentionUI', () => {
 					const pinArgument = pinSpy.firstCall.args[ 0 ];
 					const { limiter } = pinArgument;
 
-					sinon.stub( editingView.document.selection, 'editableElement' ).value( null );
+					testUtils.sinon.stub( editingView.document.selection, 'editableElement' ).value( null );
 
 					// Should not break;
 					expect( limiter() ).to.be.null;
@@ -346,10 +346,6 @@ describe( 'MentionUI', () => {
 
 				return waitForDebounce()
 					.then( () => {
-						expect( panelView.isVisible ).to.be.true;
-
-						expectChildViewsIsOnState( [ true, false, false, false, false, false, false, false, false, false ] );
-
 						const arrowDownEvtData = {
 							keyCode: keyCodes.arrowdown,
 							preventDefault: sinon.spy(),
@@ -362,18 +358,41 @@ describe( 'MentionUI', () => {
 							stopPropagation: sinon.spy()
 						};
 
-						fireKeyDownEvent( arrowDownEvtData );
+						// The scroll test highly depends on browser styles.
+						// Some CI test environments might not load theme which will result that tests will not render on CI as locally.
+						// To make this test repeatable across different environments it enforces mentions view size to 100px...
+						mentionsView.element.style = 'height:100px;padding:0px;margin:0px';
+
+						// ...and each list view item size to 25px...
+						Array.from( mentionsView.items ).forEach( item => {
+							item.children.get( 0 ).element.style = 'height:25px;padding:0px;margin:0px;';
+						} );
+
+						// ...so after those changes it is safe to assume that:
+						// - base offset is 0
+						// - only 4 items are visible at once
+						// - if scrolled to the last element scrollTop will be set to 150px. The 150px is the offset of the 7th item in the
+						//   list as last four (7, 8, 9 & 10) will be visible.
+						expect( panelView.isVisible ).to.be.true;
+
+						expectChildViewsIsOnState( [ true, false, false, false, false, false, false, false, false, false ] );
 						expect( mentionsView.element.scrollTop ).to.equal( 0 );
 
+						fireKeyDownEvent( arrowDownEvtData );
+
 						expectChildViewsIsOnState( [ false, true, false, false, false, false, false, false, false, false ] );
+						expect( mentionsView.element.scrollTop ).to.equal( 0 );
 
 						fireKeyDownEvent( arrowUpEvtData );
-						fireKeyDownEvent( arrowUpEvtData );
+						expectChildViewsIsOnState( [ true, false, false, false, false, false, false, false, false, false ] );
+						expect( mentionsView.element.scrollTop ).to.equal( 0 );
 
+						fireKeyDownEvent( arrowUpEvtData );
 						expectChildViewsIsOnState( [ false, false, false, false, false, false, false, false, false, true ] );
-						expect( mentionsView.element.scrollTop ).to.be.not.equal( 0 );
+						expect( mentionsView.element.scrollTop ).to.be.within( 140, 160 ); // We want 150, but sometimes we get e.g. 151.
 
 						fireKeyDownEvent( arrowDownEvtData );
+
 						expectChildViewsIsOnState( [ true, false, false, false, false, false, false, false, false, false ] );
 						expect( mentionsView.element.scrollTop ).to.equal( 0 );
 					} );
@@ -1489,15 +1508,6 @@ describe( 'MentionUI', () => {
 				mentionUI = editor.plugins.get( MentionUI );
 				panelView = mentionUI.panelView;
 				mentionsView = mentionUI._mentionsView;
-
-				editingView.attachDomRoot( editorElement );
-
-				// Focus the engine.
-				editingView.document.isFocused = true;
-				editingView.getDomRoot().focus();
-
-				// Remove all selection ranges from DOM before testing.
-				window.getSelection().removeAllRanges();
 			} );
 	}