package cz.moneta.test.regression.ufoframework;

import cz.moneta.test.dsl.Harness;
import cz.moneta.test.dsl.ufo.ufoframework.tasks.FunctionalTestsTasks;
import cz.moneta.test.dsl.util.credentials.Keys;
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 cz.moneta.test.regression.commercial.smallbusiness.digital.TearDown;
import org.junit.jupiter.api.AfterEach;

import static cz.moneta.test.harness.annotations.Environment.DEV;
import static cz.moneta.test.harness.annotations.Environment.PPE;
import static cz.moneta.test.harness.annotations.Environment.TST1;

@TestScenario(name = "Validation Tests")
public class ValidationTests {

    @TestCase(name = "Validation Tests", environments = {TST1, PPE, DEV})
    @JiraTestCase(id = "UFO-T509")
    public void validations(Harness harness, @Key(Keys.ufo.banka.banker) Credentials credentials) {

        String validHAccountNumber = "123";
        String notValidHAccountNumber = "1234";
        String validHEmail = "name@mail.subdomain.com";
        String notValidHEmail = "user@";
        String validHDate = "12.11.2025";
        String notValidHDate = "2025-07-14";
        String validHBirthNumber = "8202075090";
        String notValidHBirthNumber = "11";
        String validHIco = "48155497";
        String notValidHIco = "11";
        String validHFullName = "Jakub Slapnička";
        String notValidHFullName = "11";

        FunctionalTestsTasks functionalTestsTasks = harness.tasks().ufo().functionalTests();
        harness.withUfo()
                .openLoginPage()
                .then(functionalTestsTasks.login().withCredentials(credentials))
                .clickOtherJarda()
                .clickValidationValueTypes()
                .then(functionalTestsTasks.verificationsTasks().verifyHAccountNumber(validHAccountNumber, notValidHAccountNumber))
                .then(functionalTestsTasks.verificationsTasks().verifyHEmail(validHEmail, notValidHEmail))
                .then(functionalTestsTasks.verificationsTasks().verifyHDate(validHDate, notValidHDate))
                .then(functionalTestsTasks.verificationsTasks().verifyHBirthNumber(validHBirthNumber, notValidHBirthNumber))
                .then(functionalTestsTasks.verificationsTasks().verifyHIco(validHIco, notValidHIco))
                .then(functionalTestsTasks.verificationsTasks().verifyHFullName(validHFullName, notValidHFullName));
    }

    @AfterEach
    protected void tearDown(Harness harness) {
        TearDown.storeBirthNumberFullNameCifSessionId(harness);
    }
}
