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

import cz.moneta.test.dsl.newib.NewIbPageFlow;
import cz.moneta.test.dsl.newib.components.VerticalMainMenu;
import cz.moneta.test.harness.context.StoreAccessor;
import cz.moneta.test.harness.endpoints.ib.NewIbEndpoint;
import cz.moneta.test.harness.support.web.CheckElementPresent;
import cz.moneta.test.harness.support.web.CustomAction;
import cz.moneta.test.harness.support.web.Wait;

import static cz.moneta.test.dsl.newib.mainpage.LoansAndMortgagesPage.*;
import static org.junit.jupiter.api.Assertions.assertTrue;

@Wait({YOU_MIGHT_BE_INTERESTED_XPATH})
public interface LoansAndMortgagesPage extends NewIbPageFlow<LoansAndMortgagesPage>, StoreAccessor, VerticalMainMenu {

    String LOANS_AND_MORTGAGES_TITLE_XPATH = "//h1[@class='t-title t-title--h5 u-ml--small'][text()='Půjčky a hypotéky']";
    String YOU_MIGHT_BE_INTERESTED_XPATH = "//h1[@class='t-title t-title--h5 u-ml--small'][text()='Výhodné nabídky pro Vás']";
    String CONSOLIDATION_BANNER_XPATH = "//div[@data-testid='newProductCard-consolidation']";
    String MORTGAGE_BANNER_XPATH = "//div[@data-testid='newProductCard-mortgage']";
    String LEASING_BANNER_XPATH = "//div[@data-testid='newProductCard-leasing']";


    @CustomAction
    default LoansAndMortgagesPage checkUrl() {
        NewIbEndpoint newIbEndpoint = getEndpoint(NewIbEndpoint.class);
        String actualUrl = newIbEndpoint.getCurrentUrl();
        String urlContains = "loans-and-mortgages";
        assertTrue(actualUrl.contains(urlContains));
        return null;
    }

    @CheckElementPresent(CONSOLIDATION_BANNER_XPATH)
    LoansAndMortgagesPage checkConsolidationBannerIsPresent();

    @CheckElementPresent(MORTGAGE_BANNER_XPATH)
    LoansAndMortgagesPage checkMortgageBannerIsPresent();

    @CheckElementPresent(LEASING_BANNER_XPATH)
    LoansAndMortgagesPage checkLeasingBannerIsPresent();
}
