import { describe, it } from '@ephox/bedrock-client'; import { TinyAssertions, TinyHooks, TinySelections } from '@ephox/wrap-mcagar'; import Editor from 'tinymce/core/api/Editor'; import Plugin from 'tinymce/plugins/table/Plugin'; import { clickOnButton, makeCell, pClickOnMenuItem } from '../../module/test/TableModifiersTestUtils'; describe('browser.tinymce.plugins.table.ui.TableRowHeaderUiTest', () => { const hook = TinyHooks.bddSetupLight({ plugins: 'table', base_url: '/project/tinymce/js/tinymce', menu: { table: { title: 'Table', items: 'tablerowheader' }, }, menubar: 'table', toolbar: 'tablerowheader', indent: false, }, [ Plugin ], true); const setEditorContentAndSelection = (editor: Editor, tableSection: 'thead' | 'tbody') => { editor.setContent( '' + `<${tableSection}>` + '' + makeCell('td', '0-0', 'none') + makeCell('td', '0-1', 'none', 'selectionStart') + '' + '' + makeCell('td', '1-0', 'none') + makeCell('td', '1-1', 'none', 'selectionEnd') + '' + `` + '
' ); TinySelections.setCursor(editor, [ 0, 0, 0, 1 ], 0); }; const tableWithRowHeaders = ( '' + '' + '' + makeCell('td', '0-0', 'none') + makeCell('td', '0-1', 'none') + '' + '' + makeCell('td', '1-0', 'none') + makeCell('td', '1-1', 'none') + '' + '' + '
' ); const tableWithoutRowHeaders = ( '' + '' + '' + makeCell('td', '0-0', 'none') + makeCell('td', '0-1', 'none') + '' + '' + makeCell('td', '1-0', 'none') + makeCell('td', '1-1', 'none') + '' + '' + '
' ); it('TINY-7481: Can toggle headers on with toolbar button', () => { const editor = hook.editor(); setEditorContentAndSelection(editor, 'tbody'); clickOnButton(editor, 'Row header'); TinyAssertions.assertContent(editor, tableWithRowHeaders); }); it('TINY-7481: Can toggle headers on with menuitem', async () => { const editor = hook.editor(); setEditorContentAndSelection(editor, 'tbody'); await pClickOnMenuItem(editor, 'Row header'); TinyAssertions.assertContent(editor, tableWithRowHeaders); }); it('TINY-7481: Can toggle headers off with toolbar button', () => { const editor = hook.editor(); setEditorContentAndSelection(editor, 'thead'); clickOnButton(editor, 'Row header'); TinyAssertions.assertContent(editor, tableWithoutRowHeaders); }); it('TINY-7481: Can toggle headers off with menuitem', async () => { const editor = hook.editor(); setEditorContentAndSelection(editor, 'thead'); await pClickOnMenuItem(editor, 'Row header'); TinyAssertions.assertContent(editor, tableWithoutRowHeaders); }); });