import { context, describe, it } from '@ephox/bedrock-client'; import { Arr } from '@ephox/katamari'; import { TinyAssertions, TinyHooks, TinySelections, TinyUiActions } from '@ephox/wrap-mcagar'; import Editor from 'tinymce/core/api/Editor'; import AdvListPlugin from 'tinymce/plugins/advlist/Plugin'; import ListsPlugin from 'tinymce/plugins/lists/Plugin'; describe('browser.tinymce.plugins.advlist.ChangeListStyleTest', () => { Arr.each([ { label: 'Iframe Editor', setup: TinyHooks.bddSetup }, { label: 'Shadow Dom Editor', setup: TinyHooks.bddSetupInShadowRoot } ], (tester) => { context(tester.label, () => { const hook = tester.setup({ indent: false, plugins: 'lists advlist', toolbar: 'numlist bullist', menubar: false, statusbar: false, base_url: '/project/tinymce/js/tinymce' }, [ AdvListPlugin, ListsPlugin ]); const pWaitForMenu = (editor: Editor) => TinyUiActions.pWaitForUi(editor, '.tox-menu.tox-selected-menu'); it('ul to alpha, cursor only in parent', async () => { const editor = hook.editor(); editor.setContent(''); TinySelections.setCursor(editor, [ 0, 0, 0 ], 0); TinyUiActions.clickOnToolbar(editor, '[aria-label="Numbered list"] > .tox-tbtn + .tox-split-button__chevron'); await pWaitForMenu(editor); TinyUiActions.clickOnUi(editor, 'div.tox-selected-menu[role="menu"] div[title="Lower Alpha"]'); TinyAssertions.assertContent(editor, '
  1. a
'); TinyAssertions.assertSelection(editor, [ 0, 0, 0 ], 0, [ 0, 0, 0 ], 0); }); it('ul to alpha, selection from parent to sublist', async () => { const editor = hook.editor(); editor.setContent(''); TinySelections.setSelection(editor, [ 0, 0, 0 ], 0, [ 0, 1, 0, 0 ], 1); TinyUiActions.clickOnToolbar(editor, '[aria-label="Numbered list"] > .tox-tbtn + .tox-split-button__chevron'); await pWaitForMenu(editor); TinyUiActions.clickOnUi(editor, 'div.tox-selected-menu[role="menu"] div[title="Lower Alpha"]'); TinyAssertions.assertContent(editor, '
  1. a
    1. b
'); TinyAssertions.assertSelection(editor, [ 0, 0, 0 ], 0, [ 0, 1, 0, 0 ], 1); }); it('ol to ul, cursor only in parent', () => { const editor = hook.editor(); editor.setContent('
  1. a
    1. b
'); TinySelections.setCursor(editor, [ 0, 0, 0 ], 0); TinyUiActions.clickOnToolbar(editor, '[aria-label="Bullet list"] > .tox-tbtn'); TinyAssertions.assertContent(editor, ''); TinyAssertions.assertSelection(editor, [ 0, 0, 0 ], 0, [ 0, 0, 0 ], 0); }); it('ol to ul, selection from parent to sublist', () => { const editor = hook.editor(); editor.setContent('
  1. a
    1. b
'); TinySelections.setSelection(editor, [ 0, 0, 0 ], 0, [ 0, 1, 0, 0 ], 1); TinyUiActions.clickOnToolbar(editor, '[aria-label="Bullet list"] > .tox-tbtn'); TinyAssertions.assertContent(editor, ''); TinyAssertions.assertSelection(editor, [ 0, 0, 0 ], 0, [ 0, 1, 0, 0 ], 1); }); it('alpha to ol, cursor only in parent', async () => { const editor = hook.editor(); editor.setContent('
  1. a
    1. b
'); TinySelections.setCursor(editor, [ 0, 0, 0 ], 0); TinyUiActions.clickOnToolbar(editor, '[aria-label="Numbered list"] > .tox-tbtn + .tox-split-button__chevron'); await pWaitForMenu(editor); TinyUiActions.clickOnUi(editor, 'div.tox-selected-menu[role="menu"] div[title="Default"]'); TinyAssertions.assertContent(editor, '
  1. a
    1. b
'); TinyAssertions.assertSelection(editor, [ 0, 0, 0 ], 0, [ 0, 0, 0 ], 0); }); it('alpha to ol, selection from parent to sublist', async () => { const editor = hook.editor(); editor.setContent('
  1. a
    1. b
'); TinySelections.setSelection(editor, [ 0, 0, 0 ], 0, [ 0, 1, 0, 0 ], 1); TinyUiActions.clickOnToolbar(editor, '[aria-label="Numbered list"] > .tox-tbtn + .tox-split-button__chevron'); await pWaitForMenu(editor); TinyUiActions.clickOnUi(editor, 'div.tox-selected-menu[role="menu"] div[title="Default"]'); TinyAssertions.assertContent(editor, '
  1. a
    1. b
'); TinyAssertions.assertSelection(editor, [ 0, 0, 0 ], 0, [ 0, 1, 0, 0 ], 1); }); it('alpha to ul, cursor only in parent', () => { const editor = hook.editor(); editor.setContent('
  1. a
    1. b
'); TinySelections.setCursor(editor, [ 0, 0, 0 ], 0); TinyUiActions.clickOnToolbar(editor, '[aria-label="Bullet list"] > .tox-tbtn'); TinyAssertions.assertContent(editor, ''); TinyAssertions.assertSelection(editor, [ 0, 0, 0 ], 0, [ 0, 0, 0 ], 0); }); it('alpha to ul, selection from parent to sublist', () => { const editor = hook.editor(); editor.setContent('
  1. a
    1. b
'); TinySelections.setSelection(editor, [ 0, 0, 0 ], 0, [ 0, 1, 0, 0 ], 1); TinyUiActions.clickOnToolbar(editor, '[aria-label="Bullet list"] > .tox-tbtn'); TinyAssertions.assertContent(editor, ''); TinyAssertions.assertSelection(editor, [ 0, 0, 0 ], 0, [ 0, 1, 0, 0 ], 1); }); }); }); });