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.Wait;

import static cz.moneta.test.dsl.ib.doidentifikace.PhoneNumberPage.PHONE_NUMBER_WINDOW;

@Wait(PHONE_NUMBER_WINDOW)
public interface PhoneNumberPage extends IbPageFlow<PhoneNumberPage>, StoreAccessor {
    String PHONE_NUMBER_WINDOW = "//input[@testid='validity-input']";
    String SEND_SMS_BUTTON = "//button[@testid='show-sms-input-button']";
    String LINK_THIS_IS_NOT_MY_NUMBER = "//span[@testid='invalid-phone-link']";

    @CustomAction
    default ConfirmSMSPage focusAndClickToSmsButton() {
        IbEndpoint endpoint = getEndpoint(IbEndpoint.class);
        endpoint.moveToElement(PHONE_NUMBER_WINDOW);
        endpoint.click(() -> SEND_SMS_BUTTON);
        return null;
    }

    @CustomAction
    default ConfirmOtherPhoneNumberPage focusAndClickToNotMyNumber() {
        IbEndpoint endpoint = getEndpoint(IbEndpoint.class);
        endpoint.moveToElement(PHONE_NUMBER_WINDOW);
        endpoint.click(() -> LINK_THIS_IS_NOT_MY_NUMBER);
        return null;
    }
}