Feature: Recover password

    Background:
        Given visit "Home" page
        # clear input fields persistence mechanism (just speeds up the test)
        Given clear browser storages
        When press "Sign In" button at "Page content"
        Then modal of "Sign in the restricted area" dialog opened
        When click "Forgot password?" link at "Sign In form"
        Then modal of "Sign in the restricted area" dialog closed
        * modal of "Forgotten password recovery" dialog opened


    # Path of success

    Scenario: Fulfill password recovery form

        When enter "test@example.com" in "Email" input at "Password recovery form"
        Then button "Recover" at "Password recovery form" is enabled
        When press "Recover" button at "Password recovery form"
        Then modal of "Sign in the restricted area" dialog closed
        * modal of "Data submitted from the form" dialog opened
        # technical field names are used
        * jsonView field "email" contains "test@example.com"


    Scenario: Switch to Sign In dialogue

        When press "Go to Sign In" button at "Password recovery form"
        Then modal of "Forgotten password recovery" dialog closed
        * modal of "Sign in the restricted area" dialog opened


    # Validations testing

    Scenario: Password recovery form validations

        # prepare state of success
        Given enter "test@example.com" in "Email" input at "Password recovery form"
        * button "Recover" at "Password recovery form" is enabled

        Then not see "Required" at "Error message"
        * not see "Must be a valid email address" at "Error message"

        When enter "" in "Email" input at "Password recovery form"
        Then see "Required" at "Error message"
        * button "Recover" at "Password recovery form" is disabled

        When enter "test" in "Email" input at "Password recovery form"
        Then see "Must be a valid email address" at "Error message"
        * button "Recover" at "Password recovery form" is disabled

        When enter "test@example.com" in "Email" input at "Password recovery form"
        Then not see "Must be a valid email address" at "Error message"
        * button "Recover" at "Password recovery form" is enabled
