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

import cz.moneta.test.dsl.Harness;
import cz.moneta.test.dsl.util.credentials.Keys;
import cz.moneta.test.dsl.util.task.brokerportal.BrokerPortalTasks;
import cz.moneta.test.harness.annotations.JiraTestCase;
import cz.moneta.test.harness.annotations.NonConcurrentTestScenario;
import cz.moneta.test.harness.annotations.TestCase;
import cz.moneta.test.harness.support.auth.Credentials;
import cz.moneta.test.harness.support.auth.Key;

import static cz.moneta.test.dsl.brokerportal.enums.Client.FIRST_CLIENT;
import static cz.moneta.test.dsl.brokerportal.enums.Client.SECOND_CLIENT;

@NonConcurrentTestScenario(name = "Contract Detail Page")
public class ContractDetailTest {

    @TestCase(name = "Edit Contact Details")
    @JiraTestCase(id = "ML-T2247")
    public void tcEditContactDetails(Harness harness, @Key(Keys.brokerPortal.broker) Credentials broker) {
        BrokerPortalTasks tasks = harness.tasks().brokerPortal();
        harness.withBrokerPortal()
                .openLoginPage()
                .then(tasks.loginTasks().loginWithCredentials(broker))
                .then(tasks.menuTasks().selectProductMortgage())
                .then(tasks.calculatorTasks().fillCalculator("1000001"))
                .then(tasks.calculatorTasks().calculateAndSaveCalculator())
                .opensContractDetailPage()
                .then(tasks.contractDetailTasks().fillAndSaveContactDetails());
    }

    @TestCase(name = "Check assign to bank")
    @JiraTestCase(id = "ML-T2589")
    public void tcAssingToBank(Harness harness, @Key(Keys.brokerPortal.broker) Credentials broker) {
        BrokerPortalTasks tasks = harness.tasks().brokerPortal();
        harness.withBrokerPortal()
                .openLoginPage()
                .then(tasks.loginTasks().loginWithCredentials(broker))
                .then(tasks.menuTasks().selectProductMortgage())
                .then(tasks.calculatorTasks().fillCalculator("1000001"))
                .then(tasks.calculatorTasks().calculateAndSaveCalculator())
                .clickToShortApplicationButton()
                .then(tasks.shortApplicationTasks().fillAndConfirmShortApplication())
                .then(tasks.shortApplicationTasks().checkShortApplicationSummary())
                .clickCreateApplicationButton()
                .then(tasks.shortApplicationTasks().signShortApplication())
                .clickToContractDetail()
                .clickAssignProcessingTeam()
                .checkMissingDocument();
    }

    @TestCase(name = "Check checklist upload doc")
    @JiraTestCase(id = "ML-T2591")
    public void tcCheckChecklistDoc(Harness harness, @Key(Keys.brokerPortal.broker) Credentials broker) {
        BrokerPortalTasks tasks = harness.tasks().brokerPortal();
        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().fillLoan("1000002"))
                .then(tasks.calculatorTasks().calculateAndSaveCalculator())
                .opensContractDetailPage()
                .then(tasks.contractDetailTasks().uploadChecklistDoc("Občanský průkaz"));
    }
}