package cz.moneta.test.regression.commercial.smallbusiness.digital.localtests.banka.products.accounts.currentaccount;

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.*;
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 Current Account with Internet Banking for FON")
public class CurrentAccountFon {

    private NonClient nonClient;
    private BankaTasks bankaTasks;

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

    @TestCase(name = "Create Current Account with Internet Banking", environments = {TST1, PPE})
    public void createCurrentAccountFon(Harness harness, @Key(Keys.ufo.banka.banker) Credentials credentials) {

        harness.withUfo()
                .openLoginPage()
                .then(bankaTasks.login().withCredentialsAndTurnOffSignpad(credentials))
                .then(bankaTasks.search().findByRC(nonClient.birthNumber()))
                .then(bankaTasks.sharedTasks().storeFullNameAndBirthNumber())
                .then(bankaTasks.newCurrentAccountTasks().createCurrentAccountFon());

    }

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