Jekyll control panel
====================

First some initial setup code:

    >>> from plone.testing.z2 import Browser
    >>> browser = Browser(layer['app'])
    >>> browser.handleErrors = False
    >>> browser.addHeader('Authorization', 'Basic admin:secret')

Viewing the jekyll control panel
--------------------------------

    >>> browser.open('http://nohost/plone/@@jekyll-controlpanel')
    >>> browser.url.endswith('jekyll-controlpanel')
    True

Click the save button without making any changes:

    >>> browser.getControl(name="form.actions.save").click()
    >>> browser.url.endswith('jekyll-controlpanel')
    True

Activating just 2 symptoms
--------------------------

    >>> browser.open('http://nohost/plone/@@jekyll-controlpanel')
    >>> browser.url.endswith('jekyll-controlpanel')
    True

    >>> browser.getControl(name='form.activeSymptoms').value = \
    ...     ['collective.jekyll.symptoms.IdFormatSymptom',
    ...      'collective.jekyll.symptoms.TitleLengthSymptom']

Click the save button:

    >>> browser.getControl(name="form.actions.save").click()
    >>> browser.url.endswith('jekyll-controlpanel')
    True

We should be informed that something has changed:

    >>> 'Changes saved.' in browser.contents
    True

Make sure the changes have been applied correctly to the registry:

    >>> portal = layer['portal']
    >>> records = portal.portal_registry.records
    >>> active = records['collective.jekyll.interfaces.IJekyllSettings.activeSymptoms']
    >>> 'collective.jekyll.symptoms.IdFormatSymptom' in active.value
    True
    >>> 'collective.jekyll.symptoms.TitleLengthSymptom' in active.value
    True
    >>> len(active.value)
    2

The viewlet should be available:

    >>> browser.open('http://nohost/plone/')
    >>> 'ok' in browser.contents
    True

Deactivating all symptoms
-------------------------

    >>> browser.open('http://nohost/plone/@@jekyll-controlpanel')
    >>> browser.url.endswith('jekyll-controlpanel')
    True

    >>> browser.getControl(name='form.activeSymptoms').value = []

Click the save button:

    >>> browser.getControl(name="form.actions.save").click()
    >>> browser.url.endswith('jekyll-controlpanel')
    True

Make sure the changes have been applied correctly to the registry:

    >>> records = portal.portal_registry.records
    >>> active = records['collective.jekyll.interfaces.IJekyllSettings.activeSymptoms']
    >>> len(active.value)
    0

The viewlet shouldn't be available anymore:

    >>> browser.open('http://nohost/plone/')
    >>> 'ok' in browser.contents
    False
