package cz.moneta.test.dsl.newib.settings.communication.contacts;

import cz.moneta.test.dsl.newib.NewIbPageFlow;
import cz.moneta.test.dsl.newib.settings.SettingsModalPage;
import cz.moneta.test.harness.support.web.*;

import static cz.moneta.test.dsl.newib.settings.communication.contacts.ChangePasswordPage.*;

@Wait(value = {TITLE_XPATH, TITLE_ALERT_XPATH}, waitSecondsForElement = 30)
public interface ChangePasswordPage extends NewIbPageFlow<ChangePasswordPage> {


    String TITLE_XPATH = "//h1[@class='t-title t-title--h3'][text()='Internet Banka - Změna hesla']";
    String TITLE_ALERT_XPATH = "//div[@class='c-alert c-alert--info u-mt--large u-mb--medium']//small[text()='Své heslo nikdy nikomu nesdělujte. Není vhodné psát si heslo fyzicky na papírek. K zapamatování může pomoci správce hesel – přímo ve Vašem prohlížeči nebo v aplikaci. Pracovníci Moneta Money Bank nikdy nevyžadují sdělení hesla po telefonu.']";
    String PASSWORD_CONDITIONS_XPATH = "//div[@class='col col-5' and .//small[contains(., 'Heslo musí:')] and .//small[contains(., 'Mít minimálně 8 znaků')] and .//small[contains(., 'Obsahovat malé a velké písmeno')] and .//small[contains(., 'Obsahovat alespoň 1 číslici')]]";
    String NEW_PASSWORD_XPATH = "//input[@id='password']";
    String NEW_PASSWORD_AGAIN_XPATH = "//input[@id='passwordAgain']";
    String CONTINUE_BUTTON_XPATH = "//button[@data-testid='submit' and text()='Pokračovat']";
    String IDENTICAL_PASSWORD_VALIDATON_XPATH = "//div[@id='passwordAgain_errorMessage' and text()='Zadaná hesla musí být shodná']";
    String ALREADY_USED_PASSWORD_VALIDATION_XPATH = "//div[@id='password_errorMessage' and text()='Heslo již bylo dříve použité']";
    String MOBILE_KEY_INTO_XPATH = "//label[@for='mobileKey']//following-sibling::div//input[@id='mobileKey']";
    String MOBILE_KEY_SEND_BTN_XPATH = "//button[@data-testid='secondFactorSend']";
    String VICTORY_TITLE_AND_TEXT_XPATH = "//div[@class='c-card__header__text' and .//h4[contains(., 'Hotovo! Vaše heslo do Internet Banky bylo změněno')] and .//p[contains(., 'Dobře si ho zapamatujte a nikomu jej nesdělujte.')]]";
    String BACK_TO_SETTINGS_BUTTON_XPATH = "//button[@data-testid='submit' and text()='Zpět na Nastavení']";

    @CheckElementPresent(PASSWORD_CONDITIONS_XPATH)
    ChangePasswordPage checkPasswordConditions();

    @TypeInto(value = NEW_PASSWORD_XPATH, clear = true)
    ChangePasswordPage fillNewPassword(String password);

    @TypeInto(value = NEW_PASSWORD_AGAIN_XPATH, clear = true)
    ChangePasswordPage fillNewPasswordAgain(String password);

    @Click(CONTINUE_BUTTON_XPATH)
    ChangePasswordPage clickOnContinue();

    @Click(NEW_PASSWORD_XPATH)
    ChangePasswordPage clickOnPasswordField();

    @CheckElementPresent(IDENTICAL_PASSWORD_VALIDATON_XPATH)
    ChangePasswordPage checkIdenticalPasswordValidation();

    @CheckElementPresent(ALREADY_USED_PASSWORD_VALIDATION_XPATH)
    ChangePasswordPage checkAlreadyUsedPasswordValidation();

    @TypeInto(MOBILE_KEY_INTO_XPATH)
    ChangePasswordPage fillMobileKey(String mobileKey);

    @Click(MOBILE_KEY_SEND_BTN_XPATH)
    ChangePasswordPage clickOnContinueMobileKey();

    @CheckElementPresent(VICTORY_TITLE_AND_TEXT_XPATH)
    ChangePasswordPage checkVictoryTitleAndText();

    @Click(BACK_TO_SETTINGS_BUTTON_XPATH)
    SettingsModalPage clickOnBackToSettingsButton();
}