package cz.moneta.test.regression.backoffice.callcenter.jenkinstests.ccretail.cczakladbanka;

import cz.moneta.test.dsl.Harness;
import cz.moneta.test.dsl.util.credentials.Keys;
import cz.moneta.test.dsl.util.task.ufo.operations.OperationsTasks;
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.BeforeAll;

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

@TestScenario(name = "Saving account tests")
public class SavingAccountTests {
    private OperationsTasks operationsTasks;
    private String rcOfExistingClient;

    @BeforeAll
    public void setupInfo(Harness harness) {
        operationsTasks = harness.tasks().ufo().operations();
        rcOfExistingClient = harness.getSystemOrConfigValue("cc.savingAccountTestsClient.rc");
    }

    @TestCase(name = "Change of distribution statement on saving account", environments = {PPE, TST1})
    @JiraTestCase(id = "CC-T2101")
    public void changeOfDistributionStatementOnSavingAccount(Harness harness, @Key(Keys.ufo.banka.banker) Credentials credentials) {

        harness.withUfo()
                .openLoginPage()
                .then(operationsTasks.login().withCredentials(credentials))
                .then(operationsTasks.savingAccountTasks().searchClientAndClickOnAccountList(rcOfExistingClient))
                .clickDistributionButton()
                .clickSavingsAccountRadio()
                .acceptAlertChangeDistribution()
                .selectAnotherDistributionOfStatement()
                .clickChangeDistribution()
                .checkIfIBSBIsChecked()
                .clickSendButton()
                .onStatementsDistributionPage()
                .clickBackButton()
                .clickDemand()
                .clickRefreshRequirementButton()
                .checkDemandDescriptionFirstRow("MMB - Zákaznický servis - Změna v DTB - Změna distribuce výpisu")
                .clickCorrespondence()
                .checkDistributionAndGetTime();
    }
}