import { RealKeys } from '@ephox/agar'; import { beforeEach, context, describe, it } from '@ephox/bedrock-client'; import { PlatformDetection } from '@ephox/sand'; import { TinyAssertions, TinyHooks, TinySelections } from '@ephox/wrap-mcagar'; import Editor from 'tinymce/core/api/Editor'; describe('webdriver.tinymce.core.keyboard.SpaceKeyTest', () => { const hook = TinyHooks.bddSetupLight({ indent: false, base_url: '/project/tinymce/js/tinymce' }, []); const detect = PlatformDetection.detect().browser; const isSafari = detect.isSafari(); const isFirefox = detect.isFirefox(); beforeEach(() => { hook.editor().focus(); }); context('Space key around inline boundary elements', () => { it('TINY-8588: Add one space just before a block', async () => { const editor = hook.editor(); editor.setContent('

sa

'); TinySelections.setCursor(editor, [ 0, 0 ], 1); await RealKeys.pSendKeysOn('iframe => body', [ RealKeys.text(' ') ]); TinyAssertions.assertContent(editor, '

a

'); }); it('TINY-8588: Add two spaces just before a block', async () => { const editor = hook.editor(); editor.setContent('

sa

'); TinySelections.setCursor(editor, [ 0, 0 ], 1); await RealKeys.pSendKeysOn('iframe => body', [ RealKeys.text(' ') ]); await RealKeys.pSendKeysOn('iframe => body', [ RealKeys.text(' ') ]); if (isSafari) { // Split due to normalization issue. See TINY-8833 TinyAssertions.assertContent(editor, '

s  a

'); } else if (isFirefox) { // Split due to normalization issue. See TINY-8833 TinyAssertions.assertContent(editor, '

a

'); } else { TinyAssertions.assertContent(editor, '

s  a

'); } }); it('TINY-8588: Add one space before a block while in a span', async () => { const editor = hook.editor(); editor.setContent('

sa

'); TinySelections.setCursor(editor, [ 0, 0, 0 ], 1); await RealKeys.pSendKeysOn('iframe => body', [ RealKeys.text(' ') ]); TinyAssertions.assertContent(editor, '

a

'); }); it('TINY-8588: Add one space before a block inside a strong', async () => { const editor = hook.editor(); editor.setContent('

sa

'); TinySelections.setCursor(editor, [ 0, 0 ], 1); await RealKeys.pSendKeysOn('iframe => body', [ RealKeys.text(' ') ]); TinyAssertions.assertContent(editor, '

a

'); }); it('TINY-8814: Add one space just after a block', async () => { const editor = hook.editor(); editor.setContent('

as

'); TinySelections.setCursor(editor, [ 0, 2 ], 0); await RealKeys.pSendKeysOn('iframe => body', [ RealKeys.text(' ') ]); TinyAssertions.assertContent(editor, '

a s

'); }); it('TINY-8814: Add two spaces just after a block', async () => { const editor = hook.editor(); editor.setContent('

as

'); TinySelections.setCursor(editor, [ 0, 2 ], 0); await RealKeys.pSendKeysOn('iframe => body', [ RealKeys.text(' ') ]); await RealKeys.pSendKeysOn('iframe => body', [ RealKeys.text(' ') ]); TinyAssertions.assertContent(editor, '

a  s

'); }); it('TINY-8814: Add one space after a block while in a span', async () => { const editor = hook.editor(); editor.setContent('

as

'); TinySelections.setCursor(editor, [ 0, 2, 0 ], 0); await RealKeys.pSendKeysOn('iframe => body', [ RealKeys.text(' ') ]); TinyAssertions.assertContent(editor, '

a s

'); }); it('TINY-8814: Add one space after a block inside a strong', async () => { const editor = hook.editor(); editor.setContent('

as

'); TinySelections.setCursor(editor, [ 0, 1 ], 0); await RealKeys.pSendKeysOn('iframe => body', [ RealKeys.text(' ') ]); TinyAssertions.assertContent(editor, '

a s

'); }); }); });