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

import cz.moneta.test.dsl.newib.NewIbPageFlow;
import cz.moneta.test.harness.endpoints.ib.NewIbEndpoint;
import cz.moneta.test.harness.support.web.Click;
import cz.moneta.test.harness.support.web.CustomAction;
import cz.moneta.test.harness.support.web.Key;
import cz.moneta.test.harness.support.web.TypeInto;
import cz.moneta.test.harness.support.web.Wait;

import static cz.moneta.test.dsl.newib.investments.InvestmentsFrameworkAgreement.GO_SIGNE;

@Wait(GO_SIGNE)
public interface InvestmentsFrameworkAgreement extends NewIbPageFlow<InvestmentsFrameworkAgreement> {

    String GO_SIGNE = "//button[@data-testid='goNext']";
    String MOBILE_KEY_INPUT = "//input[@id='mobileKey']";
    String SUBMIT_BUTTON = "//button[@data-testid='secondFactorSend']";

    @CustomAction
    default InvestmentsFrameworkAgreement scrollDown() {
        NewIbEndpoint ep = getEndpoint(NewIbEndpoint.class);
        ep.sendKeysOneAtATime(Key.DOWN);
        ep.sendKeysOneAtATime(Key.END);
        return null;
    }

    @Click(GO_SIGNE)
    InvestmentsFrameworkAgreement clickGoSigneDocument();

    @Wait(MOBILE_KEY_INPUT)
    @TypeInto(MOBILE_KEY_INPUT)
    InvestmentsFrameworkAgreement fillMobileKey(String mobileKey);

    @Click(SUBMIT_BUTTON)
    InvestmentsPurchaseVictory clickSubmitMobileKey();
}
