package cz.moneta.test.dsl.ufo.banka.pages.cards.credit;

import cz.moneta.test.dsl.ufo.banka.pages.fon.TIS050_S002_SignerSelectionPage;
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.cards.credit.POZ016_S001_Change3dSecureNumberOnMbcPage.POZ016_S001_PAGE_LABEL_XPATH;

@Wait(value = POZ016_S001_PAGE_LABEL_XPATH, by = Lookup.XPATH, waitSecondsForElement = 40)
public interface POZ016_S001_Change3dSecureNumberOnMbcPage extends WebFlow<POZ016_S001_Change3dSecureNumberOnMbcPage>, StoreAccessor {
    String POZ016_S001_PAGE_LABEL_XPATH = "//div[text()='POZ016_S001']";
    String EXISTING_NUMBER_LABEL = "POZ016_S001_L009";
    String NEW_NUMBER_INPUT = "POZ016_S001_E001";
    String NEW_NUMBER_BUTTON = "POZ016_S001_B001";

    @CustomAction
    default POZ016_S001_Change3dSecureNumberOnMbcPage fillNew3dSecureNumber() {
        UfoEndpoint endpoint = getEndpoint(UfoEndpoint.class);
        if (!endpoint.getText(EXISTING_NUMBER_LABEL).equals("720961931")) {
            endpoint.type(() -> NEW_NUMBER_INPUT, "720961931", false);
        } else {
            endpoint.type(() -> NEW_NUMBER_INPUT, "702227334", false);
        }
        return null;
    }

    @Click(value = NEW_NUMBER_BUTTON)
    TIS050_S002_SignerSelectionPage clickToChange3dSecureNumberToSignerPage();
}
