port module Main exposing (..)

import Html
import Html.App as App
import Webdriver as W exposing (..)
import Webdriver.Assert exposing (..)
import Webdriver.Runner as R exposing (..)
import Expect exposing (equal)


main : Program Never
main =
    App.program
        { init = begin basicOptions tests
        , update = R.update
        , view = \_ -> Html.text ""
        , subscriptions = always Sub.none
        }


tests =
    group "Bownty V5"
        [ landingPagePubuid, categoryNavigation ]


landingPagePubuid =
    describe "Landing Page - PubUID (Organic)"
        [ visit "https://uk.1.bownty.qa"
        , cookieExists "pubuid"
        , cookie "pubuid" <| equal "3"
        ]


categoryNavigation =
    describe " Top Menu, Category Navigation"
        [ visit "https://bownty.pt/lisboa"
        , click "button.l-right"
        , moveTo "li.nav-main-large__item:nth-child(1)"
        , moveTo restaurantsLink
        , click restaurantsLink
        , url <| equal "https://bownty.pt/lisboa/restaurantes"
        ]


restaurantsLink =
    "//*[@id='js-page']/div[1]/div/header/div/div/div[2]/ul/li[1]/div/ul/li[2]/ul/li[1]/a/div"
