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.PaymentEngineDistributionToClearingForVerification.SEARCH_FIELD;

@Wait(SEARCH_FIELD)
public interface PaymentEngineDistributionToClearingForVerification extends WebFlow<PaymentEngineDistributionToClearingForVerification> {

    String ID = "//input[@name='field1#id']";
    String SEARCH_FIELD = "//button[@class='x-btn-text  grid-filter-collapse']";
    String SEARCH_BTN = "//button[@class='x-btn-text'][text() = 'Hledat']";
    String VERIFY_REJECT_TRANSACTION_BUTTON = "//a[text()='Schválit/Zamítnout']";
    String ACCEPT_STORNO_BANKA_BUTTON = "//label[text()='Schválit žádost o storno (banka)']/../input";
    String OK_BUTTON = "//button[text()='OK']";
    String CLOSE_TAB = "//a[@class='x-tab-strip-close']";
    String AJAX_LOADING = "//div[text()='Načítám...']";

    @Wait(value = AJAX_LOADING, until = Until.GONE)
    @Click(value = SEARCH_FIELD, andWait = @Wait(value = ID, until = Until.VISIBLE))
    PaymentEngineDistributionToClearingForVerification clickOnSearchField();

    @TypeInto(ID)
    @Click(value = SEARCH_BTN, andWait = @Wait(value = AJAX_LOADING, until = Until.GONE))
    PaymentEngineDistributionToClearingForVerification searchTransaction(String transactionId);

    @Wait(value = VERIFY_REJECT_TRANSACTION_BUTTON, until = Until.CLICKABLE)
    @Click(value = VERIFY_REJECT_TRANSACTION_BUTTON, andWait = @Wait(value = ACCEPT_STORNO_BANKA_BUTTON, until = Until.CLICKABLE))
    PaymentEngineDistributionToClearingForVerification clickOnVerifyOrReject();

    @Click(value = ACCEPT_STORNO_BANKA_BUTTON, andWait = @Wait(value = OK_BUTTON, until = Until.CLICKABLE))
    PaymentEngineDistributionToClearingForVerification clickOnAcceptStornoBanka();

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

    @Click(CLOSE_TAB)
    PaymentEngineHomePage closeTab();
}