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

import cz.moneta.test.dsl.Harness;
import cz.moneta.test.dsl.ufo.banka.pages.main.HKO101_S001_MainClientPage;
import cz.moneta.test.dsl.ufo.banka.tasks.BankaTasks;
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 org.junit.jupiter.api.Disabled;

import static cz.moneta.test.dsl.util.credentials.Keys.ufo;
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;

@Disabled
@TestScenario(name = "Teller must be able to find a newly created client by CIF")
public class ViewClient {

    NonClient nonClient;

    @BeforeEach
    public void createClient(Harness harness, @Key(ufo.banka.banker) Credentials credentials) {
        BankaTasks bankaTasks = harness.tasks().ufo().banka();
        nonClient = harness.data().newNonClient();

        harness.withUfo()
                .openLoginPage()
                .then(bankaTasks.login().withCredentialsAndTurnOffSignpad(credentials))
                .then(bankaTasks.newClient().create(nonClient, credentials.getUsername()));
    }

    @TestCase(name = "Teller must be able to find a newly created client by CIF", environments = {TST1, PPE, EDU})
    @JiraTestCase(id = "POB-T10644")
    public void checkClientData(Harness harness, @Key(ufo.banka.banker) Credentials credentials) {
        BankaTasks bankaTasks = harness.tasks().ufo().banka();

        harness.withUfo()
                .openLoginPage()
                .then(bankaTasks.login().withCredentialsAndTurnOffSignpad(credentials))
                .fillSearchTerm(harness.get(HKO101_S001_MainClientPage.CLIENT_CIF_STORE_KEY))
                .clickSearchByCif()
                .onClientDetailPage()
                .verifyThatCifIsValid()
                .checkPageId();
    }
}