package cz.moneta.test.regression.channels.digital.ml.brokersportal;

import cz.moneta.test.dsl.Harness;
import cz.moneta.test.dsl.util.task.brokerportal.BrokerPortalTasks;
import cz.moneta.test.harness.annotations.JiraTestCase;
import cz.moneta.test.harness.annotations.TestCase;
import cz.moneta.test.harness.annotations.NonConcurrentTestScenario;
import cz.moneta.test.harness.support.auth.Credentials;
import cz.moneta.test.harness.support.auth.Key;
import org.junit.jupiter.api.BeforeEach;

import static cz.moneta.test.dsl.util.credentials.Keys.brokerPortal;

@NonConcurrentTestScenario(name = "Check login")
public class LoginTest {
    private BrokerPortalTasks tasks;

    @BeforeEach
    public void setup(Harness harness) {
        tasks = harness.tasks().brokerPortal();
    }

    @TestCase(name = "Check correct login")
    @JiraTestCase(id = "ML-T154")
    public void tcLogin(Harness harness, @Key(brokerPortal.broker) Credentials broker) {
        harness.withBrokerPortal()
                .openLoginPage()
                .then(tasks.loginTasks().loginWithCredentials(broker))
                .checkPresentUserProfile();
    }

    @TestCase(name = "Check forgotten password")
    @JiraTestCase(id = "ML-T157")
    public void tcForgottenPassword(Harness harness, @Key(brokerPortal.broker) Credentials broker) {
        harness.withBrokerPortal()
                .openLoginPage()
                .clickForgottenPasswordButton()
                .fillLogin(broker.getUsername())
                .clickSendButton()
                .clickGoToLoginPage();
    }
}