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

import cz.moneta.test.dsl.ufo.operations.client.clientDetail.STS701_S002_ClientDetailPage;
import cz.moneta.test.dsl.ufo.operations.search.OPS001_S001_ClientSearchPageUfoOperations;
import cz.moneta.test.harness.context.StoreAccessor;
import cz.moneta.test.harness.endpoints.ufo.UfoEndpoint;
import cz.moneta.test.harness.support.web.*;
import org.junit.Assert;
import org.openqa.selenium.WebElement;

import java.util.List;

import static cz.moneta.test.dsl.ufo.operations.client.HLA701_S001_EmployeeDetailsConfirmationPage.NO_BUTTON;
import static cz.moneta.test.dsl.ufo.operations.client.HLA701_S001_EmployeeDetailsConfirmationPage.YES_BUTTON;
import static cz.moneta.test.dsl.ufo.operations.shared.SharedElements.LOAD_IMG_DIV_CLASS;

@Wait({YES_BUTTON, NO_BUTTON})
public interface HLA701_S001_EmployeeDetailsConfirmationPage extends WebFlow<HLA701_S001_EmployeeDetailsConfirmationPage>, StoreAccessor {
    String YES_BUTTON = "HLA701_S001_B002";
    String NO_BUTTON = "HLA701_S001_B003";
    String CONFIRMATION_BUTTONS_XPATH = "//button[(@id='HLA701_S001_B002' or @id='HLA701_S001_B003') and not(contains(@style,'display: none'))]";

    @Click(YES_BUTTON)
    STS701_S002_ClientDetailPage clickYes();

    @Click(value = NO_BUTTON)
    OPS001_S001_ClientSearchPageUfoOperations clickNo();

    @CustomAction
    default HLA701_S001_EmployeeDetailsConfirmationPage checkConfirmationButtonsOfEmployeePrivilege(int buttonsCount) {
        UfoEndpoint endpoint = getEndpoint(UfoEndpoint.class);
        endpoint.waitForElementsToLoad(5, Lookup.XPATH, Until.VISIBLE, CONFIRMATION_BUTTONS_XPATH);
        List<WebElement> buttons = endpoint.findAndGetListOfElements(CONFIRMATION_BUTTONS_XPATH, Lookup.XPATH);
        Assert.assertEquals(buttonsCount, buttons.size());
        return null;
    }
}