package cz.moneta.test.regression.channels.branch.archive;

import cz.moneta.dataprepare.CustomerDataPrepare;
import cz.moneta.test.dsl.Harness;
import cz.moneta.test.dsl.ufo.banka.pages.loans.VER017_S001_SecondBankerVerificationStatusPage;
import cz.moneta.test.dsl.ufo.banka.pages.search.HLO001_S001_ClientSearchPage;
import cz.moneta.test.dsl.ufo.banka.tasks.BankaTasks;
import cz.moneta.test.dsl.util.BankaUtils;
import cz.moneta.test.dsl.util.code.lists.HCisAllStavZadosti;
import cz.moneta.test.dsl.util.credentials.Keys;
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.Disabled;

import static cz.moneta.test.harness.annotations.Environment.PPE;
import static cz.moneta.test.harness.annotations.Environment.TST1;

@Disabled
@TestScenario(name = "Teller must be able to create a new flexikredit")
public class CreateNewCustomerWithFlexikredit extends CustomerDataPrepare {

    @TestCase(name = "Bank teller is able to login and create a new flexikredit", environments = {TST1, PPE})
    @JiraTestCase(id = "POB-T19494")
    public void createNewFlexikredit(Harness harness, @Key(Keys.ufo.banka.secondBanker) Credentials secondBanker) {
        BankaTasks tasks = harness.tasks().ufo().banka();

        HLO001_S001_ClientSearchPage secondInstance = harness.withUfoSecondInstance()
                .openLoginPage()
                .then(tasks.login().withCredentialsSecondBanker(secondBanker))
                .storeBankerName();

        String bankerName = BankaUtils.formatUserNameForVerification(harness.get("BANKER_NAME"));

        VER017_S001_SecondBankerVerificationStatusPage firstInstance = harness.withUfo()
                .openLoginPage()
                .then(tasks.login().withCredentialsAndTurnOffSignpad(credentials))
                .then(tasks.search().findByCif(newCustomerCif))
                .storeClientFullName()
                .then(tasks.sharedTasks().storeClientDetailInfo(harness))
                .then(tasks.newProduct().createNewCurrentAccount("Tom Plus"))
                .then(tasks.newProduct().createNewFlexikreditPart1(nonClient))
                .then(tasks.newProduct().createNewFlexikreditPart2(HCisAllStavZadosti.APPLICATION_CONDITIONALLY_APROVED, bankerName));

        secondInstance
                .then(tasks.cardsServicing().secondBankerApplicationRetailSign());

        firstInstance
                .then(tasks.newProduct().createNewFlexikreditPart3("FLEXIKREDIT"))
                .then(tasks.sharedTasks().checkFlexikreditDetail(harness));
    }
}
