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

import cz.moneta.test.dsl.payment_engine.enums.ParameterChannels;
import cz.moneta.test.harness.support.web.*;

import static cz.moneta.test.dsl.payment_engine.parts_of_menu.menu_administration.PaymentEngineParametersChannelParameters.APPLY_BUTTON;
import static cz.moneta.test.dsl.payment_engine.parts_of_menu.menu_administration.PaymentEngineParametersChannelParameters.PARAMETER_NAME;

@Wait({PARAMETER_NAME, APPLY_BUTTON})
public interface PaymentEngineParametersChannelParameters extends WebFlow<PaymentEngineParametersChannelParameters> {
    String SELECT_CHANNEL = "//input[@name = 'channelId']//following-sibling::img";
    String CHANNEL_ID = "//div[text() = '%s']";
    String PARAMETER_NAME = "//input[@name = 'paramName']";
    String APPLY_BUTTON = "//button[text() = 'Aplikovat']";
    String PARAMETER_VALUE_ID_KEY = "PARAMETER_VALUE_ID_KEY";
    String PARAMETER_VALUE_ID_XPATH = "//div[@class = 'x-grid3-cell-inner x-grid3-col-5']";

    @TypeInto(PARAMETER_NAME)
    PaymentEngineParametersChannelParameters fillParameterName(String parameterName);

    @Wait(PARAMETER_VALUE_ID_XPATH)
    @StoreElementContent(storeKey = PARAMETER_VALUE_ID_KEY, value = PARAMETER_VALUE_ID_XPATH, by = Lookup.XPATH)
    PaymentEngineParametersChannelParameters getParameterValue();

    @Click(SELECT_CHANNEL)
    PaymentEngineParametersChannelParameters clickOnChannel();

    @Wait(value = CHANNEL_ID)
    @Click(value = CHANNEL_ID, andWait = @Wait(explicitWaitSeconds = 2))
    PaymentEngineParametersChannelParameters selectChannel(ParameterChannels channelId);

    @Wait(PARAMETER_VALUE_ID_XPATH)
    @Click(value = APPLY_BUTTON, andWait = @Wait(explicitWaitSeconds = 2))
    PaymentEngineParametersChannelParameters clickApplyButton();
}
