package cz.moneta.test.dsl.auto.smartauto;

import cz.moneta.test.harness.support.web.*;

import static cz.moneta.test.dsl.auto.smartauto.LoginPage.*;

@Wait(value = {USERNAME_INPUT, PASSWORD_INPUT, LOGIN_BUTTON}, waitSecondsForElement = 40)
public interface LoginPage extends SmartAutoFlow<LoginPage> {

    String USERNAME_INPUT = "//input[@name='username']";
    String PASSWORD_INPUT = "//input[@name='password']";
    String LOGIN_BUTTON = "//button[@type='submit']";
    String UNAUTHORIZED_ACCESS = "//div[contains(text(), 'Neplatné')]";

    @TypeInto(USERNAME_INPUT)
    LoginPage typeUsername(String userName);

    @TypeInto(PASSWORD_INPUT)
    LoginPage typePassword(String password);

    @Click(value = LOGIN_BUTTON, jsClick = true)
    LoginPage clickLoginToFail();

    @Wait(value = UNAUTHORIZED_ACCESS, until = Until.VISIBLE)
    @CheckElementPresent(UNAUTHORIZED_ACCESS)
    LoginPage checkUnauthorizedAccess();

    @Click(value = LOGIN_BUTTON, jsClick = true)
    NewCalculationPage clickLogin();
}