package cz.moneta.test.dsl.ufo.banka.pages.main;

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

import static cz.moneta.test.dsl.ufo.banka.pages.main.TRP001_S002_ListOfStandingOrdersPage.TRP001_S002_PAGE_LABEL_XPATH;
import static cz.moneta.test.dsl.ufo.operations.shared.SharedElements.LOAD_IMG_DIV_CLASS;

@Wait(value = TRP001_S002_PAGE_LABEL_XPATH, by = Lookup.XPATH, waitSecondsForElement = 90)
@Wait(value = TRP001_S002_ListOfStandingOrdersPage.CREATE_BUTTON, waitSecondsForElement = 90)
public interface TRP001_S002_ListOfStandingOrdersPage extends WebFlow<TRP001_S002_ListOfStandingOrdersPage>, StoreAccessor {

    String TRP001_S002_PAGE_LABEL_XPATH = "//div[text()='TRP001_S002']";
    String CREATE_BUTTON = "TRP001_S002_B003";
    String CHANGE_BUTTON = "TRP001_S002_B004";
    String DELETE_BUTTON = "TRP001_S002_B005";
    String STANDING_ORDER_ID_XPATH = "//td[text()='%s']";
    String STANDING_ORDER_STATUS_VALID_XPATH = "//td[text()='%s']//following-sibling::td[text()='Platný']";
    String STANDING_ORDER_STATUS_DELETED_XPATH = "//td[text()='%s']//following-sibling::td[text()='Zrušený']";
    String STANDING_ORDER_AMOUNT_XPATH = "//td[text()='%s']//following-sibling::td[4]";

    @Click(CREATE_BUTTON)
    TRP001_S004_CreateNewStandingOrderPage clickCreate();

    @Click(CHANGE_BUTTON)
    TRP001_S009_ChangeStandingOrderPage clickChange();

    @Click(DELETE_BUTTON)
    TRP001_S014_DeleteStandingOrderPage clickDelete();

    @Click(value = STANDING_ORDER_ID_XPATH, isStringDynamicXpath = true, by = Lookup.XPATH, andWait = @Wait(value = LOAD_IMG_DIV_CLASS, by = Lookup.CLASSNAME, until = Until.GONE))
    TRP001_S002_ListOfStandingOrdersPage clickOnStandingOrder(String standingOrderId);

    @CheckElementPresent(value = STANDING_ORDER_STATUS_VALID_XPATH, isStringDynamicXpath = true, by = Lookup.XPATH)
    TRP001_S002_ListOfStandingOrdersPage checkStandingOrderStatusValid(String standingOrderId);

    @CheckElementPresent(value = STANDING_ORDER_STATUS_DELETED_XPATH, isStringDynamicXpath = true, by = Lookup.XPATH)
    TRP001_S002_ListOfStandingOrdersPage checkStandingOrderStatusDeleted(String standingOrderId);

    @CheckElementPresent(value = STANDING_ORDER_ID_XPATH, isStringDynamicXpath = true, by = Lookup.XPATH)
    TRP001_S002_ListOfStandingOrdersPage checkStandingOrderId(String standingOrderId);

    @CheckElementContent(value = STANDING_ORDER_AMOUNT_XPATH, isStringDynamicXpath = true, by = Lookup.XPATH)
    TRP001_S002_ListOfStandingOrdersPage checkStandingOrderAmount(String standingOrderId, String expectedAmount);

}
