Skip to content

Commit

Permalink
Merge pull request #9113 from ckeditor/i/9083
Browse files Browse the repository at this point in the history
Tests (core, basic-styles, link, restricted-editing, select-all, undo): Tests should not fail on macOS after changes in the keystrokes handling. Closes #9083.
  • Loading branch information
oleq authored Feb 26, 2021
2 parents ef35b84 + 852e3dc commit eed13fb
Show file tree
Hide file tree
Showing 9 changed files with 47 additions and 19 deletions.
4 changes: 3 additions & 1 deletion packages/ckeditor5-basic-styles/tests/bold/boldediting.js
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -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()
};
Expand Down
4 changes: 3 additions & 1 deletion packages/ckeditor5-basic-styles/tests/italic/italicui.js
Original file line number Diff line number Diff line change
Expand Up @@ -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';
Expand Down Expand Up @@ -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()
} );
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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';
Expand Down Expand Up @@ -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()
};
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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';
Expand Down Expand Up @@ -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()
} );
Expand Down
4 changes: 3 additions & 1 deletion packages/ckeditor5-core/tests/editingkeystrokehandler.js
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -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()
};
Expand Down
22 changes: 15 additions & 7 deletions packages/ckeditor5-link/tests/linkui.js
Original file line number Diff line number Diff line change
Expand Up @@ -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';
Expand Down Expand Up @@ -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()
} );
Expand All @@ -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()
} );
Expand All @@ -816,7 +819,8 @@ describe( 'LinkUI', () => {

editor.keystrokes.press( {
keyCode: keyCodes.k,
ctrlKey: true,
ctrlKey: !env.isMac,
metaKey: env.isMac,
preventDefault: preventDefaultSpy,
stopPropagation: stopPropagationSpy
} );
Expand All @@ -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()
} );
Expand All @@ -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()
} );
Expand All @@ -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()
} );
Expand Down Expand Up @@ -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()
};
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -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()
};
Expand Down
10 changes: 7 additions & 3 deletions packages/ckeditor5-select-all/tests/selectallediting.js
Original file line number Diff line number Diff line change
Expand Up @@ -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', () => {
Expand Down Expand Up @@ -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()
};

Expand All @@ -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()
};

Expand All @@ -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()
};

Expand Down
10 changes: 7 additions & 3 deletions packages/ckeditor5-undo/tests/undoediting.js
Original file line number Diff line number Diff line change
Expand Up @@ -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', () => {
Expand Down Expand Up @@ -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()
} );
Expand All @@ -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()
} );
Expand All @@ -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()
Expand Down

0 comments on commit eed13fb

Please sign in to comment.