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

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

import static cz.moneta.test.dsl.ufo.banka.pages.requests.DUP009_S001_CreateElectronicDistributionChannel.CONTINUE_BUTTON;
import static cz.moneta.test.dsl.ufo.banka.pages.requests.DUP009_S001_CreateElectronicDistributionChannel.DUP009_S001_PAGE_LABEL_XPATH;

@Wait(value = DUP009_S001_PAGE_LABEL_XPATH, by = Lookup.XPATH)
@Wait(CONTINUE_BUTTON)
public interface DUP009_S001_CreateElectronicDistributionChannel extends WebFlow<DUP009_S001_CreateElectronicDistributionChannel>, StoreAccessor {
    String DUP009_S001_PAGE_LABEL_XPATH = "//div[text()='DUP009_S001']";
    String CONTINUE_BUTTON = "DUP009_S001_B001";
    String DISTRIBUTION_TYPE_SELECT = "DUP009_S001_C001";

    @Select(DISTRIBUTION_TYPE_SELECT)
    DUP009_S001_CreateElectronicDistributionChannel selectDistributionChannel(String channel);

    @CustomAction
    default DUP009_S001_CreateElectronicDistributionChannelTransitions clickContinueDismissAlertIfPresent() {
        UfoEndpoint endpoint = getEndpoint(UfoEndpoint.class);
        endpoint.click(() -> CONTINUE_BUTTON);
        if(endpoint.isAlertPresent(2)){
            endpoint.dismissAlert(1);
        }
        return null;
    }

}
