package cz.moneta.test.dsl.ufo.banka.pages.loans.flexikredit;

import cz.moneta.test.dsl.Harness;
import cz.moneta.test.dsl.ufo.banka.pages.main.HKO101_S001_MainClientPage;
import cz.moneta.test.harness.context.StoreAccessor;
import cz.moneta.test.harness.endpoints.ufo.UfoEndpoint;
import cz.moneta.test.harness.support.web.*;
import org.junit.jupiter.api.Assertions;

import static cz.moneta.test.dsl.ufo.banka.pages.loans.flexikredit.HPO003_FlexikreditDetailPage.BACK_BUTTON;

@Wait(BACK_BUTTON)
public interface HPO003_FlexikreditDetailPage extends WebFlow<HPO003_FlexikreditDetailPage>, StoreAccessor {

    String BACK_BUTTON = "HPO003_S001_S014";
    String DECLIP_BUTTON = "HPO003_S001_B006";
    String AMOUNT_DIV = "HPO003_S001_L004";
    String INTEREST_DIV = "HPO003_S001_L010";
    String PENALTY_RATE_DIV = "HPO003_S001_L011";
    String ACCOUNTING_CHARGE_DIV = "HPO003_S001_L012";

    @Click(BACK_BUTTON)
    HKO101_S001_MainClientPage clickBackButton();

    @Click(DECLIP_BUTTON)
    NFL008_FlexiCreditDeclipPage clickDeclipButton();

    @CheckElementContent(AMOUNT_DIV)
    HPO003_FlexikreditDetailPage checkAmount(String amount);

    @CheckElementContent(INTEREST_DIV)
    HPO003_FlexikreditDetailPage checkInterest(String interest);

    @CustomAction
    default HPO003_FlexikreditDetailPage checkPenaltyRateNotEmpty() {
        UfoEndpoint endpoint = getEndpoint(UfoEndpoint.class);
        Assertions.assertNotEquals("", endpoint.getText(PENALTY_RATE_DIV));
        return null;
    }

    @CustomAction
    default HPO003_FlexikreditDetailPage checkAccountingChargeNotEmpty() {
        UfoEndpoint endpoint = getEndpoint(UfoEndpoint.class);
        Assertions.assertNotEquals("", endpoint.getText(ACCOUNTING_CHARGE_DIV));
        return null;
    }

}
