From abcbf04aa28c0356573009f5695a840ff364929c Mon Sep 17 00:00:00 2001 From: Kuba Niegowski Date: Thu, 25 Feb 2021 17:52:56 +0100 Subject: [PATCH] Tests updated to the changed keystroke handling. --- .../tests/bold/boldediting.js | 4 +++- .../tests/italic/italicui.js | 4 +++- .../tests/strikethrough/strikethroughui.js | 4 +++- .../tests/underline/underlineui.js | 4 +++- .../tests/editingkeystrokehandler.js | 4 +++- packages/ckeditor5-link/tests/linkui.js | 22 +++++++++++++------ .../tests/restrictededitingmodeediting.js | 4 +++- .../tests/selectallediting.js | 10 ++++++--- packages/ckeditor5-undo/tests/undoediting.js | 10 ++++++--- 9 files changed, 47 insertions(+), 19 deletions(-) diff --git a/packages/ckeditor5-basic-styles/tests/bold/boldediting.js b/packages/ckeditor5-basic-styles/tests/bold/boldediting.js index 7ee66bc1892..844ae5b8a98 100644 --- a/packages/ckeditor5-basic-styles/tests/bold/boldediting.js +++ b/packages/ckeditor5-basic-styles/tests/bold/boldediting.js @@ -12,6 +12,7 @@ import AttributeCommand from '../../src/attributecommand'; import { getData as getModelData, setData as setModelData } from '@ckeditor/ckeditor5-engine/src/dev-utils/model'; import { getData as getViewData } from '@ckeditor/ckeditor5-engine/src/dev-utils/view'; import { keyCodes } from '@ckeditor/ckeditor5-utils/src/keyboard'; +import env from '@ckeditor/ckeditor5-utils/src/env'; describe( 'BoldEditing', () => { let editor, model; @@ -60,7 +61,8 @@ describe( 'BoldEditing', () => { const spy = sinon.spy( editor, 'execute' ); const keyEventData = { keyCode: keyCodes.b, - ctrlKey: true, + ctrlKey: !env.isMac, + metaKey: env.isMac, preventDefault: sinon.spy(), stopPropagation: sinon.spy() }; diff --git a/packages/ckeditor5-basic-styles/tests/italic/italicui.js b/packages/ckeditor5-basic-styles/tests/italic/italicui.js index 39f83cb5e82..1f6aa08f630 100644 --- a/packages/ckeditor5-basic-styles/tests/italic/italicui.js +++ b/packages/ckeditor5-basic-styles/tests/italic/italicui.js @@ -10,6 +10,7 @@ import ItalicEditing from '../../src/italic/italicediting'; import ItalicUI from '../../src/italic/italicui'; import ButtonView from '@ckeditor/ckeditor5-ui/src/button/buttonview'; import testUtils from '@ckeditor/ckeditor5-core/tests/_utils/utils'; +import env from '@ckeditor/ckeditor5-utils/src/env'; import { keyCodes } from '@ckeditor/ckeditor5-utils/src/keyboard'; import Paragraph from '@ckeditor/ckeditor5-paragraph/src/paragraph'; @@ -80,7 +81,8 @@ describe( 'ItalicUI', () => { const wasHandled = editor.keystrokes.press( { keyCode: keyCodes.i, - ctrlKey: true, + ctrlKey: !env.isMac, + metaKey: env.isMac, preventDefault: sinon.spy(), stopPropagation: sinon.spy() } ); diff --git a/packages/ckeditor5-basic-styles/tests/strikethrough/strikethroughui.js b/packages/ckeditor5-basic-styles/tests/strikethrough/strikethroughui.js index d946657581a..8310df72d45 100644 --- a/packages/ckeditor5-basic-styles/tests/strikethrough/strikethroughui.js +++ b/packages/ckeditor5-basic-styles/tests/strikethrough/strikethroughui.js @@ -10,6 +10,7 @@ import StrikethroughEditing from '../../src/strikethrough/strikethroughediting'; import StrikethroughUI from '../../src/strikethrough/strikethroughui'; import ButtonView from '@ckeditor/ckeditor5-ui/src/button/buttonview'; import testUtils from '@ckeditor/ckeditor5-core/tests/_utils/utils'; +import env from '@ckeditor/ckeditor5-utils/src/env'; import { keyCodes } from '@ckeditor/ckeditor5-utils/src/keyboard'; import Paragraph from '@ckeditor/ckeditor5-paragraph/src/paragraph'; @@ -80,7 +81,8 @@ describe( 'StrikethroughUI', () => { const keyEventData = { keyCode: keyCodes.x, shiftKey: true, - ctrlKey: true, + ctrlKey: !env.isMac, + metaKey: env.isMac, preventDefault: sinon.spy(), stopPropagation: sinon.spy() }; diff --git a/packages/ckeditor5-basic-styles/tests/underline/underlineui.js b/packages/ckeditor5-basic-styles/tests/underline/underlineui.js index b7843bcfd50..833c7a8165f 100644 --- a/packages/ckeditor5-basic-styles/tests/underline/underlineui.js +++ b/packages/ckeditor5-basic-styles/tests/underline/underlineui.js @@ -10,6 +10,7 @@ import UnderlineEditing from '../../src/underline/underlineediting'; import UnderlineUI from '../../src/underline/underlineui'; import ButtonView from '@ckeditor/ckeditor5-ui/src/button/buttonview'; import testUtils from '@ckeditor/ckeditor5-core/tests/_utils/utils'; +import env from '@ckeditor/ckeditor5-utils/src/env'; import { keyCodes } from '@ckeditor/ckeditor5-utils/src/keyboard'; import Paragraph from '@ckeditor/ckeditor5-paragraph/src/paragraph'; @@ -80,7 +81,8 @@ describe( 'Underline', () => { const wasHandled = editor.keystrokes.press( { keyCode: keyCodes.u, - ctrlKey: true, + ctrlKey: !env.isMac, + metaKey: env.isMac, preventDefault: sinon.spy(), stopPropagation: sinon.spy() } ); diff --git a/packages/ckeditor5-core/tests/editingkeystrokehandler.js b/packages/ckeditor5-core/tests/editingkeystrokehandler.js index 4e667a3d645..719cfb16363 100644 --- a/packages/ckeditor5-core/tests/editingkeystrokehandler.js +++ b/packages/ckeditor5-core/tests/editingkeystrokehandler.js @@ -6,6 +6,7 @@ import VirtualTestEditor from '../tests/_utils/virtualtesteditor'; import EditingKeystrokeHandler from '../src/editingkeystrokehandler'; import { keyCodes } from '@ckeditor/ckeditor5-utils/src/keyboard'; +import env from '@ckeditor/ckeditor5-utils/src/env'; describe( 'EditingKeystrokeHandler', () => { let editor, keystrokes, executeSpy; @@ -120,7 +121,8 @@ describe( 'EditingKeystrokeHandler', () => { function getCtrlA() { return { keyCode: keyCodes.a, - ctrlKey: true, + ctrlKey: !env.isMac, + metaKey: env.isMac, preventDefault: sinon.spy(), stopPropagation: sinon.spy() }; diff --git a/packages/ckeditor5-link/tests/linkui.js b/packages/ckeditor5-link/tests/linkui.js index 024848b3f26..b467aed8111 100644 --- a/packages/ckeditor5-link/tests/linkui.js +++ b/packages/ckeditor5-link/tests/linkui.js @@ -12,6 +12,7 @@ import isRange from '@ckeditor/ckeditor5-utils/src/dom/isrange'; import { keyCodes } from '@ckeditor/ckeditor5-utils/src/keyboard'; import { getData as getModelData, setData as setModelData } from '@ckeditor/ckeditor5-engine/src/dev-utils/model'; import { getData as getViewData } from '@ckeditor/ckeditor5-engine/src/dev-utils/view'; +import env from '@ckeditor/ckeditor5-utils/src/env'; import Paragraph from '@ckeditor/ckeditor5-paragraph/src/paragraph'; import BlockQuote from '@ckeditor/ckeditor5-block-quote/src/blockquote'; @@ -788,7 +789,8 @@ describe( 'LinkUI', () => { editor.keystrokes.press( { keyCode: keyCodes.k, - ctrlKey: true, + ctrlKey: !env.isMac, + metaKey: env.isMac, preventDefault: sinon.spy(), stopPropagation: sinon.spy() } ); @@ -802,7 +804,8 @@ describe( 'LinkUI', () => { editor.keystrokes.press( { keyCode: keyCodes.k, - ctrlKey: true, + ctrlKey: !env.isMac, + metaKey: env.isMac, preventDefault: sinon.spy(), stopPropagation: sinon.spy() } ); @@ -816,7 +819,8 @@ describe( 'LinkUI', () => { editor.keystrokes.press( { keyCode: keyCodes.k, - ctrlKey: true, + ctrlKey: !env.isMac, + metaKey: env.isMac, preventDefault: preventDefaultSpy, stopPropagation: stopPropagationSpy } ); @@ -837,7 +841,8 @@ describe( 'LinkUI', () => { editor.keystrokes.press( { keyCode: keyCodes.k, - ctrlKey: true, + ctrlKey: !env.isMac, + metaKey: env.isMac, preventDefault: sinon.spy(), stopPropagation: sinon.spy() } ); @@ -859,7 +864,8 @@ describe( 'LinkUI', () => { editor.keystrokes.press( { keyCode: keyCodes.k, - ctrlKey: true, + ctrlKey: !env.isMac, + metaKey: env.isMac, preventDefault: sinon.spy(), stopPropagation: sinon.spy() } ); @@ -868,7 +874,8 @@ describe( 'LinkUI', () => { editor.keystrokes.press( { keyCode: keyCodes.k, - ctrlKey: true, + ctrlKey: !env.isMac, + metaKey: env.isMac, preventDefault: sinon.spy(), stopPropagation: sinon.spy() } ); @@ -1162,7 +1169,8 @@ describe( 'LinkUI', () => { it( 'should add the #formView upon Ctrl+K keystroke press', () => { const keyEvtData = { keyCode: keyCodes.k, - ctrlKey: true, + ctrlKey: !env.isMac, + metaKey: env.isMac, preventDefault: sinon.spy(), stopPropagation: sinon.spy() }; diff --git a/packages/ckeditor5-restricted-editing/tests/restrictededitingmodeediting.js b/packages/ckeditor5-restricted-editing/tests/restrictededitingmodeediting.js index 758fce672f2..08240045b66 100644 --- a/packages/ckeditor5-restricted-editing/tests/restrictededitingmodeediting.js +++ b/packages/ckeditor5-restricted-editing/tests/restrictededitingmodeediting.js @@ -23,6 +23,7 @@ import ItalicEditing from '@ckeditor/ckeditor5-basic-styles/src/italic/italicedi import BlockQuoteEditing from '@ckeditor/ckeditor5-block-quote/src/blockquoteediting'; import TableEditing from '@ckeditor/ckeditor5-table/src/tableediting'; import Command from '@ckeditor/ckeditor5-core/src/command'; +import env from '@ckeditor/ckeditor5-utils/src/env'; describe( 'RestrictedEditingModeEditing', () => { let editor, model; @@ -1432,7 +1433,8 @@ describe( 'RestrictedEditingModeEditing', () => { beforeEach( async () => { evtData = { keyCode: getCode( 'A' ), - ctrlKey: true, + ctrlKey: !env.isMac, + metaKey: env.isMac, preventDefault: sinon.spy(), stopPropagation: sinon.spy() }; diff --git a/packages/ckeditor5-select-all/tests/selectallediting.js b/packages/ckeditor5-select-all/tests/selectallediting.js index 6e10c669ab5..76b410576c9 100644 --- a/packages/ckeditor5-select-all/tests/selectallediting.js +++ b/packages/ckeditor5-select-all/tests/selectallediting.js @@ -6,6 +6,7 @@ import ModelTestEditor from '@ckeditor/ckeditor5-core/tests/_utils/modeltesteditor'; import SelectAllEditing from '../src/selectallediting'; import SelectAllCommand from '../src/selectallcommand'; +import env from '@ckeditor/ckeditor5-utils/src/env'; import { keyCodes } from '@ckeditor/ckeditor5-utils/src/keyboard'; describe( 'SelectAllEditing', () => { @@ -42,7 +43,8 @@ describe( 'SelectAllEditing', () => { it( 'should execute the "selectAll" command', () => { const domEventDataMock = { keyCode: keyCodes.a, - ctrlKey: true, + ctrlKey: !env.isMac, + metaKey: env.isMac, preventDefault: sinon.spy() }; @@ -55,7 +57,8 @@ describe( 'SelectAllEditing', () => { it( 'should prevent the default action', () => { const domEventDataMock = { keyCode: keyCodes.a, - ctrlKey: true, + ctrlKey: !env.isMac, + metaKey: env.isMac, preventDefault: sinon.spy() }; @@ -67,7 +70,8 @@ describe( 'SelectAllEditing', () => { it( 'should not react to other keystrokes', () => { const domEventDataMock = { keyCode: keyCodes.x, - ctrlKey: true, + ctrlKey: !env.isMac, + metaKey: env.isMac, preventDefault: sinon.spy() }; diff --git a/packages/ckeditor5-undo/tests/undoediting.js b/packages/ckeditor5-undo/tests/undoediting.js index 8bf8f613745..f0d55517c3a 100644 --- a/packages/ckeditor5-undo/tests/undoediting.js +++ b/packages/ckeditor5-undo/tests/undoediting.js @@ -6,6 +6,7 @@ import ModelTestEditor from '@ckeditor/ckeditor5-core/tests/_utils/modeltesteditor'; import UndoEditing from '../src/undoediting'; +import env from '@ckeditor/ckeditor5-utils/src/env'; import { keyCodes } from '@ckeditor/ckeditor5-utils/src/keyboard'; describe( 'UndoEditing', () => { @@ -143,7 +144,8 @@ describe( 'UndoEditing', () => { const wasHandled = editor.keystrokes.press( { keyCode: keyCodes.z, - ctrlKey: true, + ctrlKey: !env.isMac, + metaKey: env.isMac, preventDefault: sinon.spy(), stopPropagation: sinon.spy() } ); @@ -157,7 +159,8 @@ describe( 'UndoEditing', () => { const wasHandled = editor.keystrokes.press( { keyCode: keyCodes.y, - ctrlKey: true, + ctrlKey: !env.isMac, + metaKey: env.isMac, preventDefault: sinon.spy(), stopPropagation: sinon.spy() } ); @@ -170,7 +173,8 @@ describe( 'UndoEditing', () => { const spy = sinon.stub( editor, 'execute' ); const keyEventData = { keyCode: keyCodes.z, - ctrlKey: true, + ctrlKey: !env.isMac, + metaKey: env.isMac, shiftKey: true, preventDefault: sinon.spy(), stopPropagation: sinon.spy()