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

import cz.moneta.test.harness.support.web.*;

import static cz.moneta.test.dsl.payment_engine.parts_of_menu.menu_clients.PaymentEngineClientsListOfStandingOrdersTransactions.AJAX_LOADING;
import static cz.moneta.test.dsl.payment_engine.parts_of_menu.menu_clients.PaymentEngineClientsListOfStandingOrdersTransactions.PAGE_LABEL;

@Wait(value = PAGE_LABEL, until = Until.VISIBLE)
@Wait(value = AJAX_LOADING, until = Until.GONE)
public interface PaymentEngineClientsListOfStandingOrdersTransactions extends WebFlow<PaymentEngineClientsListOfStandingOrdersTransactions> {

    String PAGE_LABEL = "//span[@class='x-tab-strip-inner']//span[text()='Trvalé příkazy / Seznam']";
    String TRANSACTION_BY_DATE_ID_KEY = "TRANSACTION_BY_TYPE_ID_KEY";
    String TRANSACTION_BY_DATE_ID = "(//div[text()='%s']/../preceding-sibling::td)[3]";
    String FILTERS_BUTTON = "//button[@class='x-btn-text  grid-filter-collapse']";
    String SETTLEMENT_FROM_FILLED = "//input[@name='field1#settDate' and not(@value='undefined')]";
    String SETTLEMENT_FROM = "//input[@name='field1#settDate']//following-sibling::input";
    String SEARCH_BUTTON = "//div[@class='x-panel-footer x-panel-footer-noborder']//button[text()='Hledat']";
    String AJAX_LOADING = "//div[text()='Načítám...']";

    @CheckElementPresent(value = TRANSACTION_BY_DATE_ID, isStringDynamicXpath = true)
    PaymentEngineClientsListOfStandingOrdersTransactions checkTransactionIdByDatePresent(String settlementDate);

    @StoreElementContent(storeKey = TRANSACTION_BY_DATE_ID_KEY, value = TRANSACTION_BY_DATE_ID, isStringDynamicXpath = true)
    PaymentEngineClientsListOfStandingOrdersTransactions storeTransactionIdByDate(String settlementDate);

    @Click(value = FILTERS_BUTTON, andWait = @Wait(value = SETTLEMENT_FROM, until = Until.VISIBLE))
    PaymentEngineClientsListOfStandingOrdersTransactions clickFilters();

    @TypeInto(value = SETTLEMENT_FROM, andWait = @Wait(value = SETTLEMENT_FROM_FILLED, isStringDynamicXpath = true))
    PaymentEngineClientsListOfStandingOrdersTransactions fillSettlementFrom(String settlementFrom);

    @Click(value = SEARCH_BUTTON, andWait = @Wait(value = AJAX_LOADING, until = Until.GONE))
    PaymentEngineClientsListOfStandingOrdersTransactions clickSearch();

}
