import { GeneralSteps, Keys, Logger, Pipeline } from '@ephox/agar'; import { TinyActions, TinyApis, TinyLoader } from '@ephox/mcagar'; import Theme from 'tinymce/themes/modern/Theme'; import { UnitTest } from '@ephox/bedrock'; UnitTest.asynctest('browser.tinymce.core.keyboard.TableNavigationTest', (success, failure) => { Theme(); TinyLoader.setup(function (editor, onSuccess, onFailure) { const tinyApis = TinyApis(editor); const tinyActions = TinyActions(editor); Pipeline.async({}, [ Logger.t('Up navigation', GeneralSteps.sequence([ Logger.t('Arrow up on first position in table cell', GeneralSteps.sequence([ tinyApis.sFocus, tinyApis.sSetContent('
ab
'), tinyApis.sSetCursor([0, 0, 0, 0, 0], 0), tinyActions.sContentKeystroke(Keys.up(), {}), tinyApis.sAssertSelection([0], 0, [0], 0), tinyApis.sAssertContent('

 

ab
') ])), Logger.t('Arrow up on second position in first table cell', GeneralSteps.sequence([ tinyApis.sFocus, tinyApis.sSetContent('
ab
'), tinyApis.sSetCursor([0, 0, 0, 0, 0], 1), tinyActions.sContentKeystroke(Keys.up(), {}), tinyApis.sAssertSelection([0], 0, [0], 0), tinyApis.sAssertContent('

 

ab
') ])), Logger.t('Arrow up on first position in first table cell on the second row', GeneralSteps.sequence([ tinyApis.sFocus, tinyApis.sSetContent('
ab
cd
'), tinyApis.sSetCursor([0, 0, 1, 0, 0], 0), tinyActions.sContentKeystroke(Keys.up(), {}), tinyApis.sAssertSelection([0, 0, 0, 0, 0], 0, [0, 0, 0, 0, 0], 0), tinyApis.sAssertContent('
ab
cd
') ])), ])), Logger.t('Down navigation', GeneralSteps.sequence([ Logger.t('Arrow down on last position in last table cell', GeneralSteps.sequence([ tinyApis.sFocus, tinyApis.sSetContent('
ab
'), tinyApis.sSetCursor([0, 0, 0, 1, 0], 1), tinyActions.sContentKeystroke(Keys.down(), {}), tinyApis.sAssertSelection([1], 0, [1], 0), tinyApis.sAssertContent('
ab

 

') ])), Logger.t('Arrow down on second last position in last table cell', GeneralSteps.sequence([ tinyApis.sFocus, tinyApis.sSetContent('
ab
'), tinyApis.sSetCursor([0, 0, 0, 1, 0], 0), tinyActions.sContentKeystroke(Keys.down(), {}), tinyApis.sAssertSelection([1], 0, [1], 0), tinyApis.sAssertContent('
ab

 

') ])), Logger.t('Arrow down on last position in last table cell on the first row', GeneralSteps.sequence([ tinyApis.sFocus, tinyApis.sSetContent('
ab
cd
'), tinyApis.sSetCursor([0, 0, 0, 1, 0], 1), tinyActions.sContentKeystroke(Keys.down(), {}), tinyApis.sAssertSelection([0, 0, 1, 1, 0], 1, [0, 0, 1, 1, 0], 1), tinyApis.sAssertContent('
ab
cd
') ])), ])) ], onSuccess, onFailure); }, { indent: false, skin_url: '/project/js/tinymce/skins/lightgray' }, success, failure); });