package cz.moneta.test.regression.commercial.smallbusiness.digital.localtests.banka.products.smeautomats.po;

import cz.moneta.test.dsl.Harness;
import cz.moneta.test.dsl.ufo.banka.tasks.BankaTasks;
import cz.moneta.test.dsl.util.credentials.Keys;
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 cz.moneta.test.regression.commercial.smallbusiness.digital.DataPrepare;
import cz.moneta.test.regression.commercial.smallbusiness.digital.TearDown;
import org.junit.jupiter.api.AfterEach;
import org.junit.jupiter.api.BeforeAll;

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

@TestScenario(name = "Create Expres Business and Flexi Business and Moneta Business Card for PO")
public class CreateExpresBusinessAndFlexiBusinessAndMonetaBusinessCard {

    private NonClient nonPoClient;
    private BankaTasks bankaTasks;

    @BeforeAll
    protected void setUp(Harness harness) {
        bankaTasks = harness.tasks().ufo().banka();
        nonPoClient = DataPrepare.setUpPo(harness);
    }

    @TestCase(name = "Create Expres Business and Flexi Business and Moneta Business Card for PO", environments = {TST1, PPE})
    @JiraTestCase(id = "SBD-T957")
    public void createExpresBusinessAndFlexiBusinessAndMonetaBusinessCard(Harness harness, @Key(Keys.ufo.banka.banker) Credentials credentials) {
        String lastYear = DataPrepare.getLastYear();
        String yearBeforeLast = DataPrepare.getYearBeforeLast();
        String loanExpresAmount = "500000";
        String loanFlexiAmount = "500000";
        String financingReason = "nákup strojů, výrobních zařízení";

        harness.withUfo()
                .openLoginPage()
                .then(bankaTasks.login().withCredentialsAndTurnOffSignpad(credentials))
                .then(bankaTasks.search().findLegalRepresentativeByIco(nonPoClient.ico()))
                .then(bankaTasks.sharedTasks().storeFullNameAndIco())
                .then(bankaTasks.newSmeAutomatPoTasks().withExpresBusinessAndFlexiBusinessAndMonetaBusinessCard(harness, loanExpresAmount, loanFlexiAmount, lastYear, yearBeforeLast, financingReason));

    }

    @AfterEach
    protected void tearDown(Harness harness) {
        TearDown.storeIcoFullNameCifSessionId(harness);
    }
}
