package cz.moneta.test.dsl.ufo.banka.pages.products.one.click;

import cz.moneta.test.dsl.ufo.banka.pages.common.pages.TIS027_OBR001_PreContractualInformationPage;
import cz.moneta.test.harness.context.StoreAccessor;
import cz.moneta.test.harness.endpoints.ufo.UfoEndpoint;
import cz.moneta.test.harness.support.web.Click;
import cz.moneta.test.harness.support.web.CustomAction;
import cz.moneta.test.harness.support.web.Until;
import cz.moneta.test.harness.support.web.Wait;
import cz.moneta.test.harness.support.web.WebFlow;

import static cz.moneta.test.dsl.ufo.banka.pages.products.one.click.BAL023_S002_RecapitulationOfClientDataPage.CONTINUE_BUTTON;

@Wait(value = CONTINUE_BUTTON, waitSecondsForElement = 30)
public interface BAL023_S002_RecapitulationOfClientDataPage extends WebFlow<BAL023_S002_RecapitulationOfClientDataPage>, StoreAccessor {

    String CONTINUE_BUTTON = "BAL023_S002_B003";
    String LOG_BUTTON = "XXX001_T001_P102";
    String LOADER_IMG = "CAS001_S001_P001";

    @Click(CONTINUE_BUTTON)
    TIS027_OBR001_PreContractualInformationPage clickContinue();

    @CustomAction
    default void clickContinueAndWaitUntilLoaded() {
        UfoEndpoint endpoint = getEndpoint(UfoEndpoint.class);
        endpoint.click(() -> CONTINUE_BUTTON);
        endpoint.waitForElementsToLoad(15, Until.VISIBLE, LOADER_IMG);
        endpoint.waitForElementsToLoad(150, Until.VISIBLE, LOG_BUTTON);
    }
}
