CKEditor configuration
======================

Log in as manager

    >>> from plone.testing.z2 import Browser
    >>> from plone.app.testing import SITE_OWNER_NAME
    >>> from plone.app.testing import SITE_OWNER_PASSWORD
    >>> app = layer['app']
    >>> portal = layer['portal']
    >>> browser = Browser(app)
    >>> browser.open('http://nohost/plone/login_form')
    >>> browser.getControl('Login Name').value = SITE_OWNER_NAME
    >>> browser.getControl('Password').value = SITE_OWNER_PASSWORD
    >>> browser.getControl('Log in').click()

First just get ckeditor properties sheet :

    >>> ptool = portal.portal_properties
    >>> ckeditor_props = ptool.ckeditor_properties

We will try to get javascript configuration using testbrowser
The javascript code must depend on ckeditor_props.

    >>> portal_url = portal.absolute_url()
    >>> portal.error_log._ignored_exceptions = ()
    >>> import transaction
    >>> transaction.commit()

Test ckeditor finder configuration
==================================

    >>> browser.open('%s/ckeditor_plone_config.js' % portal_url)
    >>> js_string = "config.filebrowserImageBrowseUrl='" + portal_url + "/@@plone_ckfinder?typeview=image&media=image&types:list=Image'"
    >>> js_string in browser.contents
    True

Remove 'News Item' portal_type for browsing images in ckeditor_properties

    >>> ckeditor_props.manage_changeProperties(REQUEST=None, browse_images_portal_types = ['Image', 'News Item'])
    >>> transaction.commit()

Get the javascript config file

    >>> browser.open('%s/ckeditor_plone_config.js' %portal_url)
    >>> js_string = "config.filebrowserImageBrowseUrl='" + portal_url + "/@@plone_ckfinder?typeview=image&media=image&types:list=Image&types:list=News%20Item'"
    >>> js_string in browser.contents
    True

Test Area style sheets configuration
====================================

We set first portal_css in debug mode 

    >>> portal.portal_css.setDebugMode(True)

    >>> browser.open('%s/ckeditor_plone_config.js' %portal_url)

By default we must find all portal_css stylesheet in javascript configuration

    >>> 'base.css' in browser.contents
    True
    >>> 'public.css' in browser.contents
    True

By default we must also find a specific css for plone ckeditor area

    >>> 'ckeditor_plone_area.css' in browser.contents
    True


Test CKEditor area body ID
==========================

To get real wysiwyg by default editor area has the same id
as Plone content. We must find it in javascript config file.

    >>> "config.bodyId='content'" in browser.contents
    True

Test Combo Menu Styles
======================

A specific style menu must be set in javascript which
depends on ckeditor control panel config.

    >>> global_styles_config = "config.stylesSet='plone:%s/ckeditor_plone_menu_styles.js'" %portal_url
    >>> global_styles_config in browser.contents
    True


Absolute URL stylesheets
========================

If an external stylesheet is registered with an absolute URL,
it should be left alone (portal_url should not be concatenated).

    >>> ABSOLUTE_URL = 'http://style.plone.org/external.css'
    >>> portal.portal_css.registerStylesheet(ABSOLUTE_URL)
    >>> transaction.commit()
    >>> browser.open('%s/ckeditor_plone_config.js' %portal_url)
    >>> (",\'%s\'," % ABSOLUTE_URL) in browser.contents
    True

