package cz.moneta.test.dsl.payment_engine.parts_of_menu.menu_transaction;

import cz.moneta.test.dsl.payment_engine.home.PaymentEngineHomePage;
import cz.moneta.test.harness.support.web.*;

import static cz.moneta.test.dsl.payment_engine.parts_of_menu.menu_transaction.PaymentEngineOutgoingManualEdit.OK_BUTTON;

@Wait(OK_BUTTON)
public interface PaymentEngineOutgoingManualEdit extends WebFlow<PaymentEngineOutgoingManualEdit> {
    String EDIT_RELEASE = "//input[following-sibling::label[text()='Editovat a uvolnit']]";
    String CREDITOR_BIC = "//input[@name='cpAgentBic']";
    String CLEARING_PARTNER_LIST = "//input[@name='clpIdCp']//following-sibling::img";
    String CLEARING_PARTNER_SELECT = "//div[text()='%s']";
    String OUTGOING_COVERAGE_ACCOUNT = "//input[@name='cpAgentCorr1Acc']";
    String OK_BUTTON = "//button[text()='OK']";
    String CREDITOR_CORESPONDENT = "//input[@name='cpAgentCorr1Bic']";
    String RELEASE = "//input[following-sibling::label[text()='Uvolnit']]";
    String CLOSE_TAB = "//a[@class='x-tab-strip-close']";

    @Click(value = EDIT_RELEASE, andWait = @Wait(value = OK_BUTTON, until = Until.CLICKABLE))
    PaymentEngineOutgoingManualEdit clickOnEditAndRelease();

    @Click(value = RELEASE, andWait = @Wait(value = OK_BUTTON, until = Until.CLICKABLE))
    PaymentEngineOutgoingManualEdit clickOnRelease();

    @TypeIntos({@TypeInto(value = CREDITOR_BIC), @TypeInto(value = OUTGOING_COVERAGE_ACCOUNT), @TypeInto(value = CREDITOR_CORESPONDENT)})
    PaymentEngineOutgoingManualEdit fillAdditionalData(String creditorBic, String coverageAccount, String creditorCorespondent);

    @Click(CLEARING_PARTNER_LIST)
    PaymentEngineOutgoingManualEdit clickOnClearingPartnerList();

    @Click(value = CLEARING_PARTNER_SELECT, isStringDynamicXpath = true, andWait = @Wait(explicitWaitSeconds = 2))
    PaymentEngineOutgoingManualEdit selectClearingPartner(String clearingPartner);

    @Click(value = OK_BUTTON, andWait = @Wait(value = OK_BUTTON, until = Until.GONE))
    PaymentEngineOutgoingManualEdit clickOnOKButton();

    @Click(CLOSE_TAB)
    PaymentEngineHomePage closeTab();
}
