package cz.moneta.test.dsl.newib.settings.security;

import cz.moneta.test.dsl.newib.NewIbPageFlow;
import cz.moneta.test.dsl.newib.settings.mobileapplication.AboutTheSmartBankaPage;
import cz.moneta.test.harness.support.web.CheckElementPresent;
import cz.moneta.test.harness.support.web.Click;
import cz.moneta.test.harness.support.web.Until;
import cz.moneta.test.harness.support.web.Wait;

import static cz.moneta.test.dsl.newib.settings.security.AuthorizationPage.*;

@Wait(value = {AUTHORIZATION_TITLE_XPATH, SMS_AUTHORIZATION_BTN_XPATH}, waitSecondsForElement = 30, explicitWaitSeconds = 1)
public interface AuthorizationPage extends NewIbPageFlow<AuthorizationPage> {
    String AUTHORIZATION_TITLE_XPATH = "//h2[@class='t-title t-title--h2'][text()='Autorizace']";
    String PUSH_AUTHORIZATION_BTN_XPATH = "//div[@data-testid='pushBox']";
    String SMS_AUTHORIZATION_BTN_XPATH = "//div[@data-testid='smsBox']";
    String CLOSE_MODAL_BTN_XPATH = "//button[@data-testid='settings_modal-close']";
    String SMS_AUTHORIZATION_BTN_XPATH_ACTIVE = "//a[@class='c-tile styles_authorizationCard__3j9QA c-tile--selected']//ancestor::div[@data-testid='smsBox']";
    String PUSH_AUTHORIZATION_BTN_XPATH_ACTIVE = "//a[@class='c-tile styles_authorizationCard__3j9QA c-tile--selected']//ancestor::div[@data-testid='pushBox']";
    String MODAL_TITLE_XPATH = "//h2[@class='t-title t-title--h3 c-modal__title'][text()='Nemáte aktivovanou Smart Banku']";
    String DECLINE_MODAL_BTN_XPATH = "//button[@data-testid='decline-button']";
    String CONFIRM_MODAL_BTN_XPATH = "//button[@data-testid='confirm-button']";

    @Wait(value = PUSH_AUTHORIZATION_BTN_XPATH_ACTIVE, until = Until.GONE)
    @Click(PUSH_AUTHORIZATION_BTN_XPATH)
    AuthorizationPage clickPush();

    @Wait(value = SMS_AUTHORIZATION_BTN_XPATH_ACTIVE, until = Until.GONE)
    @Click(SMS_AUTHORIZATION_BTN_XPATH)
    AuthorizationPage clickSMS();

    @Wait(value = CLOSE_MODAL_BTN_XPATH, until = Until.VISIBLE, explicitWaitSeconds = 1)
    @Click(CLOSE_MODAL_BTN_XPATH)
    AuthorizationPage closeAuthorizationModal();

    @CheckElementPresent(AUTHORIZATION_TITLE_XPATH)
    AuthorizationPage checkAuthorizationTitleIsPresent();

    @CheckElementPresent(MODAL_TITLE_XPATH)
    AuthorizationPage checkModalTitleIsPresent();

    @Click(DECLINE_MODAL_BTN_XPATH)
    AuthorizationPage clickOnDecline();

    @Click(CONFIRM_MODAL_BTN_XPATH)
    AboutTheSmartBankaPage clickOnConfirm();
}
