kotti_etherpad browser tests
============================

Setup and Login
---------------

  >>> from kotti import tests
  >>> tools = tests.setUpFunctional(
  ...     **{'kotti.configurators': 'kotti_etherpad.kotti_configure'})
  >>> browser = tools['Browser']()
  >>> ctrl = browser.getControl

  >>> browser.open(tests.BASE_URL + '/@@login')
  >>> "Log in" in browser.contents
  True
  >>> ctrl("Username or email").value = "admin"
  >>> ctrl("Password").value = "secret"
  >>> ctrl(name="submit").click()
  >>> "Welcome, Administrator" in browser.contents
  True

Add a etherpad
--------------

  >>> browser.open(tests.BASE_URL + '/@@add_etherpad')
  >>> ctrl("Title").value = "New Etherpad"
  >>> ctrl("Description").value = "This is the etherpad"
  >>> ctrl("Pad ID").value = "hello"
  >>> ctrl("Domain").value = "http://localhost"
  >>> ctrl("Port").value = "1234"
  >>> ctrl("Width").value = "100%"
  >>> ctrl("Height").value = "800px"
  >>> ctrl(name="border").value = "0"
  >>> ctrl("Border Style").value = "solid"
  >>> ctrl("save").click()
  >>> browser.url == tests.BASE_URL + '/new-etherpad/'
  True
  >>> "Successfully added item" in browser.contents
  True


View etherpad
-------------

  >>> browser.open(tests.BASE_URL + '/new-etherpad/')
  >>> "This is the etherpad" in browser.contents
  True
  >>> "'host': 'http://localhost:1234'" in browser.contents
  True
  >>> "'baseUrl': '/p/'" in browser.contents
  True
  >>> "'showControls': true" in browser.contents
  True
  >>> "'showChat': true" in browser.contents
  True
  >>> "'showLineNumbers': true" in browser.contents
  True
  >>> "'userName': 'Administrator'" in browser.contents
  True
  >>> "'useMonospaceFont': true" in browser.contents
  True
  >>> "'noColors': false" in browser.contents
  True
  >>> "'hideQRCode': false" in browser.contents
  True
  >>> "'width': '100%'" in browser.contents
  True
  >>> "'height': '800px'" in browser.contents
  True
  >>> "'border': '0'" in browser.contents
  True
  >>> "'borderStyle': 'solid'" in browser.contents
  True
  >>> "'padId': 'hello'" in browser.contents
  True


Edit etherpad
-------------

  >>> browser.open(tests.BASE_URL + '/new-etherpad/@@edit')
  >>> ctrl("Description").value = "This is the etherpad edited"
  >>> ctrl("save").click()
  >>> browser.url == tests.BASE_URL + '/new-etherpad/'
  True
  >>> "This is the etherpad edited" in browser.contents
  True


Set domain with username and password
-------------------------------------

  >>> browser.open(tests.BASE_URL + '/new-etherpad/@@edit')
  >>> ctrl("Domain").value = "http://fromadmin:withlove@localhost"
  >>> ctrl("save").click()
  >>> browser.url == tests.BASE_URL + '/new-etherpad/'
  True
  >>> "This is the etherpad edited" in browser.contents
  True


Check if the username or Anonymous is used for settings
-------------------------------------------------------

  >>> browser.open(tests.BASE_URL + '/new-etherpad')
  >>> "'userName': 'Administrator'," in browser.contents
  True

  >>> browser.open(tests.BASE_URL + '/logout')
  >>> "You have been logged out." in browser.contents
  True

  >>> browser.open(tests.BASE_URL + '/new-etherpad')
  >>> "'userName': 'Administrator'," in browser.contents
  False
  >>> "'userName': 'Anonymous user'," in browser.contents
  True
