package cz.moneta.test.dsl.ufo.operations.ufoOperations;

import cz.moneta.test.dsl.ufo.operations.client.clientDetail.STS701_S002_ClientDetailPage;
import cz.moneta.test.dsl.ufo.operations.shared.topmenu.XXX702_SharedTopMenu;
import cz.moneta.test.harness.context.StoreAccessor;
import cz.moneta.test.harness.support.web.*;

import static cz.moneta.test.dsl.ufo.operations.shared.SharedElements.LOAD_IMG_DIV_CLASS;
import static cz.moneta.test.dsl.ufo.operations.ufoOperations.TRA701_S001_Transactions.TITLE_OF_PAGE;

@Wait(value = TITLE_OF_PAGE, until = Until.VISIBLE)
@Wait(value = LOAD_IMG_DIV_CLASS, by = Lookup.CLASSNAME, until = Until.GONE)
public interface TRA701_S001_Transactions extends WebFlow<TRA701_S001_Transactions>, XXX702_SharedTopMenu<TRA701_S001_Transactions>, StoreAccessor {

    String TITLE_OF_PAGE = "TRA701_S001_L001";
    String STATEMENT_ARCHIVE = "TRA701_S001_R001_1";
    String BACK_DART = "TRA701_S001_P025";
    String ACCOUNT_NUMBER_LABEL = "TRA701_S001_L013";
    String TRANSFER_ORDER = "//button[(@title='TRA701_S001_I009 [TRA701_S001_I009]')]";
    String FIRST_ACCOUNT_STATEMENT_CHECKBOX = "ufo-et-TRA701_S001_F001_row_1_sel";
    String STATEMENT_WITHOUT_FEE_BUTTON = "TRA701_S001_B033";
    String STATEMENT_WITH_FEE_BUTTON = "TRA701_S001_B032";
    String FIRST_STATEMENT_VALUE = "TRA701_S001_L036-1";
    String DETAIL_OF_TRANSACTION_IN_THE_LIST_BUTTON = "TRA701_S001_P001-1";
    String ID_OF_USER_LABEL = "TRA701_S001_L379";
    String EXIT_DETAIL_OF_TRANSACTION_BUTTON = "TRA701_S001_P002";
    String VIEW_TRANSACTIONS_BUTTON = "TRA701_S001_B003";
    String CURRENCY_LABEL = "TRA701_S001_L011";
    String LAST_ROW_DETAIL_IN_TRANSACTION_TABLE = "//tr[starts-with(@id, 'ufo-et-TRA701_S001_F002_row_')][last()]//img[starts-with(@id, 'TRA701_S001_P001-')]";
    String LAST_ROW_DATE_IN_TRANSACTION_TABLE = "(//*[@id[starts-with(., 'TRA701_S001_L033-')]])[last()]";
    String LAST_ROW_VALUE_IN_TRANSACTION_TABLE = "//tr[starts-with(@id, 'ufo-et-TRA701_S001_F002_row_')][last()]//div[starts-with(@id, 'TRA701_S001_L036-')]";
    String TRANSACTION_DETAIL_AV_FIELD = "TRA701_S001_L384";
    String TRANSACTION_DETAIL_POSTING_DATE = "TRA701_S001_L362";
    String LIST_OF_BLOCKED_FINANCIAL_RESOURCES_DIV = "TRA701_S001_X032";
    String NEXT_BUTTON = "TRA701_S001_B024";

    @CheckElementPresent(ACCOUNT_NUMBER_LABEL)
    TRA701_S001_Transactions assertAccountNumber();

    @Wait(value = STATEMENT_ARCHIVE, until = Until.VISIBLE)
    @Click(BACK_DART)
    STS701_S002_ClientDetailPage clickBack();

    @Wait(value = STATEMENT_ARCHIVE, until = Until.VISIBLE)
    @CheckElementPresent(STATEMENT_ARCHIVE)
    TRA701_S001_Transactions assertStatementArchive();

    @Click(value = TRANSFER_ORDER, by = Lookup.XPATH, andWait = @Wait(value = LOAD_IMG_DIV_CLASS, by = Lookup.CLASSNAME, until = Until.GONE))
    TRA740_S001_CreateNewTransferPaymentOrderPage clickTransactionOrder();

    @Wait(value = FIRST_ACCOUNT_STATEMENT_CHECKBOX, until = Until.CLICKABLE)
    @Click(value = FIRST_ACCOUNT_STATEMENT_CHECKBOX)
    TRA701_S001_Transactions clickFirstAccountStatementCheckbox();

    @Wait(value = STATEMENT_WITHOUT_FEE_BUTTON, until = Until.CLICKABLE)
    @Click(value = STATEMENT_WITHOUT_FEE_BUTTON)
    PSP701_S001_AmortizationPage clickStatementWithoutFeeButton();

    @Wait(value = STATEMENT_WITH_FEE_BUTTON, until = Until.CLICKABLE)
    @Click(STATEMENT_WITH_FEE_BUTTON)
    @AcceptAlert(waitSecondsForAlert = 15, expectedAlertText = "Bude naúčtován 1x poplatek.")
    PSP701_S001_AmortizationPage clickStatementWithFeeButton();

    @Wait(value = FIRST_STATEMENT_VALUE, until = Until.VISIBLE)
    @CheckElementContent(FIRST_STATEMENT_VALUE)
    TRA701_S001_Transactions checkFirstStatementValue(String value);

    @Wait(value = DETAIL_OF_TRANSACTION_IN_THE_LIST_BUTTON, until = Until.VISIBLE)
    @Click(value = DETAIL_OF_TRANSACTION_IN_THE_LIST_BUTTON, andWait = @Wait(value = LOAD_IMG_DIV_CLASS, by = Lookup.CLASSNAME, until = Until.GONE))
    TRA701_S001_Transactions clickDetailOfTransaction();

    @Wait(value = ID_OF_USER_LABEL, until = Until.VISIBLE)
    @CheckElementPresent(ID_OF_USER_LABEL)
    TRA701_S001_Transactions checkIdOfUser();

    @Click(EXIT_DETAIL_OF_TRANSACTION_BUTTON)
    TRA701_S001_Transactions clickExitInWindowWithDetailOfTransaction();

    @Click(VIEW_TRANSACTIONS_BUTTON)
    TRA701_S001_Transactions clickViewTransactions();

    @Wait(value = LOAD_IMG_DIV_CLASS, until = Until.GONE, by = Lookup.CLASSNAME)
    @CheckElementPresent(CURRENCY_LABEL)
    TRA701_S001_Transactions assertCurrency();

    @Click(value = NEXT_BUTTON, andWait = @Wait(value = LOAD_IMG_DIV_CLASS, by = Lookup.CLASSNAME, until = Until.GONE))
    TRA701_S001_Transactions clickNext();

    @GetElementContent(value = LAST_ROW_DATE_IN_TRANSACTION_TABLE, by = Lookup.XPATH)
    String getLastRowTransactionDate();

    @CheckElementContent(value = LAST_ROW_VALUE_IN_TRANSACTION_TABLE, by = Lookup.XPATH)
    TRA701_S001_Transactions checkValueInTransactionTable(String value);

    @CheckElementContent(TRANSACTION_DETAIL_AV_FIELD)
    TRA701_S001_Transactions checkTransactionDetailAvField(String text);

    @CheckElementContent(TRANSACTION_DETAIL_POSTING_DATE)
    TRA701_S001_Transactions checkTransactionDetailPostingDate(String date);

    @Wait(value = LIST_OF_BLOCKED_FINANCIAL_RESOURCES_DIV, until = Until.VISIBLE)
    @CheckElementPresent(LIST_OF_BLOCKED_FINANCIAL_RESOURCES_DIV)
    TRA701_S001_Transactions checkListOfBlockedFinancialResources();

    @Click(value = LAST_ROW_DETAIL_IN_TRANSACTION_TABLE, by = Lookup.XPATH, andWait = @Wait(value = LOAD_IMG_DIV_CLASS, by = Lookup.CLASSNAME, until = Until.GONE))
    TRA701_S001_Transactions clickLastTransactionDetail();

}