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 = "Disabling online payments")

public class DebitCardDisablingOnlinePayments {
    private OperationsTasks operationsTasks;
    private String rcOfExistingClientFO;
    private String cifOfExistingClientFOP;
    private String icoOfExistingClientPO;

    @BeforeAll
    public void setupInfo(Harness harness) {
        operationsTasks = harness.tasks().ufo().operations();
        rcOfExistingClientFO = harness.getSystemOrConfigValue("cc.disablingOnlinePaymentsClientFO.rc");
        cifOfExistingClientFOP = harness.getSystemOrConfigValue("cc.disablingOnlinePaymentsClientFOP.cif");
        icoOfExistingClientPO = harness.getSystemOrConfigValue("cc.disablingOnlinePaymentsClientPO.ico");
    }

    @TestCase(name = "Disabling online payments", environments = {PPE, TST1})
    @JiraTestCase(id = "CC-T2202")
    public void disablingOnlinePaymentsFO(Harness harness, @Key(Keys.ufo.banka.banker) Credentials credentials) {

        harness.withUfo()
                .openLoginPage()
                .then(operationsTasks.login().withCredentials(credentials))
                .then(operationsTasks.searchClient().byRc(rcOfExistingClientFO))
                .then(operationsTasks.debitCardChangesTasks().stepsToTurnOffInternetPayments())
                .assertFirstRequirementDescription("Call centrum Banka - PLATEBNÍ KARTA - Žádost o akci - MO/TO Transakce - Deaktivace služby")
                .assertSecondRequirementDescription("Call centrum Banka - PLATEBNÍ KARTA - platby přes internet - Deaktivace služby")
                .clickTransactionsSettings()
                .clickInternetTransactionsOn()
                .clickSaveWithExpectedInfoError()
                .clickHomePage()
                .clickSettings()
                .doubleClickOpsCallcentrumBasisAccess()
                .clickSaveChangeOfPrivilages()
                .then(operationsTasks.searchClient().byRc(rcOfExistingClientFO))
                .clickDebitCard()
                .then(operationsTasks.debitCardChangesTasks().stepsToTurnOnInternetPayments())
                .assertFirstRequirementDescription("Call centrum Banka - PLATEBNÍ KARTA - Žádost o akci - MO/TO Transakce - Aktivace služby")
                .assertSecondRequirementDescription("Call centrum Banka - PLATEBNÍ KARTA - platby přes internet - Aktivace služby");
    }

    @TestCase(name = "Disabling online payments", environments = {PPE, TST1})
    @JiraTestCase(id = "CC-T2203")
    public void disablingOnlinePaymentsFOP(Harness harness, @Key(Keys.ufo.banka.banker) Credentials credentials) {

        harness.withUfo()
                .openLoginPage()
                .then(operationsTasks.login().withCredentials(credentials))
                .then(operationsTasks.searchClient().byCif(cifOfExistingClientFOP))
                .then(operationsTasks.debitCardChangesTasks().stepsToTurnOffInternetPayments())
                .assertFirstRequirementDescription("Call centrum Banka - PLATEBNÍ KARTA - Žádost o akci - MO/TO Transakce - Deaktivace služby")
                .assertSecondRequirementDescription("Call centrum Banka - PLATEBNÍ KARTA - platby přes internet - Deaktivace služby")
                .then(operationsTasks.debitCardChangesTasks().stepsToTurnOnInternetPayments())
                .assertFirstRequirementDescription("Call centrum Banka - PLATEBNÍ KARTA - Žádost o akci - MO/TO Transakce - Aktivace služby")
                .assertSecondRequirementDescription("Call centrum Banka - PLATEBNÍ KARTA - platby přes internet - Aktivace služby");
    }

    @TestCase(name = "Disabling online payments", environments = {PPE, TST1})
    @JiraTestCase(id = "CC-T2198")
    public void disablingOnlinePaymentsPO(Harness harness, @Key(Keys.ufo.banka.banker) Credentials credentials) {

        harness.withUfo()
                .openLoginPage()
                .then(operationsTasks.login().withCredentials(credentials))
                .then(operationsTasks.searchClient().byIco(icoOfExistingClientPO))
                .clickContinueOnFirstClient()
                .then(operationsTasks.debitCardChangesTasks().stepsToTurnOffInternetPayments())
                .assertFirstRequirementDescription("Call centrum Banka - PLATEBNÍ KARTA - Žádost o akci - MO/TO Transakce - Deaktivace služby")
                .assertSecondRequirementDescription("Call centrum Banka - PLATEBNÍ KARTA - platby přes internet - Deaktivace služby")
                .then(operationsTasks.debitCardChangesTasks().stepsToTurnOnInternetPayments())
                .assertFirstRequirementDescription("Call centrum Banka - PLATEBNÍ KARTA - Žádost o akci - MO/TO Transakce - Aktivace služby")
                .assertSecondRequirementDescription("Call centrum Banka - PLATEBNÍ KARTA - platby přes internet - Aktivace služby");
    }
}

