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

Testing functionality of garbas.forum.

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

Login as admin, set that users can register and select their own password. At
the same time create normal portal member (Membes role)

    >>> from Products.PloneTestCase.setup import portal_owner, default_password
    >>> browser.open(portal_url)
    >>> browser.getControl(name='__ac_name').value = portal_owner
    >>> browser.getControl(name='__ac_password').value = default_password
    >>> browser.getControl(name='submit').click()
    >>> browser.url == portal_url
    True

    >>> browser.open(portal_url+'/@@security-controlpanel')
    >>> browser.getControl(name='form.enable_self_reg').value = True
    >>> browser.getControl(name='form.enable_user_pwd_choice').value = True
    >>> browser.getControl('Save').click()
    
    >>> browser.open(portal_url+'/join_form')
    >>> browser.getControl('Full Name').value = 'Rok Garbas'
    >>> browser.getControl('User Name').value = 'garbas'
    >>> browser.getControl('E-mail').value = 'rok.garbas@gmail.com'
    >>> browser.getControl('Password').value = 'password'
    >>> browser.getControl('Confirm password').value = 'password'
    >>> browser.getControl('Register').click()


Create initial structure. Main forum container with two subforums.

    >>> browser.open(portal_url)
    >>> browser.getLink(id='forum').click()
    >>> browser.getControl(name='title').value = 'Forum'
    >>> browser.getControl(name='categories:lines').value = 'Category 1\nCategory 2'
    >>> browser.getControl(name='allow_addtopic:boolean').value = False
    >>> browser.getControl('Save').click()
    >>> browser.url == portal_url+'/forum'
    True

    >>> browser.getLink(id='forum').click()
    >>> browser.getControl(name='title').value = 'Subforum 1'
    >>> browser.getControl(name='category').value = ['Category 1']
    >>> browser.getControl('Save').click()
    >>> browser.url == portal_url+'/forum/subforum-1'
    True

    >>> browser.open(portal_url+'/forum')
    >>> browser.getLink(id='forum').click()
    >>> browser.getControl(name='title').value = 'Subforum 2'
    >>> browser.getControl(name='category').value = ['Category 2']
    >>> browser.getControl('Save').click()
    >>> browser.url == portal_url+'/forum/subforum-2'
    True

Logout and login as normal portal member

    >>> browser.open(portal_url+'/logout')
    >>> browser.open(portal_url)
    >>> browser.getControl(name='__ac_name').value = 'garbas'
    >>> browser.getControl(name='__ac_password').value = 'password'
    >>> browser.getControl(name='submit').click()
    >>> browser.url == portal_url
    True

Now lets add new topic and reply.

    >>> browser.open(portal_url+'/forum/subforum-1')
    >>> browser.getControl('New Topic').click()
    >>> browser.getControl(name='topic_title').value = 'Topic 1'
    >>> browser.getControl(name='topic_text').value = 'Text for Topic 1'
    >>> browser.getControl('Submit').click()

TODO :: why is this test failing, maybe because of redirect handling

    >>> 'Topic was successfuly added.' in browser.contents
    True

    >>> browser.getControl('Post Reply').click()
    >>> browser.getControl(name='post_title').value = 'What is Topic 1'
    >>> browser.getControl(name='post_text').value = 'Text for reply to Topic'
    >>> browser.getControl('Submit').click()
    >>> 'Post was successfuly added.' in browser.contents
    True


