# ============================================================================
# DEXTERITY ROBOT TESTS
# ============================================================================
#
# Run this robot test stand-alone:
#
#  $ bin/test -s {{{ package.dottedname }}} -t test_{{{ dexterity_type_name_normalized }}}.robot --all
#
# Run this robot test with robot server (which is faster):
#
# 1) Start robot server:
#
# $ bin/robot-server --reload-path src {{{ package.dottedname }}}.testing.{{{ package.uppercasename }}}_ACCEPTANCE_TESTING
#
# 2) Run robot tests:
#
# $ bin/robot {{{ package_folder_rel_path }}}/tests/robot/test_{{{ dexterity_type_name_normalized }}}.robot
#
# See the http://docs.plone.org for further details (search for robot
# framework).
#
# ============================================================================

*** Settings *****************************************************************

Resource  plone/app/robotframework/selenium.robot
Resource  plone/app/robotframework/keywords.robot

Library  Remote  ${PLONE_URL}/RobotRemote

Test Setup  Open test browser
Test Teardown  Close all browsers


*** Test Cases ***************************************************************

Scenario: As a site administrator I can add a {{{ dexterity_type_name }}}
  Given a logged-in site administrator
{{% if not dexterity_type_global_allow | to_boolean %}}
    and an add {{{ dexterity_parent_container_type_name }}} form
{{% else %}}
    and an add {{{ dexterity_type_name }}} form
{{% endif %}}
   When I type 'My {{{ dexterity_type_name }}}' into the title field
    and I submit the form
   Then a {{{ dexterity_type_name }}} with the title 'My {{{ dexterity_type_name }}}' has been created

Scenario: As a site administrator I can view a {{{ dexterity_type_name }}}
  Given a logged-in site administrator
    and a {{{ dexterity_type_name }}} 'My {{{ dexterity_type_name }}}'
   When I go to the {{{ dexterity_type_name }}} view
   Then I can see the {{{ dexterity_type_name }}} title 'My {{{ dexterity_type_name }}}'


*** Keywords *****************************************************************

# --- Given ------------------------------------------------------------------

a logged-in site administrator
  Enable autologin as  Site Administrator

{{% if not dexterity_type_global_allow | to_boolean %}}
an add {{{ dexterity_parent_container_type_name }}} form
  Go To  ${PLONE_URL}/++add++{{{ dexterity_parent_container_type_name }}}
{{% else %}}
an add {{{ dexterity_type_name }}} form
  Go To  ${PLONE_URL}/++add++{{{ dexterity_type_name }}}
{{% endif %}}

{{% if not dexterity_type_global_allow | to_boolean %}}
a {{{ dexterity_type_name }}} 'My {{{ dexterity_type_name }}}'
  Create content  type={{{ dexterity_parent_container_type_name }}}  id=my-{{{ dexterity_type_name_normalized }}}  title=My {{{ dexterity_type_name }}}
{{% else %}}
a {{{ dexterity_type_name }}} 'My {{{ dexterity_type_name }}}'
  Create content  type={{{ dexterity_type_name }}}  id=my-{{{ dexterity_type_name_normalized }}}  title=My {{{ dexterity_type_name }}}
{{% endif %}}

# --- WHEN -------------------------------------------------------------------

I type '${title}' into the title field
  Input Text  name=form.widgets.IBasic.title  ${title}

I submit the form
  Click Button  Save

I go to the {{{ dexterity_type_name }}} view
  Go To  ${PLONE_URL}/my-{{{ dexterity_type_name_normalized }}}
  Wait until page contains  Site Map


# --- THEN -------------------------------------------------------------------

a {{{ dexterity_type_name }}} with the title '${title}' has been created
  Wait until page contains  Site Map
  Page should contain  ${title}
  Page should contain  Item created

I can see the {{{ dexterity_type_name }}} title '${title}'
  Wait until page contains  Site Map
  Page should contain  ${title}

