*** Keywords ***

Suite Setup
    Open browser  ${front-page}

Suite Teardown
    Close All Browsers

Log in
    [Documentation]  Log in to the site as ${userid} using ${password}. There
    ...              is no guarantee of where in the site you are once this is
    ...              done. (You are responsible for knowing where you are and
    ...              where you want to be)
    [Arguments]  ${userid}  ${password}

    Go to  ${PLONE_URL}/login_form
    Page should contain element  __ac_name
    Page should contain element  __ac_password
    Page should contain button  Log in
    Input text  __ac_name  ${userid}
    Input text  __ac_password  ${password}
    Click Button  Log in

Log in as site owner
    [Documentation]  Log in as the SITE_OWNER provided by plone.app.testing,
    ...              with all the rights and privileges of that user.
    Log in  ${SITE_OWNER_NAME}  ${SITE_OWNER_PASSWORD}

Create Event
    [Arguments]  ${title}
    Go to  ${test-folder}/++add++Event

    Input text  name=form.widgets.IDublinCore.title  ${title}
    Input text  name=form.widgets.start_date-day  10
    Input text  name=form.widgets.start_date-year  2013
    Input text  name=form.widgets.end_date-day  10
    Input text  name=form.widgets.end_date-year  2013
    
    Click Button  Save
    Page Should Contain  Item created 

Create News Item
    [Arguments]  ${title}
    Go to  ${test-folder}/++add++News Item

    Input text  name=form.widgets.IDublinCore.title  ${title}
    Click Button  Save

    Page Should Contain  Item created 

Create Link
    [Arguments]  ${title}
    Go to  ${test-folder}/++add++Link

    Input text  name=form.widgets.IDublinCore.title  ${title}
    Input text  name=form.widgets.remoteUrl  http://plone.org
    Click Button  Save

    Page Should Contain  Item created 

Create Collection
    [Arguments]  ${title}
    Go to  ${test-folder}/++add++Collection

    Input text  name=form.widgets.IDublinCore.title  ${title}
    Click Button  Save

    Page Should Contain  Item created 

Create Folder
    [Arguments]  ${title}
    Go to  ${test-folder}/++add++Folder

    Input text  name=form.widgets.IDublinCore.title  ${title}
    Click Button  Save

    Page Should Contain  Item created 

Create Document
    [Arguments]  ${title}
    Go to  ${test-folder}/++add++Document

    Input text  name=form.widgets.IDublinCore.title  ${title}
    Click Button  Save

    Page Should Contain  Item created 

Create Image
    [Arguments]  ${title}
    Go to  ${test-folder}/++add++Image

    Input text  name=form.widgets.title  ${title} 
    Choose File  name=form.widgets.image  ${PATH_TO_TEST_FILES}/image.jpg
    Click Button  Save

    Page Should Contain  Item created 
    Page Should Contain  Click to view full-size image 
