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

import cz.moneta.test.dsl.Harness;
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.CC.39 - Employee - Application finishing (Employee MoneyCard Smart) (from other channels > IB) - BRANCH")
public class Employee_fromIB_toBranch {

    NonClient nonClient;

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

//        BankaTasks bankaTasks = harness.tasks().ufo().banka();
//        harness.withUfo()
//                .openLoginPage()
//                .then(bankaTasks.login().withCredentialsAndTurnOffSignpad(credentials))
//                .then(bankaTasks.newClient().create(nonClient))
//                .then(bankaTasks.newPackagedProductTasks().ibWithMobileKeyAndCurrentAccount(CurrentAccountsEnum.GENIUS_FREE_FLEXI));
//
//        nonClient.withBirthNumber("7209130852");

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

    @JiraTestCase(id = "FVP-T312")
    @TestCase(name = "Employee wants to get his MoneyCard Smart on Moneta other channels and he will complete origination process on BRANCH.", environments = {TST3})
    public void fromIB_toBranch(Harness harness, @Key(ufo.banka.banker) Credentials credentials) {
//        IbCardsApplicationTasks cardTasks = harness.tasks().ib().cardsApplication();
//        Credentials udebsCredentials = harness.tasks().udebs().findCredentialsByRC(nonClient.birthNumber());
//
//        int limit = 100000;
//
//        harness.withIB()
//                .openLoginPage()
//                .then(harness.tasks().ib().loginWithUsernamePasswordAndMobileKey(
//                        udebsCredentials.getUsername(),
//                        udebsCredentials.getPassword(),
//                        "12341234"))
//                .onWelcomePage()
//                .consentToCookies()
//                .checkCreditCardOfferPresent("Kreditní karta Smart")
//                .clickIamInterested()
//                .then(cardTasks.fillCardDetails(
//                        TestUtils.toString(limit),
//                        "50000",
//                        "50000",
//                        "Elektronicky",
//                        "111111",
//                        "29.-28.",
//                        "Bankovním příkazem"
//                ))
//                .selectSecondIdType("Řidičský průkaz")
//                .setSecondIdNumber("EK 608907")
//                .setSecondIdValidTo("31.8.2026")
//                .continueToEmploymentDetails()
//                    .setApproximateMonthlyIncomeAverage(nonClient.netMonthlyIncome())
//                    .setHouseholdMonthlyIncome(nonClient.homeIncome())
//                    .setOtherNonMMBMonthlyPayments(nonClient.otherLoanPayments())
//                    .setOtherMonthlyExpenses(nonClient.otherExpenses())
//                    .setSalaryDiscounts(nonClient.wageDeductions())
//                    .setEmployment(nonClient.occupationAdditionalInformation())
//                    .setEmploymentStartDate(DateUtils.getDateWithFormat(nonClient.occupationEmploymentFromRaw(), "dd.MM.yyyy"))
//                    .setCounty("Česká republika")
//                .continueApplicationConfirmation()
//                    .typeSmsCode("12341234")
//                    .validateMobileKey()
//                .onApplicationFinishingPage()
//                    .continueToApplicationOvereview()
//                    .waitForApproval()
//                    .signApplicationAndContinueToPrepareContractPage()
//                    .clickConfirm()
//                .clickAgreeAndContinueToReview()
//                    .clickConfirm()
//                    .typeSmsCode("12341234")
//                    .signContractAndContinueToConfirmationPage()
//                .continueToApplicationOverviewPage()
//                    .checkFirstApplicationStatus("Schválená")
//                    .checkFirstApplicationLimit(TestUtils.toStringWithTwoDecimals(limit))
//                .clickLogOff();
//
//        harness.withUfo()
//                .openLoginPage()
//                .then(harness.tasks().ufo().banka().login().withCredentialsAndTurnOffSignpad(credentials))
////                    .fillSearchTerm(nonClient.birthNumber())
////                .clickSearchByRc()
//                    .fillSearchTerm(harness.get(CLIENT_CIF_STORE_KEY))
//                    .clickSearchByCif()
//                .onEmployeeClientPage()
//                    .clickContinueToCifMainPage()
//                    .clickClientRequests()
//                    .clickOpenRequestDetail()
//                .onConfirmationPage()
//                    .clickOKAndContinueToCardRequestPage()
//                .clickCreateProductButton()
//                .continueToPrintCopyOfContractProposalPage()
//                .clickContinue()
//                .onSignContractPage()
//                    .clickFirstSignerCheckbox()
//                    .clickYesButton()
//                .clickContinue();

        harness.withGreenScreen()
                .logIn();

        System.out.println();
    }
}
