package cz.moneta.test.dsl.dmbsib;

import cz.moneta.test.harness.context.StoreAccessor;
import cz.moneta.test.harness.support.web.Click;
import cz.moneta.test.harness.support.web.Page;
import cz.moneta.test.harness.support.web.TypeInto;
import cz.moneta.test.harness.support.web.Until;
import cz.moneta.test.harness.support.web.Wait;
import cz.moneta.test.harness.support.web.WebFlow;

import static cz.moneta.test.dsl.dmbsib.LoginPage.MONETA_LOGO_XPATH;

@Wait(MONETA_LOGO_XPATH)
public interface LoginPage extends WebFlow<LoginPage>, StoreAccessor {

    String MONETA_LOGO_XPATH = "//img[@alt='MONETA logo']";
    String LOGIN_INPUT = "//input[@name='id']";
    String PASSWORD_INPUT = "//input[@name='password']";
    String SEND_MOBILE_KEY_BUTTON = "//button//span[contains(text(), 'Odeslat mobilní klíč')]";
    String VERIFY_MOBILE_KEY = "//button//span[contains(text(), 'Ověřit mobilní klíč')]";
    String MOBILE_KEY_INPUT = "//input[@name='smsKey']";

    @TypeInto(LOGIN_INPUT)
    LoginPage fillLogin(String login);

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

    @Click(value = SEND_MOBILE_KEY_BUTTON, andWait = @Wait(value = VERIFY_MOBILE_KEY, until = Until.VISIBLE))
    LoginPage clickSendMobileKey();

    @TypeInto(MOBILE_KEY_INPUT)
    LoginPage fillMobileKey(String mobileKey);

    @Click(VERIFY_MOBILE_KEY)
    @Page(ConfirmPaymentOrderPage.class)
    ConfirmPaymentOrderPage clickVerifyMobileKeyAndContinueToSubmitOrder();

    @Page(ConfirmPaymentOrderPage.class)
    ConfirmPaymentOrderPage continueToSubmitOrder();
}
