package cz.moneta.test.dsl.newib.savings;

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

import static cz.moneta.test.dsl.newib.savings.DpsStaticDocumentsAndContractPage.STATIC_DOCUMENTS_TITLE_XPATH;
import static cz.moneta.test.dsl.newib.savings.DpsStaticDocumentsAndContractPage.STATIC_DOCUMENTS_PAGE_HEADER_XPATH;
import static cz.moneta.test.dsl.newib.savings.DpsStaticDocumentsAndContractPage.PRECONTRACTUAL_INFORMATION_DOCUMENT_XPATH;
import static cz.moneta.test.dsl.newib.savings.DpsStaticDocumentsAndContractPage.PRECONTRACTUAL_INFORMATION_SFDR_DOCUMENT_XPATH;

@Wait(value ={STATIC_DOCUMENTS_TITLE_XPATH, STATIC_DOCUMENTS_PAGE_HEADER_XPATH, PRECONTRACTUAL_INFORMATION_DOCUMENT_XPATH, PRECONTRACTUAL_INFORMATION_SFDR_DOCUMENT_XPATH}, waitSecondsForElement = 30)
public interface DpsStaticDocumentsAndContractPage extends NewIbPageFlow<DpsStaticDocumentsAndContractPage> {

    String STATIC_DOCUMENTS_PAGE_HEADER_XPATH = "//h1[@data-testid='dps-shared-staticdocuments-header' and text()='Doplňkové penzijní spoření']";
    String STATIC_DOCUMENTS_TITLE_XPATH = "//h2[@data-testid='dps-shared-staticdocuments-title' and text()='Před pokračováním si prosím přečtěte následující dokumenty']";
    String PRECONTRACTUAL_INFORMATION_DOCUMENT_XPATH = "//button[@class='c-link' and text()='Předsmluvní informace k doplňkovému penzijnímu spoření']";
    String PRECONTRACTUAL_INFORMATION_SFDR_DOCUMENT_XPATH = "//button[@class='c-link' and text()='Předsmluvní informace k SFDR']";
    String CONTINUE_TO_SIGNATURE_BUTTON_XPATH = "//button[@data-testid='dps-shared-staticdocuments-btn-next' and text()='Pokračovat k podpisu']";
    String CONTRACT_TITLE_XPATH = "//h2[@data-testid='dps-shared-contract-title' and text()='Přečtěte si smlouvu o změně parametrů Doplňkového penzijního spoření']";
    String AGREE_CONTINUE_BUTTON_XPATH = "//button[@data-testid='dps-shared-contract-btn-next' and text()='Souhlasím, pokračovat k podpisu']";
    String MOBILE_KEY_INTO_XPATH = "//label[@for='mobileKey']//following-sibling::div//input[@id='mobileKey']";
    String CONTINUE_MOBILE_KEY_BUTTON_XPATH = "//button[@data-testid='secondFactorSend']";

    @Wait(value = CONTRACT_TITLE_XPATH, until = Until.VISIBLE)
    @CheckElementPresent(CONTRACT_TITLE_XPATH)
    DpsStaticDocumentsAndContractPage checkContractTitle();

    @Click(AGREE_CONTINUE_BUTTON_XPATH)
    DpsStaticDocumentsAndContractPage clickOnAgreeContinuebutton();

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

    @Click(CONTINUE_MOBILE_KEY_BUTTON_XPATH)
    DpsVictoryPage clickContinueMobileKey();

    @Click(value = CONTINUE_TO_SIGNATURE_BUTTON_XPATH, andWait = @Wait(value = CONTRACT_TITLE_XPATH, waitSecondsForElement = 30))
    DpsStaticDocumentsAndContractPage clickOnContinueToSignatureButton();
}