package cz.moneta.test.regression.channels.digital.ib.newib.payment.fon;

import cz.moneta.test.dsl.Harness;
import cz.moneta.test.dsl.newib.tasks.NewIbTasks;
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 = "Advice tests")
public class AdviceFonTest {

    Credentials clientCredentials;
    String clientId;

    @BeforeAll
    public void getCredentials(Harness harness) {
        String clientBirthNumber = harness.getConfig("nib.rc.payments.advice.fon");

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

        clientId = harness.withUdebs()
                .usersTable()
                .getClientId(clientBirthNumber);
    }

    @Order(1)
    @TestCase(name = "CA - advice on the advice tab", environments = {Environment.TST1, Environment.PPE})
    @JiraTestCase(id = "SB-T9220")
    public void adviceFonTest(Harness harness) {
        NewIbTasks newIbTasks = harness.tasks().newIb();
        harness.withNewIb()
                .openLoginPage()
                .then(newIbTasks.loginWithUsernamePasswordAndDefaultMobKey(clientCredentials.getUsername(), clientCredentials.getPassword()))
                .then(newIbTasks.adviceFonTest());
    }

    @Order(2)
    @TestCase(name = "CA - advice on the transaction detail", environments = {Environment.TST1, Environment.PPE})
    @JiraTestCase(id = "SB-T9221")
    public void adviceOnTheTransactionDetailFonTest(Harness harness) {
        NewIbTasks newIbTasks = harness.tasks().newIb();
        harness.withNewIb()
                .openLoginPage()
                .then(newIbTasks.loginWithUsernamePasswordAndDefaultMobKey(clientCredentials.getUsername(), clientCredentials.getPassword()))
                .then(newIbTasks.adviceOnTheTransactionDetailFonTest());
    }
}