import { ApproxStructure, GeneralSteps, Pipeline, Waiter } from '@ephox/agar'; import { UnitTest } from '@ephox/bedrock'; import { TinyApis, TinyLoader, TinyUi } from '@ephox/mcagar'; import Plugin from 'tinymce/plugins/media/Plugin'; import Theme from 'tinymce/themes/modern/Theme'; import Utils from '../module/test/Utils'; UnitTest.asynctest('browser.core.SubmitTest', function () { const success = arguments[arguments.length - 2]; const failure = arguments[arguments.length - 1]; Plugin(); Theme(); const sTestPlaceholder = function (ui, editor, apis, url, expected, struct) { return GeneralSteps.sequence([ Utils.sOpenDialog(ui), Utils.sSetFormItemNoEvent(ui, url), ui.sClickOnUi('click checkbox', 'div.mce-primary > button'), Utils.sAssertEditorContent(apis, editor, expected), Waiter.sTryUntil('Wait for structure check', apis.sAssertContentStructure(struct), 100, 3000), apis.sSetContent('') ]); }; const sTestScriptPlaceholder = function (ui, editor, apis, expected, struct) { return GeneralSteps.sequence([ apis.sSetContent( '' + ''), apis.sNodeChanged, Waiter.sTryUntil('Wait for structure check', apis.sAssertContentStructure(struct), 10, 500), Utils.sAssertEditorContent(apis, editor, expected), apis.sSetContent('') ]); }; const placeholderStructure = ApproxStructure.build(function (s) { return s.element('body', { children: [ s.element('p', { children: [ s.element('img', {}) ] }), s.element('div', {}), s.element('div', {}), s.element('div', {}), s.element('div', {}) ] }); }); const iframeStructure = ApproxStructure.build(function (s) { return s.element('body', { children: [ s.element('p', { children: [ s.element('span', { children: [ s.element('iframe', {}), s.element('span', {}) ] }), s.anything() ] }) ] }); }); const scriptStruct = ApproxStructure.build(function (s, str, arr) { return s.element('body', { children: [ s.element('p', { children: [ s.element('img', { classes: [ arr.has('mce-object', 'mce-object-script') ], attrs: { height: str.is('150'), width: str.is('300') } }), s.element('img', { classes: [ arr.has('mce-object', 'mce-object-script') ], attrs: { height: str.is('200'), width: str.is('100') } }) ] }) ] }); }); TinyLoader.setup(function (editor, onSuccess, onFailure) { const ui = TinyUi(editor); const apis = TinyApis(editor); Pipeline.async({}, [ Utils.sSetSetting(editor.settings, 'media_live_embeds', false), sTestScriptPlaceholder(ui, editor, apis, '

\n' + '