Functional Tests
================

Set Up
------

Make this test available as a module so that stuff defined in here can
be pickled properly:

    >>> from zope.testing import module
    >>> module.setUp(test, name='five.localsitemanager.browsertest')

Load all of Five's configuration (this is a functional test):

    >>> import Products.Five
    >>> import five.localsitemanager
    >>> from Products.Five.zcml import load_config, load_string
    >>> load_config('configure.zcml', package=Products.Five)
    >>> load_config('configure.zcml', package=five.localsitemanager)
    >>> load_string('<includeOverrides package="five.localsitemanager" file="overrides.zcml" />')

Enable local component lookup hooks:

    >>> from zope.site.hooks import setHooks
    >>> setHooks()

User Set Up
-----------

    >>> uf = app.acl_users
    >>> uf._doAddUser('admin', 'admin', ['Manager'], [])

Create the test browser we'll be using:

    >>> from Products.Five.testbrowser import Browser
    >>> browser = Browser()
    >>> browser.addHeader('Authorization', 'Basic admin:admin')

Folder Set Up
-------------

Make a folder to use as a local site for component registration:

    >>> browser.open('http://localhost/manage_addProduct/OFSP/folderAdd')
    >>> browser.getControl(name='id').value = 'folder'
    >>> browser.getControl('Add').click()
    >>> browser.getLink('folder').click()

Look up the ``components.html`` view and make sure the ``Make Site`` action
still works.

    >>> browser.open('http://localhost/folder/components.html')
    >>> browser.getControl('Make site').click()

Make sure the site manager trail only leads back to the global component
registry.

    >>> '<dd class="sitemanager-trail">Global Registry =&gt; &lt;PersistentComponents /folder&gt;</dd>' in browser.contents
    True

Now we add a sub folder.

    >>> browser.open('http://localhost/folder/manage_addProduct/OFSP/folderAdd')
    >>> browser.getControl(name='id').value = 'subfolder'
    >>> browser.getControl('Add').click()
    >>> browser.getLink('folder').click()

    >>> browser.open('http://localhost/folder/subfolder/components.html')
    >>> browser.getControl('Make site').click()

    >>> '<dd class="sitemanager-trail">Global Registry =&gt; &lt;PersistentComponents /folder&gt; =&gt; &lt;PersistentComponents /folder/subfolder&gt;</dd>' in browser.contents
    True

Clean up
--------

    >>> module.tearDown(test, name='five.localsitemanager.browsertest')
    >>> from zope.testing.cleanup import cleanUp
    >>> cleanUp()
