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.brokerportal.enums.Client.*;
import static cz.moneta.test.dsl.util.credentials.Keys.brokerPortal;

@NonConcurrentTestScenario(name = "Calculator Page")
public class CalculatorTest {
    private BrokerPortalTasks tasks;

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

    @TestCase(name = "Fill and save calculator")
    @JiraTestCase(id = "ML-T150")
    public void tcNewContract(Harness harness, @Key(brokerPortal.broker) Credentials broker) {
        harness.withBrokerPortal()
                .openLoginPage()
                .then(tasks.loginTasks().loginWithCredentials(broker))
                .then(tasks.menuTasks().selectProductMortgage())
                .then(tasks.calculatorTasks().fillFullCalculator("1000001"))
                .then(tasks.calculatorTasks().calculateAndSaveCalculator());
    }

    @TestCase(name = "Fill and save calculator with more clients")
    @JiraTestCase(id = "ML-T168")
    public void tcNewContractMoreClients(Harness harness, @Key(brokerPortal.broker) Credentials broker) {
        harness.withBrokerPortal()
                .openLoginPage()
                .then(tasks.loginTasks().loginWithCredentials(broker))
                .then(tasks.menuTasks().selectProductMortgage())
                .then(tasks.calculatorTasks().fillClient(FIRST_CLIENT))
                .then(tasks.calculatorTasks().addAndFillClient(SECOND_CLIENT))
                .then(tasks.calculatorTasks().addAndFillClient(THIRD_CLIENT))
                .then(tasks.calculatorTasks().fillLoan("1000003"))
                .then(tasks.calculatorTasks().calculateAndSaveCalculator());
    }
}