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.cards.credit.OPN008_S001_SignContractPage;
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.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.dsl.ufo.banka.pages.loans.flexikredit.NFL006_S001_FlexikreditScoringResultPage.APP_ID_STORE;
import static cz.moneta.test.harness.annotations.Environment.EDU;
import static cz.moneta.test.harness.annotations.Environment.PPE;
import static cz.moneta.test.harness.annotations.Environment.TST1;

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

    @Disabled("Konsolidace externích závazků bude zrušena")
    @TestCase(name = "Bank teller is able to login and create a new customer with consolidation", environments = {TST1, PPE, EDU})
    @JiraTestCase(id = "POB-T18687")
    public void tcBankTellerIsAbleToCreateNewCustomerWithDebtConsolidation(Harness harness, @Key(Keys.ufo.banka.secondBanker) Credentials secondBanker) {
        BankaTasks bankaTasks = harness.tasks().ufo().banka();

        HLO001_S001_ClientSearchPage firstInstance = harness.withUfoSecondInstance()
                .openLoginPage()
                .then(bankaTasks.login().withCredentialsSecondBanker(secondBanker))
                .storeBankerName();

        OPN008_S001_SignContractPage secondInstance = harness.withUfo()
                .openLoginPage()
                .then(bankaTasks.login().withCredentialsAndTurnOffSignpad(credentials))
                .then(bankaTasks.search().findByCif(newCustomerCif))
                .then(bankaTasks.newProduct().createNewCurrentAccount("Tom Plus"))
                .then(bankaTasks.newConsolidation().createNewConsolidationRequestToScoring())
                .then(bankaTasks.newConsolidation().createNewConsolidationRequestAfterScoring(HCisAllStavZadosti.APPLICATION_CONDITIONALLY_APROVED))
                .then(bankaTasks.newConsolidation().createNewConsolidationRequestConditionalAgreement(HCisAllStavZadosti.APPLICATION_CONDITIONALLY_APROVED))
                .then(bankaTasks.newConsolidation().createNewConsolidationAccountsFoundation());

        firstInstance
                .then(bankaTasks.newProduct().verifyApplicationSignatureThirdWindow(harness.get(APP_ID_STORE)));

        secondInstance
                .then(bankaTasks.newConsolidation().createNewConsolidationAccountsFoundationFinish("PODEPSANÁ"));
    }
}