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.TestScenarioWithOrder;
import cz.moneta.test.harness.support.auth.Credentials;
import cz.moneta.test.harness.support.auth.Key;
import org.junit.jupiter.api.BeforeAll;
import org.junit.jupiter.api.Order;

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

@TestScenarioWithOrder(name = "Debit card tests")
public class DebitCardTests {
    private OperationsTasks operationsTasks;
    private String rcOfExistingClient;
    private String phoneNumber;

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

    @Order(1)
    @TestCase(name = "Debit temporary block", environments = {PPE, TST1})
    @JiraTestCase(id = "CC-T2093")
    public void debitTemporaryBlock(Harness harness, @Key(Keys.ufo.banka.banker) Credentials credentials) {

        harness.withUfo()
                .openLoginPage()
                .then(operationsTasks.login().withCredentials(credentials))
                .then(operationsTasks.debitCardChangesTasks().searchClientAndCheckNumberofCard(rcOfExistingClient))
                .clickBlocation()
                .selectReason("Dočasná blokace")
                .fillIntoTelephoneNumberBox(phoneNumber)
                .clickCalendar()
                .clickNextMonth()
                .clickRegularDay()
                .clickHolder()
                .clickSubmitSaveButton()
                .clickConfirmBlockButton()
                .clickRequirementButton()
                .clickRefreshButton()
                .assertReqTempBlock("Call centrum Banka - PLATEBNÍ KARTA - Žádost o akci - dočasná blokace");
    }

    @Order(2)
    @TestCase(name = "Unblock of temporary block on debit card", environments = {PPE, TST1})
    @JiraTestCase(id = "CC-T2094")
    public void unblockOfTemporaryBlockOnDebitCard(Harness harness, @Key(Keys.ufo.banka.banker) Credentials credentials) {

        harness.withUfo()
                .openLoginPage()
                .then(operationsTasks.login().withCredentials(credentials))
                .then(operationsTasks.debitCardChangesTasks().searchClientAndCheckNumberofCard(rcOfExistingClient))
                .clickBlocation()
                .selectReasonUnblock("Bez poplatku")
                .clickUnblockDebitCardButton()
                .clickConfirmAlertButton()
                .clickRequirementButton()
                .clickRefreshButton()
                .assertReqTempUnblock("Call centrum Banka - PLATEBNÍ KARTA - Žádost o akci - Odblokace - dočasné blokace");
    }
}