package cz.moneta.test.regression.channels.digital.web;

import cz.moneta.test.dsl.Harness;
import cz.moneta.test.dsl.monetaportal.components.Web2Call;
import cz.moneta.test.dsl.util.task.monetaportal.Wso2Tasks;
import cz.moneta.test.harness.annotations.Environment;
import cz.moneta.test.harness.annotations.JiraTestCase;
import cz.moneta.test.harness.annotations.TestCase;
import cz.moneta.test.harness.annotations.TestScenario;
import cz.moneta.test.harness.support.data.GeneratorType;
import org.junit.jupiter.api.Assertions;

@TestScenario(name = "Check W2C")
public class W2CTest {

    @TestCase(name = "W2C", environments = {Environment.TST1, Environment.PPE})
    @JiraTestCase(id = "NWP-T760")
    public void tcW2C(Harness harness) {

        String telephone = harness.generate(GeneratorType.MOBILE_PHONE_NUMBER);
        String campaignName = "Expres půjčka";

        Web2Call web2Call = harness.withMonetaPortal()
                .openHomePage()
                .acceptCookies()
                .openLoansMenu()
                .openExpressLoanPage()
                .clickToCall()
                .fillW2CPhone(telephone);

        Wso2Tasks wso2Tasks = harness.tasks().monetaPortal().wso2Tasks();
        int before = wso2Tasks.getCampaignsCount(harness, telephone, campaignName);

        web2Call.clickW2CSubmit()
                .checkW2CSuccessMessage();

        int after = wso2Tasks.getCampaignsCount(harness, telephone, campaignName);

        Assertions.assertEquals(before + 1, after);
    }
}