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

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.operations.shared.SharedElements.LOAD_IMG_DIV_CLASS;
import static cz.moneta.test.dsl.ufo.operations.ufoOperations.ACQ702_S010_Fraud.CHECK_NUMBER_INPUT;

@Wait(value = LOAD_IMG_DIV_CLASS, by = Lookup.CLASSNAME, until = Until.GONE, waitSecondsForElement = 50)
@Wait(value = CHECK_NUMBER_INPUT)
public interface ACQ702_S010_Fraud extends WebFlow<ACQ702_S010_Fraud>, StoreAccessor {

    String CHECK_NUMBER_INPUT = "ACQ702_S010_E008";
    String FRAUD_CONTROL_RADIO = "ACQ702_S010_R001_2";
    String SET_ALL_OK_BUTTON = "ACQ702_S010_B007";
    String SEND_BUTTON = "ACQ702_S010_B014";
    String AGREE_SEND_BUTTON = "SCH708_S001_B001";
    String FINISH_BUTTON = "SCH706_S007_B001";

    @TypeInto(value = CHECK_NUMBER_INPUT, clear = true)
    ACQ702_S010_Fraud fillCheckingNumber(String number);

    @Wait(value = FRAUD_CONTROL_RADIO)
    @Click(value = FRAUD_CONTROL_RADIO, jsClick = true)
    ACQ702_S010_Fraud clickFraudControl();

    @Wait(value = SET_ALL_OK_BUTTON)
    @Click(value = SET_ALL_OK_BUTTON, jsClick = true, andWait = @Wait(value = LOAD_IMG_DIV_CLASS, by = Lookup.CLASSNAME, until = Until.GONE, waitSecondsForElement = 50))
    ACQ702_S010_Fraud clickSetAll();

    @Wait(value = SEND_BUTTON)
    @Click(value = SEND_BUTTON, jsClick = true, andWait = @Wait(value = LOAD_IMG_DIV_CLASS, by = Lookup.CLASSNAME, until = Until.GONE, waitSecondsForElement = 50))
    ACQ702_S010_Fraud clickSend();

    @Wait(value = AGREE_SEND_BUTTON)
    @Click(value = AGREE_SEND_BUTTON, jsClick = true, andWait = @Wait(value = LOAD_IMG_DIV_CLASS, by = Lookup.CLASSNAME, until = Until.GONE, waitSecondsForElement = 50))
    ACQ702_S010_Fraud clickAgreeSend();

    @Wait(value = FINISH_BUTTON)
    @Click(value = FINISH_BUTTON, jsClick = true, andWait = @Wait(value = LOAD_IMG_DIV_CLASS, by = Lookup.CLASSNAME, until = Until.GONE, waitSecondsForElement = 50))
    ACQ702_S010_Fraud clickFinish();

    @CustomAction
    default UKO720_S001_TaskDetail closeWindow() {
        UfoEndpoint endpoint = getEndpoint(UfoEndpoint.class);
        endpoint.closePopup(20);
        return null;
    }
}