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

First just get ckeditor properties sheet :

    >>> self.loginAsManager()
    >>> ptool = self.ptool
    >>> ckeditor_props = ptool.ckeditor_properties

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

    >>> from Products.Five.testbrowser import Browser
    >>> browser = Browser()
    >>> portal_url = self.portal.absolute_url()
    >>> self.portal.error_log._ignored_exceptions = ()

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'])

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 

    >>> self.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'
    >>> self.portal.portal_css.registerStylesheet(ABSOLUTE_URL)
    >>> browser.open('%s/ckeditor_plone_config.js' %portal_url)
    >>> (",\'%s\'," % ABSOLUTE_URL) in browser.contents
    True

