package cz.moneta.test.dsl.ib.doidentifikace;

import cz.moneta.test.dsl.ib.IbPageFlow;
import cz.moneta.test.harness.context.StoreAccessor;
import cz.moneta.test.harness.endpoints.ib.IbEndpoint;
import cz.moneta.test.harness.support.web.CustomAction;
import cz.moneta.test.harness.support.web.TypeInto;
import cz.moneta.test.harness.support.web.Wait;

import static cz.moneta.test.dsl.ib.doidentifikace.ConfirmSMSPage.CONFIRM_SMS_WINDOW;

@Wait(CONFIRM_SMS_WINDOW)
public interface ConfirmSMSPage extends IbPageFlow<ConfirmSMSPage>, StoreAccessor {
    String CONFIRM_SMS_WINDOW = "//span[@testid='invalid-phone-link']";
    String INPUT_SMS_KEY = "//input[@placeholder='Opište kód z SMS']"; //FIXME
    String CONFIRM_SMS_BUTTON = "//button[@testid='verify-sms-key-button']";

    @TypeInto(value = INPUT_SMS_KEY, clear = true)
    ConfirmSMSPage typeSMSKey(String smsKey);

    @Wait(value = INPUT_SMS_KEY, explicitWaitSeconds = 2)
    ConfirmSMSPage waitSMSField();

    @CustomAction
    default SuccessPage focusAndClickToConfirmSmsButton() {
        IbEndpoint endpoint = getEndpoint(IbEndpoint.class);
        endpoint.moveToElement(CONFIRM_SMS_WINDOW);
        endpoint.click(() -> CONFIRM_SMS_BUTTON);
        return null;
    }
}
