collective.portaltabs usage: edit many entries
==============================================

Setup:

>>> from pyquery import PyQuery
>>> from plone.testing.z2 import Browser
>>> app = layer['app']
>>> portal = layer['portal']
>>> browser = Browser(app)
>>> browser.handleErrors = False

Now login:

>>> browser.open(portal.portal_url() + '/login_form')
>>> browser.getControl(name='__ac_name').value = 'sa_user'
>>> browser.getControl(name='__ac_password').value = 'secret'
>>> browser.getControl(name='submit').click()

We manually prepare another portal tab for testing purpose:

>>> browser.open(portal.portal_url() + '/@@manage-portaltabs')
>>> browser.getControl(name='title').value = 'Accessibility info page'
>>> browser.getControl(name='url').value = '/accessibility-info'
>>> browser.getControl('Add').click()

Edit more than a value at once
------------------------------

Go the the tabs management:

>>> browser.open(portal.portal_url() + '/@@manage-portaltabs')

Now editing the "Home" link title and the "Accessibility info page" URL.

>>> browser.getControl(name='title:list', index=0).value = 'A Great Homepage Site!'
>>> browser.getControl(name='url:list', index=1).value = portal.portal_url() + '/@@manage-portaltabs?foo=5'
>>> browser.getControl('Save').click()
>>> 'Changes saved' in browser.contents
True
>>> pq = PyQuery(browser.contents)
>>> pq('#portal-globalnav #portaltab-index_html').text()
'A Great Homepage Site!'
>>> browser.getLink('A Great Homepage Site!').click()
>>> browser.url == portal.portal_url()
True
>>> pq = PyQuery(browser.contents)
>>> pq('#portal-globalnav #portaltab-accessibility-info-page').text()
'Accessibility info page'
>>> browser.getLink('Accessibility info page').click()
>>> browser.url == portal.portal_url() + '/@@manage-portaltabs?foo=5'
True

Multiple validation
-------------------

Required fields are checked for all provided data.
If we don't provide the "Home" link URL and the "Accessibility info" link title, we get both errors:

>>> browser.open(portal.portal_url() + '/@@manage-portaltabs')
>>> browser.getControl(name='url:list', index=0).value = ''
>>> browser.getControl(name='title:list', index=1).value = ''
>>> browser.getControl('Save').click()
>>> 'Please correct the indicated errors.' in browser.contents
True
>>> pq = PyQuery(browser.contents)
>>> 'URL field is required, please provide it.' in pq('#fieldset-portal_tabs .tabSetup:first').text()
True
>>> browser.getControl(name='url:list', index=0).value
'/'
>>> 'Title field is required, please provide it.' in pq('#fieldset-portal_tabs .tabSetup:last').text()
True
>>> browser.getControl(name='title:list', index=1).value
'Accessibility info page'


