## $Id: test_browser.py 10929 2014-01-15 12:50:07Z henrik $
##
## Copyright (C) 2011 Uli Fouquet & Henrik Bettermann
## This program is free software; you can redistribute it and/or modify
## it under the terms of the GNU General Public License as published by
## the Free Software Foundation; either version 2 of the License, or
## (at your option) any later version.
##
## This program is distributed in the hope that it will be useful,
## but WITHOUT ANY WARRANTY; without even the implied warranty of
## MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
## GNU General Public License for more details.
##
## You should have received a copy of the GNU General Public License
## along with this program; if not, write to the Free Software
## Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
##
import grok
from zope.event import notify
from zope.component import createObject, getUtility
from waeup.aaue.testing import FunctionalLayer
from waeup.kofa.applicants.tests.test_browser import (
    ApplicantsFullSetup, container_name_1)

class CustomApplicantUITest(ApplicantsFullSetup):
    """Perform some browser tests.
    """

    layer = FunctionalLayer

    def test_show_credentials_on_landing_page(self):
        # An applicant can register himself.
        self.applicant.reg_number = u'1234'
        notify(grok.ObjectModifiedEvent(self.applicant))
        self.browser.open('http://localhost/app/applicants/%s/' % container_name_1)
        self.browser.getLink("Register for application").click()
        # Fill the edit form with suitable values
        self.browser.getControl(name="form.firstname").value = 'Klaus'
        self.browser.getControl(name="form.lastname").value = 'Lutz'
        self.browser.getControl(name="form.email").value = 'xx@yy.zz'
        self.browser.getControl("Send login credentials").click()
        self.assertMatches('...Your registration was successful...',
            self.browser.contents)
        self.assertTrue('<td>Password:</td>' in self.browser.contents)
        return
