package cz.moneta.test.dsl.ufo.banka.pages.term.deposit;

import cz.moneta.test.dsl.ufo.banka.pages.main.PSP004_S001_PrintPage;
import cz.moneta.test.harness.context.StoreAccessor;
import cz.moneta.test.harness.endpoints.ufo.UfoEndpoint;
import cz.moneta.test.harness.support.web.*;

import static cz.moneta.test.dsl.ufo.banka.pages.term.deposit.RTV003_S001_DepositOfPrincipalTypePage.*;

@Wait(value = RTV003_S001_PAGE_LABEL_XPATH, by = Lookup.XPATH, waitSecondsForElement = 60)
public interface RTV003_S001_DepositOfPrincipalTypePage extends WebFlow<RTV003_S001_DepositOfPrincipalTypePage>, StoreAccessor {
    String RTV003_S001_PAGE_LABEL_XPATH = "//div[text()='RTV003_S001']";

    String PARENT_ACCOUNT_BUTTON = "RTV003_S001_B001";
    String IN_CASH_BUTTON = "RTV003_S001_B002";
    String FROM_DIFFERENT_BANK_BUTTON = "RTV003_S001_B003";

    @CustomAction
    default PSP004_S001_PrintPage clickParentAccountAndDismissAlertIfPresent() {
        UfoEndpoint endpoint = getEndpoint(UfoEndpoint.class);
        endpoint.click(() -> PARENT_ACCOUNT_BUTTON);
        if (endpoint.isAlertPresent(3)) {
            endpoint.dismissAlert(1);
        }
        return null;
    }
}
