package cz.moneta.test.dsl.salesforce.pages.opportunities;

import cz.moneta.test.dsl.salesforce.components.ListViewHeader;
import cz.moneta.test.harness.context.StoreAccessor;
import cz.moneta.test.harness.endpoints.sales_force.SalesForceEndpoint;
import cz.moneta.test.harness.support.web.*;

@Wait(value = {OpportunitiesListPage.NEW_OPPORTUNITY_BUTTON},until = Until.VISIBLE)
public interface OpportunitiesListPage extends WebFlow<OpportunitiesListPage>, ListViewHeader, StoreAccessor {
    String NEW_OPPORTUNITY_BUTTON = "//runtime_platform_actions-action-renderer[@title='Nový']//button";

    @Click(NEW_OPPORTUNITY_BUTTON)
    CreateNewOpportunityPage newOpportunity();

    @CustomAction
    default OpportunitiesListPage searchOpportunity(String opportunity) {
        SalesForceEndpoint endpoint = getEndpoint(SalesForceEndpoint.class);
        endpoint.type(() -> OPPORTUNITY_SEARCH_INPUT, opportunity, false);
        endpoint.sendKeysOneAtATime(Key.ENTER);
        return null;
    }
}
