package cz.moneta.test.regression.backoffice.callcenter.jenkinstests;

import cz.moneta.test.dsl.Harness;
import cz.moneta.test.dsl.ufo.operations.ufoOperations.taskslist.TypesOfViewFilter;
import cz.moneta.test.dsl.util.credentials.Keys;
import cz.moneta.test.dsl.util.task.ufo.operations.OperationsTasks;
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.BeforeAll;

import static cz.moneta.test.dsl.ufo.operations.ufoOperations.sendingInformationsToClient.STI701_S002_PostPanel.DATE_OF_ACCEPTANCE_REQUIREMENT_INPUT;
import static cz.moneta.test.dsl.ufo.operations.ufoOperations.UKO720_S001_TaskPage.TASK_ID_KEY;
import static cz.moneta.test.harness.annotations.Environment.PPE;
import static cz.moneta.test.harness.annotations.Environment.TST1;

@TestScenario(name = "Communciation with client")
public class CommunicationWithClient {

    private OperationsTasks operationsTasks;

    @BeforeAll
    public void getInfo(Harness harness) {
        operationsTasks = harness.tasks().ufo().operations();
    }

    @TestCase(name = "Communciation with client - email", environments = {PPE, TST1})
    @JiraTestCase(id = "CC-T2159")
    public void communicationWithClientEmail(Harness harness, @Key(Keys.ufo.banka.banker) Credentials credentials) {

        harness.withUfo()
                .openLoginPage()
                .then(operationsTasks.login().withCredentials(credentials))
                .then(operationsTasks.tasks().removeFraudAcccesAndOpenTasks())
                .then(operationsTasks.tasks().createTask())
                .selectChooseAction("Komunikace s klientem")
                .clickProcessDocuments()
                .onSendingInformationsToClient()
                .clickEmailPanel()
                .clickSendingFinalStatement()
                .checkClientName("AutoTest")
                .selectSalutation("Vážený pane")
                .fillInflectClientName("AutoTeste")
                .checkOverwrittenTaskId(harness.get(TASK_ID_KEY))
                .checkEmailAddress("matej.liska@moneta.cz")
                .clickMMB()
                .clickTaskFile()
                .clickSendEmail()
                .checkWarningSentence("Akce byla provedena.\nZavřete okno křížkem.")
                .closeWarningPageWindow()
                .clickListOfTasks()
                .selectTypeOfView(TypesOfViewFilter.TASK_SEARCH)
                .fillTaskID(harness.get(TASK_ID_KEY))
                .clickFind()
                .clickOpenTaskDetail()
                .clickSolve()
                .checkFirstNoteText("Stížnost/Reklamace - odeslán informační Email - na matej.liska@moneta.cz - Odeslání finálního vyjádření k požadavku klienta-")
                .clickFinishAndAcceptAnswerAlert()
                .fillNote("Automatický Test")
                .clickFinishOK()
                .clickOpenTaskDetail()
                .checkStatusLabelContent(" - Úkol byl v pořádku dokončen !");
    }

    @TestCase(name = "Communciation with client - post", environments = {PPE, TST1})
    @JiraTestCase(id = "CC-T2161")
    public void communicationWithClientPost(Harness harness, @Key(Keys.ufo.banka.banker) Credentials credentials) {

        harness.withUfo()
                .openLoginPage()
                .then(operationsTasks.login().withCredentials(credentials))
                .then(operationsTasks.tasks().removeFraudAcccesAndOpenTasks())
                .then(operationsTasks.tasks().createTask())
                .selectChooseAction("Komunikace s klientem")
                .clickProcessDocuments()
                .onSendingInformationsToClient()
                .clickPostPanel()
                .clickStatementToRequirement()
                .selectSalutationRight("Vážený pan")
                .checkClientName("AutoTest")
                .fillStreetWithDescNo("Na Rovince 871")
                .fillCity("Ostrava")
                .fillPostalCode("720 00")
                .selectSalutationLeft("Vážený pane")
                .fillInflectClientName("AutoTeste")
                .checkOverwrittenTaskId(harness)
                .checkDateOfAcceptanceRequirement(DATE_OF_ACCEPTANCE_REQUIREMENT_INPUT)
                .clickMMB();
    }
}
