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

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 = "Confirmation of account managment in UFO OPS")
public class ConfirmationOfAccountManagmentInUfoOps {

    private String rcOfExistingClient;
    private OperationsTasks operationsTasks;

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

    @TestCase(name = "Confirmation of account managment in UFO OPS", environments = {PPE, TST1})
    @JiraTestCase(id = "CC-T2132")
    public void confirmationOfAccountManagmentInUfoOpsCzech(Harness harness, @Key(Keys.ufo.banka.banker) Credentials credentials) {

        harness.withUfo()
                .openLoginPage()
                .then(operationsTasks.login().withCredentials(credentials))
                .fillSearchInput(rcOfExistingClient)
                .clickSearchClient()
                .onClientDetailsPage()
                .clickAccountList()
                .clickConfirmationAboutAccount()
                .clickSend()
                .checkIfIBSBIsChecked()
                .clickSend()
                .onClientDetailPage()
                .checkIfStatusBarIsOverwritten("Poplatek byl zaúčtován pod")
                .clickTransactions()
                .checkValueInTransactionTable("300")
                .clickDetailLastRowInTransactionTable()
                .checkAvField("Poplatek za potvrzení")
                .dateCompare()
                .clickBack()
                .clickCorrespondence()
                .assertPrintName("Potvrzení o vedení účtu")
                .checkSendingChannel("Internet Banka/Smart banka")
                .closeCorrespondency()
                .clickDemand()
                .clickRefreshRequirementButton()
                .checkDateInRequirement()
                .checkDemandDescriptionFirstRow("Call centrum Banka - Zaslání dokumentu - vedení účtu");
    }

    @TestCase(name = "Confirmation of account managment in UFO OPS", environments = {PPE, TST1})
    @JiraTestCase(id = "CC-T2133")
    public void confirmationOfAccountManagmentInUfoOpsEnglish(Harness harness, @Key(Keys.ufo.banka.banker) Credentials credentials) {

        harness.withUfo()
                .openLoginPage()
                .then(operationsTasks.login().withCredentials(credentials))
                .fillSearchInput(rcOfExistingClient)
                .clickSearchClient()
                .onClientDetailsPage()
                .clickAccountList()
                .clickConfirmationAboutAccount()
                .selectLanguage(1)
                .clickSend()
                .checkIfIBSBIsChecked()
                .clickSend()
                .onClientDetailPage()
                .checkIfStatusBarIsOverwritten("Poplatek byl zaúčtován pod")
                .clickTransactions()
                .checkValueInTransactionTable("300")
                .clickDetailLastRowInTransactionTable()
                .checkAvField("Poplatek za potvrzení")
                .dateCompare()
                .clickBack()
                .clickCorrespondence()
                .assertPrintName("Account maintenance confirmation")
                .checkSendingChannel("Internet Banka/Smart banka")
                .closeCorrespondency()
                .clickDemand()
                .clickRefreshRequirementButton()
                .checkDateInRequirement()
                .checkDemandDescriptionFirstRow("Call centrum Banka - Zaslání dokumentu - vedení účtu");
    }

    @TestCase(name = "Confirmation of account managment in UFO OPS", environments = {PPE, TST1})
    @JiraTestCase(id = "CC-T2134")
    public void confirmationOfAccountManagmentInUfoOpsWithoutFee(Harness harness, @Key(Keys.ufo.banka.banker) Credentials credentials) {

        harness.withUfo()
                .openLoginPage()
                .then(operationsTasks.login().withCredentials(credentials))
                .fillSearchInput(rcOfExistingClient)
                .clickSearchClient()
                .onClientDetailsPage()
                .clickAccountList()
                .clickConfirmationAboutAccount()
                .selectFee(1)
                .fillReason("chyba na OM")
                .clickSend()
                .checkIfIBSBIsChecked()
                .clickSend()
                .onClientDetailPage()
                .checkIfStatusBarIsOverwritten("")
                .clickCorrespondence()
                .assertPrintName("Potvrzení o vedení účtu")
                .checkSendingChannel("Internet Banka/Smart banka")
                .closeCorrespondency()
                .clickDemand()
                .clickRefreshRequirementButton()
                .checkDateInRequirement()
                .checkDemandDescriptionFirstRow("Call centrum Banka - Zaslání dokumentu - vedení účtu");
    }
}
