package cz.moneta.test.regression.commercial.salesforce.web;

import cz.moneta.test.dsl.Harness;
import cz.moneta.test.dsl.salesforce.data.OpportunityData;
import cz.moneta.test.dsl.salesforce.tasks.SalesForceTasks;
import cz.moneta.test.harness.annotations.Environment;
import cz.moneta.test.harness.annotations.JiraTestCase;
import cz.moneta.test.harness.annotations.NonConcurrentTestScenario;
import cz.moneta.test.harness.annotations.TestCase;
import org.junit.jupiter.api.Disabled;

@NonConcurrentTestScenario(name = "Create new opportunity")
public class NewOpportunityTest {

    //TODO the Salesforce was updated, this test is not up to date
    @TestCase(name = "Create new opportunity for account", environments = {Environment.TST1})
    @JiraTestCase(id = "SC-T751")
    @Disabled
    public void newOpportunity(Harness harness) {
        SalesForceTasks tasks = harness.tasks().salesForce();
        OpportunityData opportunityData = OpportunityData.builder().build().getInvestmentOpportunity();

        harness.withSalesForce()
                .openLoginPage()
                .then(tasks.loginAsBanker())
                .then(tasks.openAccountDetail(opportunityData.getAccount()))
                .onAccountDetailPage()
                .clickNewOpportunityButton()
                .onNewOpportunityPage()
                .selectOpportunityInitiator(opportunityData.getInitiator())
                .selectOpportunitySource(opportunityData.getSource())
                .inputOpportunityBranch(opportunityData.getBranch())
                .fillOpportunityAmount(opportunityData.getAmount())
                .fillOpportunityProbability(opportunityData.getProbability())
                .fillOpportunitySignatureDate(opportunityData.getSignatureDate())
                .fillOpportunityDescription(opportunityData.getDescription())
                .selectProductPotentials(opportunityData.getProductPotential())
                .clickNext()
                .onOpportunityConfirmationPage()
                .clickFinishButton()
                .onOpportunityDetailPage()
                .checkAccountId(opportunityData.getAccount())
                .logoutUser();
    }

}
