package cz.moneta.test.regression.transactional.cards.retail.debitcard.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.util.data.client.NonClient;
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;
import static cz.moneta.test.harness.annotations.Environment.TST3;

@TestScenario(name = "ONB.RET.DC.43 - ONB.RET.DC.43 - Retail DC - Account&Card Onboarding (Tom - USD - Debit MC Standard USD - fee)")
public class Client_fromBranch_toBranch_Usd {

    NonClient nonClient;

    @BeforeEach
    void setUp(Harness harness, @Key(ufo.banka.banker) Credentials credentials) {
        nonClient = harness.data().newFVNonClientEmployee()
                .withNetMonthlyIncome(100000)
                .withHomeIncome(100000)
                .withOtherExpenses(5000)
                .withOtherLoanPayments(0);

        BankaTasks bankaTasks = harness.tasks().ufo().banka();
        harness.withUfo()
                .openLoginPage()
                .then(bankaTasks.login().withCredentialsAndTurnOffSignpad(credentials))
                .then(bankaTasks.newClient().create(nonClient, credentials.getUsername()))
                .then(bankaTasks.newProduct().createNewCurrentAccount(CurrentAccountsEnum.TOM));

        harness.tasks().nasDb().insertUser(nonClient);
    }

    @JiraTestCase(id = "FVP-T309")
    @TestCase(name = "Banker creates Standard Account (USD) and Debit card (Debit MC Standard USD) for an existing client with existing account TOM", environments = {TST3})
            public void Retail_CC_Application_Origination_MoneyCard_Smart_BRANCH(Harness harness, @Key(ufo.banka.banker) Credentials credentials) {

        BankaTasks bankaTasks = harness.tasks().ufo().banka();
        harness.withUfo()
                .openLoginPage()
                .then(bankaTasks.login().withCredentialsAndTurnOffSignpad(credentials))
                .fillSearchTerm(nonClient.birthNumber())
                .clickSearchByRc()
                .onClientDetailPage()
                .then(bankaTasks.newProduct().createNewCurrentAccount(CurrentAccountsEnum.TOM));

    }
}
