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

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 = "Documents Tests")
public class DocumentsTest {

    Credentials clientCredentials;
    String clientId;

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

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

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

    @Order(1)
    @TestCase(name = "Documents - Overview", environments = {Environment.TST1, Environment.PPE})
    @JiraTestCase(id = "SB-T9181")
    public void documentsOverviewTest(Harness harness) {
        NewIbTasks newIbTasks = harness.tasks().newIb();
        harness.withNewIb()
                .openLoginPage()
                .then(newIbTasks.loginWithUsernamePasswordAndDefaultMobKey(clientCredentials.getUsername(), clientCredentials.getPassword()))
                .then(newIbTasks.documentsOverviewTest());
    }
}