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 sTestPlaceholder = function (ui, editor, apis, url, expected, struct) { return Logger.t(`Test placeholder ${expected}`, GeneralSteps.sequence([ Utils.sOpenDialog(ui), Utils.sSetFormItemNoEvent(ui, url), ui.sClickOnUi('click checkbox', Utils.selectors.saveButton), 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( '<script src="http://media1.tinymce.com/123456"></script>' + '<script src="http://media2.tinymce.com/123456"></script>'), apis.sNodeChanged, Waiter.sTryUntil('Wait for structure check', apis.sAssertContentStructure(struct), 10, 500), Utils.sAssertEditorContent(apis, editor, expected), apis.sSetContent('') ]); };
const sParseStyles = function (editor) { return GeneralSteps.sequence([ Step.sync(function () { editor.setContent('<html><head><style>p {text-align:right}</style></head><body dir="rtl"><p>Test</p></body></html>'); }), Waiter.sTryUntil( 'Expected styles where not added', Step.sync(function () { Assertions.assertEq('Styles added to iframe document', 'right', editor.dom.getStyle(editor.getBody().firstChild, 'text-align', true)); } ), 10, 3000) ]); };
TinyLoader.setup(function (editor, onSuccess, onFailure) { const tinyApis = TinyApis(editor); Pipeline.async({}, Arr.flatten([ [ Logger.t('Fullscreen toggle scroll state', GeneralSteps.sequence([ tinyApis.sExecCommand('mceFullScreen'), sAssertScroll(editor, true), tinyApis.sExecCommand('mceFullScreen'), sAssertScroll(editor, false) ])), Logger.t('Editor size increase based on content size', GeneralSteps.sequence([ tinyApis.sSetContent('<div style="height: 5000px;">a</div>'), Waiter.sTryUntil('wait for editor height', sAssertEditorHeightAbove(editor, 5000), 10, 3000) ])), Logger.t('Editor size decrease based on content size', GeneralSteps.sequence([ tinyApis.sSetContent('<div style="height: 1000px;">a</div>'), Waiter.sTryUntil('wait for editor height', sAssertEditorHeightBelow(editor, 2000), 10, 3000) ])) ], // These tests doesn't work on phantom since measuring things seems broken there navigator.userAgent.indexOf('PhantomJS') === -1 ? [ Logger.t('Editor size decrease content to 1000 based and restrict by max height', GeneralSteps.sequence([ tinyApis.sSetSetting('autoresize_max_height', 200), tinyApis.sSetContent('<div style="height: 1000px;">a</div>'), Waiter.sTryUntil('wait for editor height', sAssertEditorHeightBelow(editor, 500), 10, 3000), tinyApis.sSetSetting('autoresize_max_height', 0) ])), Logger.t('Editor size decrease content to 10 and set min height to 500', GeneralSteps.sequence([ tinyApis.sSetSetting('autoresize_min_height', 500), tinyApis.sSetContent('<div style="height: 10px;">a</div>'), Waiter.sTryUntil('wait for editor height', sAssertEditorHeightAbove(editor, 300), 10, 3000), tinyApis.sSetSetting('autoresize_min_height', 0) ])) ] : [] ]), onSuccess, onFailure); }, {
const sAssertColour = (label: string, expected: string, labelText: string) => Logger.t( label, Waiter.sTryUntil( 'Waiting until hex updates the other fields', Chain.asStep(component.element(), [ UiFinder.cFindIn(`label:contains("${labelText}") + input`), UiControls.cGetValue, Assertions.cAssertEq('Checking value in input', expected) ]), 100, 1000 ) );
TinyLoader.setup(function (editor, onSuccess, onFailure) { const api = TinyApis(editor); const ui = TinyUi(editor); // Cut doesn't seem to work in webdriver mode on ie, firefox is producing moveto not supported, edge fails if it's not observed Pipeline.async({}, (platform.browser.isIE() || platform.browser.isFirefox() || platform.browser.isEdge()) ? [] : [ api.sSetContent('<p>abc</p>'), api.sSetSelection([0, 0], 1, [0, 0], 2), ui.sClickOnMenu('Click Edit menu', 'button:contains("Edit")'), ui.sWaitForUi('Wait for dropdown', '.mce-floatpanel[role="application"]'), RealMouse.sClickOn('.mce-i-cut'), Waiter.sTryUntil('Cut is async now, so need to wait for content', api.sAssertContent('<p>ac</p>'), 100, 1000) ], onSuccess, onFailure); }, {
TinyLoader.setup(function (editor, onSuccess, onFailure) { const ui = TinyUi(editor); Pipeline.async({}, [ Utils.sOpenDialog(ui), ui.sClickOnUi('Click on close button', 'button:contains("Ok")'), Waiter.sTryUntil( 'Wait for dialog to close', UiFinder.sNotExists(TinyDom.fromDom(document.body), 'div[aria-label="Insert/edit media"][role="dialog"]'), 50, 5000 ) ], onSuccess, onFailure); }, {
const sParseStyles = function (editor) { return Logger.t('Parse styles', GeneralSteps.sequence([ Step.sync(function () { editor.setContent('<html><head><style>p {text-transform: uppercase}</style></head><body dir="rtl"><p>Test</p></body></html>'); }), Waiter.sTryUntil( 'Expected styles were added', Step.sync(function () { Assertions.assertEq('Styles added to iframe document', 'uppercase', editor.dom.getStyle(editor.getBody().firstChild, 'text-transform', true)); Assertions.assertEq('Styles not added to actual element', '', editor.dom.getStyle(editor.getBody().firstChild, 'text-transform', false)); } ), 10, 3000) ])); };
const sClickFocusedButton = function (selector) { return GeneralSteps.sequence([ Waiter.sTryUntil( 'Focus was not moved to the expected element', FocusTools.sIsOnSelector('Is not on the right element', TinyDom.fromDom(document), selector), 10, 1000 ), Chain.asStep(TinyDom.fromDom(document), [ FocusTools.cGetFocused, Mouse.cTrueClick ]) ]); };