package cz.moneta.test.regression.cards.localtests;

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.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 static cz.moneta.test.harness.annotations.Environment.PPE;
import static cz.moneta.test.harness.annotations.Environment.TST1;
import static cz.moneta.test.harness.support.data.GeneratorType.LAST_NAME;

@TestScenario(name = "Teller must be able to change data on CIF and then check if data changed on cards")
public class ChangeClientDetailsWithCheckOnCards {

    @TestCase(name = "Change name and check on first debit card", environments = {TST1, PPE})
    public void changeNameAndCheckDebitCard(Harness harness, @Key(Keys.ufo.banka.banker) Credentials credentials) {
        NonClient nonClient = harness.data().newFVNonClient()
                .withBirthNumber(harness.getConfig("cards_team.retail.rc"));

        BankaTasks bankaTasks = harness.tasks().ufo().banka();
        harness.withUfo()
                .openLoginPage()
                .then(bankaTasks.login().withCredentialsAndTurnOffSignpad(credentials))
                .then(bankaTasks.search().findByRC(nonClient.birthNumber()))
                .then(bankaTasks.cardsServicing().changeName(harness.generate(LAST_NAME)));

        harness.store("reports.tmfj.execution.comment", "Rč klienta " + nonClient.birthNumber());

    }
}
