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.*;

public interface PaymentEngineOutgoingForVerification extends WebFlow<PaymentEngineOutgoingForVerification> {
    String SELECT_TRANSACTION = "//div[contains(@class,'x-grid3-row')]//div[@class='x-grid3-cell-inner x-grid3-col-2'][text() = '%s']";
    String VERIFY_TRANSACTION_BUTTON = "//a[text()='Schválit/Zamítnout']";
    String ACCEPT_REQUEST_BUTTON = "//input[@name='manActGroup']";
    String ACCEPT_CHANGES_BUTTON = "//input[following-sibling::label[text()='Schválit editaci a uvolnění']]";
    String OK_BUTTON = "//button[text()='OK']";
    String CLOSE_TAB = "//a[@class='x-tab-strip-close']";
    String SEARCH_ID_BUTTON ="//em/button[@class='x-btn-text  grid-filter-collapse']";
    String SEARCH_FIELD = "//input[@name='field1#id']";
    String SEARCH_BTN = "//button[@class='x-btn-text'][text() = 'Hledat']";
    String AJAX_LOADING = "//div[text()='Načítám...']";

    @Click(SEARCH_ID_BUTTON)
    PaymentEngineOutgoingForVerification pressSearch();

    @TypeInto(SEARCH_FIELD)
    PaymentEngineOutgoingForVerification fillId(String transactionId);

    @Click(value = SEARCH_BTN, andWait = @Wait(value = AJAX_LOADING, until = Until.GONE))
    PaymentEngineOutgoingForVerification searchUnverified();

    @Click(value = SELECT_TRANSACTION, isStringDynamicXpath = true, andWait = @Wait(explicitWaitSeconds = 1))
    PaymentEngineOutgoingForVerification selectTransaction(String transactionId);

    @Click(VERIFY_TRANSACTION_BUTTON)
    PaymentEngineOutgoingForVerification clickOnVerifyTransaction();

    @Click(value = ACCEPT_CHANGES_BUTTON, andWait = @Wait(value = OK_BUTTON, until = Until.CLICKABLE))
    PaymentEngineOutgoingForVerification clickOnAccept();

    @Click(value = OK_BUTTON, andWait = @Wait(value = OK_BUTTON, until = Until.GONE))
    PaymentEngineOutgoingForVerification clickOnOk();

    @Click(value = ACCEPT_REQUEST_BUTTON, andWait = @Wait(value = OK_BUTTON, until = Until.CLICKABLE))
    PaymentEngineOutgoingForVerification clickOnAcceptRequest();

    @Click(CLOSE_TAB)
    PaymentEngineHomePage closeTab();
}
