*** 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 ***
Alice is notified about a post she is in
    Given I am logged in as the user guy_hackey
    When I open the Dashboard
    And I write a status update    Hello to you
    Then I can mention the user    Lindström    Alice Lindström
    And I submit the status update
    Then I am logged in as the user alice_lindstrom
    And I can click the notifications toolbar
    And I can follow the notifications link containing    Guy Hackey mentioned you in a post.
    And I can see the notification from Guy Hackey saying Hello to you

Alice can see the notification counter change when somebody mentions her
    Given I am logged in as the user alice_lindstrom
    When I Read All My Notifications
    And A New Notification Arrives
    Then I See I Have One Notification Pending


*** Keywords ***
I can click the notifications toolbar
    Click Link    css=header a#notification-link
    Wait until Page contains Element    css=#notifications-listing

I can follow the notifications link containing
    [Arguments]    ${TEXT}
    Wait until Page contains Element    jquery=#notifications-listing .notification .message:contains("${TEXT}")
    Click Element    jquery=#notifications-listing .notification .message:contains("${TEXT}")

I can see the notification from ${USER} saying ${TEXT}
    Page should contain    ${USER}
    Page should contain    ${TEXT}

I Read All My Notifications
    Go To    ${PLONE_URL}/apps/notifications/@@app-notifications?showall=1

A New Notification Arrives
    Go To    ${PLONE_URL}/@@test_incoming_notification
    Wait Until Page Contains Element    css=#ping-button
    Click Element    css=#ping-button

I See I Have One Notification Pending
    Wait Until Page Contains Element    jquery=#notification-link #online-count:contains(1)
