package cz.moneta.test.regression.feeincome.insurance;

import cz.moneta.test.dsl.Harness;
import cz.moneta.test.dsl.ufo.banka.tasks.BankaTasks;
import cz.moneta.test.dsl.ufo.banka.tasks.insurance.InsuranceIndividualTasks;
import cz.moneta.test.dsl.util.credentials.Keys;
import cz.moneta.test.dsl.util.data.client.NonClient;
import cz.moneta.test.harness.annotations.JiraTestCase;
import cz.moneta.test.harness.annotations.TestCase;
import cz.moneta.test.harness.annotations.TestScenario;
import cz.moneta.test.harness.support.auth.Credentials;
import cz.moneta.test.harness.support.auth.Key;
import org.junit.jupiter.api.Assertions;

@TestScenario()
public class LifeInsuranceTest {
    @TestCase(name = "Zivotni pojisteni NN")
    @JiraTestCase(id = "INS-T914", project = "Insurance Cluster")
    public void lifeInsuranceViaUFOTest(Harness harness, @Key(Keys.ufo.banka.banker) Credentials credentials) {
        BankaTasks bankaTasks = harness.tasks().ufo().banka();
        InsuranceIndividualTasks insuranceTasks = bankaTasks.newInsuranceIndividualTasks();
        NonClient client = insuranceTasks.prepareClientViaWSO();

        harness.withUfo()
                .openLoginPage()
                .then(bankaTasks.login().withCredentialsAndTurnOffSignpad(credentials))
                //.openLoginPageTomcat() //tomcat
                //.selectFirstOm() //tomcat
                //.selectUfoBankaAndContinue() //tomcat
                .then(insuranceTasks.searchClientAndOpenIndividualInsuranceForm(client))
                .then(insuranceTasks.fillInsuranceForm())
                .then(insuranceTasks.signDocuments())
                .clickOpenNNAndSwitchTab()
                .storeNnInputValues();

        Assertions.assertEquals(client.firstName(), harness.get("NN_FIRSTNAME"));
        Assertions.assertEquals(client.lastName(), harness.get("NN_LASTNAME"));
        Assertions.assertEquals(insuranceTasks.formatBirthDate(client.birthDate()), harness.get("NN_BIRTHDATE"));
        Assertions.assertEquals("Male", harness.get("NN_SEX"));
    }
}