*** Settings ***
Variables           variables.py
Resource            plone/app/robotframework/selenium.robot
Resource            plone/app/robotframework/keywords.robot
Resource            ../lib/keywords.robot
Library             Remote    ${PLONE_URL}/RobotRemote
Library             DebugLibrary

Test Setup          Prepare test browser
Test Teardown       Close all browsers


*** Test Cases ***
User can access the calendar app
    Given I am logged in as the user allan_neece
    Then I can go to the calendar application

Christian can create a central calendar
    Given I am logged in as the user christian_stoney
    And I can go to the calendar application
    Then I can create a central calendar    Partner Events    visibility=all
    Given I am in a workspace as a workspace member
    Then I can create a new event for today    Ad-Hoc Meeting
    And I can share the event to a central calendar    Partner Events
    [Teardown]    Delete calendar    Partner Events

Christian can create a central calendar with a maintainer group
    Given I am logged in as the user christian_stoney
    And I can go to the calendar application
    Then I can create a central calendar    Interviews    maintenance=groups    maintainer_group=hr
    Given I am logged in as the user alice_lindstrom
    And I can go to the calendar application
    Then I see the central calendar in the sidebar    Interviews
    And I can change the description of the calendar    Interviews
    [Teardown]    Delete calendar    Interviews

Christian can hide a central calendar
    Given I am logged in as the user dollie_nocera
    And I can go to the calendar application
    Then I see the central calendar in the sidebar    Website Events
    And I see the event as part of a central calendar    Middle of Month Event
    Given I am logged in as the user christian_stoney
    And I can go to the calendar application
    Then I can change the visibility of the calendar    Website Events    visibility=none
    Given I am logged in as the user dollie_nocera
    And I can go to the calendar application
    Then I do not see the central calendar in the sidebar    Website Events
    And I do not see the event as part of a central calendar    Middle of Month Event
    [Teardown]    Restore visibility


*** Keywords ***
Restore visibility
    Given I am logged in as the user christian_stoney
    And I can go to the calendar application
    Then I can change the visibility of the calendar    Website Events    visibility=all

Delete Calendar
    [Arguments]    ${title}
    Given I am logged in as the user christian_stoney
    And I can go to the calendar application
    Then I can delete a central calendar    ${title}
