import { GeneralSteps, Logger, Pipeline, Step } from '@ephox/agar'; import { UnitTest } from '@ephox/bedrock'; import { TinyApis, TinyLoader, TinyUi } from '@ephox/mcagar'; import TemplatePlugin from 'tinymce/plugins/template/Plugin'; import ModernTheme from 'tinymce/themes/modern/Theme'; UnitTest.asynctest('browser.tinymce.plugins.template.DatesTest', function () { const success = arguments[arguments.length - 2]; const failure = arguments[arguments.length - 1]; ModernTheme(); TemplatePlugin(); TinyLoader.setup(function (editor, onSuccess, onFailure) { const tinyUi = TinyUi(editor); const tinyApis = TinyApis(editor); const sDeleteSetting = function (key) { return Step.sync(function () { delete editor.settings[key]; }); }; Pipeline.async({}, [ Logger.t('test cdate in snippet with default class', GeneralSteps.sequence([ tinyApis.sSetSetting('templates', [{ title: 'a', description: 'b', content: '
x
' }]), tinyApis.sSetSetting('template_cdate_format', 'fake date'), tinyUi.sClickOnToolbar('click on template button', 'div[aria-label="Insert template"] > button'), tinyUi.sWaitForPopup('wait for popup', 'div[role="dialog"][aria-label="Insert template"]'), tinyUi.sClickOnUi('click on ok button', 'div.mce-primary button'), tinyApis.sAssertContent('fake date
'), tinyApis.sSetContent('') ])), Logger.t('test cdate in snippet with custom class', GeneralSteps.sequence([ tinyApis.sSetSetting('template_cdate_classes', 'customCdateClass'), tinyApis.sSetSetting('templates', [{ title: 'a', description: 'b', content: 'x
' }]), tinyApis.sSetSetting('template_cdate_format', 'fake date'), tinyUi.sClickOnToolbar('click on template button', 'div[aria-label="Insert template"] > button'), tinyUi.sWaitForPopup('wait for popup', 'div[role="dialog"][aria-label="Insert template"]'), tinyUi.sClickOnUi('click on ok button', 'div.mce-primary button'), tinyApis.sAssertContent('fake date
'), sDeleteSetting('template_cdate_classes'), sDeleteSetting('templates'), sDeleteSetting('template_cdate_format'), tinyApis.sSetContent('') ])), Logger.t('test mdate updates with each serialization', GeneralSteps.sequence([ tinyApis.sSetSetting( 'templates', [{ title: 'a', description: 'b', content: 'fake modified date
fake created date
changed modified date
fake created date
fake modified date
fake created date
changed modified date
fake created date