package cz.moneta.test.dsl.monetaportal.savings.childbuildingsavings;

import cz.moneta.test.harness.endpoints.ib.NewIbEndpoint;
import cz.moneta.test.harness.support.web.*;

import static cz.moneta.test.dsl.monetaportal.savings.childbuildingsavings.PreContractInformationPage.PRE_CONTRACT_LOADER;

@Wait(value = PRE_CONTRACT_LOADER, waitSecondsForElement = 10)
public interface PreContractInformationPage extends ChildBuildingSavingsPageFlow<PreContractInformationPage> {
    String PAGE_HEADER = "//h2[text()='Přečtěte si prosím předsmluvní informace']";
    String PRE_CONTRACT_LOADER = "//div[contains(@class,'c-loader')]/following-sibling::h2[@id='in-page-loader-with-message']";
    String AGREE_AND_CONTINUE = "//button[text()='Souhlasím, pokračovat']";

    @Click(AGREE_AND_CONTINUE)
    ContractPage clickAgreeAndContinue();

    @CustomAction
    default PreContractInformationPage waitToLoad() {
        NewIbEndpoint ep = getEndpoint(NewIbEndpoint.class);
        ep.waitForElementsToLoad(300, Until.GONE, PRE_CONTRACT_LOADER);
        ep.waitForElementsToLoad(5, PAGE_HEADER);
        return null;
    }

}
