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

import cz.moneta.test.dsl.payment_engine.PaymentEngineForeignPaymentDetailPage;
import cz.moneta.test.dsl.payment_engine.home.PaymentEngineHomePage;
import cz.moneta.test.dsl.payment_engine.parts_of_menu.menu_search.PaymentEngineSearchPage;
import cz.moneta.test.harness.context.StoreAccessor;
import cz.moneta.test.harness.support.web.*;

import static cz.moneta.test.dsl.payment_engine.parts_of_menu.menu_transaction.PaymentEngineManualForVerificationPage.SEARCH_ID_BUTTON;

@Wait(value = SEARCH_ID_BUTTON, until = Until.VISIBLE)
public interface PaymentEngineManualForVerificationPage extends WebFlow<PaymentEngineManualForVerificationPage>, StoreAccessor {
        String AJAX_LOADING = "//div[text()='Načítám...']";
        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 SELECT_TRANSACTION = "//div[contains(@class,'x-grid3-row')]//div[@class='x-grid3-cell-inner x-grid3-col-2'][text() = '%s']";
        String VERIFY_BUTTON = "//a[text()='Schválit']";

        String SUBMIT_BUTTON = "//button[text() = 'OK']";
        String SEARCH = "//button[text() = 'Vyhledávání']";
        String CLOSE_TAB_BUTTON = "//a[@class='x-tab-strip-close']";

        @Click(SEARCH_ID_BUTTON)
        PaymentEngineManualForVerificationPage pressSearch();

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

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

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

        @Click(value = VERIFY_BUTTON, andWait = @Wait(SUBMIT_BUTTON))
        PaymentEngineForeignPaymentDetailPage clickVerifyTransaction();

        @Wait(CLOSE_TAB_BUTTON)
        @Click(CLOSE_TAB_BUTTON)
        PaymentEngineHomePage closeTab();

        @Click(value = SEARCH)
        PaymentEngineSearchPage search();
}