package cz.moneta.test.regression.transactional.cards.retail.creditcard.origination;

import cz.moneta.test.dsl.Harness;
import cz.moneta.test.dsl.ufo.banka.tasks.BankaTasks;
import cz.moneta.test.dsl.ufo.banka.tasks.accountenums.CurrentAccountsEnum;
import cz.moneta.test.dsl.ufo.operations.client.NewProductsByNameUfoOps;
import cz.moneta.test.dsl.ufo.operations.search.SearchBy;
import cz.moneta.test.dsl.util.data.client.NonClient;
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.auth.Credentials;
import cz.moneta.test.harness.support.auth.Key;
import org.junit.jupiter.api.BeforeEach;

import static cz.moneta.test.dsl.util.credentials.Keys.ufo;

@TestScenario(name = "ONB.RET.CC.08 - Retail CC - Application Origination - MoneyCard Gold - CC")
public class Client_fromCallCenter_toCallCenter {

    NonClient nonClient;

    @BeforeEach
    void setUp(Harness harness, @Key(ufo.banka.banker) Credentials credentials) {
        BankaTasks bankaTasks = harness.tasks().ufo().banka();
        nonClient = harness.data().newFVNonClient()
                .withNetMonthlyIncome(100000)
                .withHomeIncome(100000)
                .withOtherExpenses(10000)
                .withOtherLoanPayments(0)
                .withWageDeductions(0)
                .withIncomeSources("1");

        harness.withUfo()
                .openLoginPage()
                .then(bankaTasks.login().withCredentialsAndTurnOffSignpad(credentials))
                .then(bankaTasks.newClient().create(nonClient, credentials.getUsername()))
                .then(bankaTasks.newPackagedProductTasks().ibWithMobileKeyAndCurrentAccount(nonClient, CurrentAccountsEnum.GENIUS_FREE_FLEXI));
    }

    @JiraTestCase(id = "FVP-T64")
    @TestCase(name = "Retail Customer wants to get his Credit Card on Moneta CALL CENTRUM and he will complete origination process on Call Centrum.", environments = Environment.TST3)
    public void Retail_CC_Application_Origination_MoneyCard_Gold_CC(Harness harness, @Key(ufo.banka.banker) Credentials credentials) {

        String creditAmount = "40000";

        BankaTasks bankaTasks = harness.tasks().ufo().banka();
        harness.withUfo()
                .openLoginPage()
                .then(harness.tasks().ufo().operations().login().withCredentialsExpectingError(credentials))
                .dismissErrorPage()
                .searchBy(SearchBy.CIF)
                .onClientDetailsPage()
                .then(harness.tasks().ufo().operations().clientDetails().createNewProductByName(NewProductsByNameUfoOps.CREDIT_CARD))
                .clickContinue()
                .onCreditCardScoring()
                .continueToProductSelection()
                .then(harness.tasks().ufo().operations().productActivation().createCreditCard(
                        nonClient,
                        "MoneyCard Gold",
                        "KARTA - KARTA",
                        "MC Gold",
                        "Bez akce",
                        "40000",
                        "Na dobu neurčitou",
                        "30000",
                        "30000",
                        "30000",
                        "bene+ (více na www.beneplus.cz)",
                        "BÚ Genius Free & Flexi",
                        "111111"
                ))
                .checkProduct("Kreditní karta")
                .scheduleMeetingAtABranch()
                .setMeetingToFirstWorkingDayOfNextMonth()
                .setMeetingTimeSlot(5)
                .setNotificationsToDoNotSend()
                .confirmMeeting()
                .menuClickClientApplications()
                .assertFirstApplicationState("SOUHLAS")
                .assertFirstApplicationProductCode("Credit card")
                .assertFirstApplicationRequestedAmount("40000")
                .assertFirstApplicationApprovedAmount("40000");
    }
}
