package cz.moneta.test.regression.channels.digital.ib.newib.settings;

import cz.moneta.test.dsl.Harness;
import cz.moneta.test.dsl.newib.tasks.NewIbTasks;
import cz.moneta.test.dsl.newib.util.PaymentFormData;
import cz.moneta.test.harness.annotations.Environment;
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 org.junit.jupiter.api.BeforeAll;
import org.junit.jupiter.api.Order;

@TestScenarioWithOrder(name = "Limits")
public class LimitsSettingsTest {
    Credentials clientCredentials;
    PaymentFormData formData;

    @BeforeAll
    public void setup(Harness harness) {
        String clientBirthNumber = harness.getConfig("nib.rc.limits");
        String recipientAccountNumber = harness.getConfig("nib.recipientaccount.payments-one-account");

        clientCredentials = harness.tasks()
                .udebs()
                .findCredentialsByRC(clientBirthNumber);

        formData = PaymentFormData.builder()
                .recipientAccountNumber(recipientAccountNumber)
                .bankCode("0600")
                .amount("500")
                .variableSymbol("111")
                .constantSymbol("222")
                .specificSymbol("333")
                .recipientMessage("over Limit")
                .recipientAccountNumberEur("BE62 5100 0754 7061")
                .currency("CZK")
                .recipientName("Mirek Kereškéni")
                .fromAccountNumber("609-206971718/0600")
                .category("týdenní")
                .build();
    }

    @Order(1)
    @TestCase(name = "Change limits via settings", environments = {Environment.TST1, Environment.PPE})
    @JiraTestCase(id = "SB-T9339")
    public void limitsSettings(Harness harness) {
        NewIbTasks newIbTasks = harness.tasks().newIb();

        harness.withNewIb()
                .openLoginPage()
                .then(newIbTasks.loginWithUsernamePasswordAndDefaultMobKey(clientCredentials.getUsername(), clientCredentials.getPassword()))
                .then(newIbTasks.changeLimitsViaSettings(formData))
                .then(newIbTasks.setPaymentOverLimit(formData))
                .then(newIbTasks.resetLimitsViaSettings(formData));
    }
}
