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

import cz.moneta.test.dsl.Harness;
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.UKO720_S001_TaskPage.CATEGORY_COMBOBOX;
import static cz.moneta.test.dsl.ufo.operations.ufoOperations.UKO720_S001_TaskPage.SOLVING_GROUP_COMBOBOX;
import static cz.moneta.test.dsl.ufo.operations.ufoOperations.UKO720_S001_TaskPage.SUBCATEGORIES_COMBOBOX;
import static cz.moneta.test.dsl.ufo.operations.ufoOperations.UKO720_S001_TaskPage.TASK_TYPE_COMBOBOX;
import static cz.moneta.test.harness.annotations.Environment.PPE;
import static cz.moneta.test.harness.annotations.Environment.TST1;

@TestScenario(name = "RaS Tests")
public class RaSTests {

    private OperationsTasks operationsTasks;
    private String rcOfExistingClient;

    @BeforeAll
    public void getInfo(Harness harness) {
        operationsTasks = harness.tasks().ufo().operations();
        rcOfExistingClient = harness.getSystemOrConfigValue("cc.ras.rc");
    }

    @TestCase(name = "RaS - Filing a complaint on current account", environments = {PPE, TST1})
    @JiraTestCase(id = "CC-T2047")
    public void rasFilingAComplaintCurrentAccount(Harness harness, @Key(Keys.ufo.banka.banker) Credentials credentials) {

        harness.withUfo()
                .openLoginPage()
                .then(operationsTasks.login().withCredentials(credentials))
                .fillSearchInput(rcOfExistingClient)
                .clickSearchClient()
                .onClientDetailsPage()
                .clickComplaint()
                .selectCategory(16)
                .selectSubcategory(48)
                .selectTypeOfTask(869)
                .clickAssignCategoryAndFastSolve()
                .clickDontWannaRushIt()
                .selectPreferredCanal("email")
                .checkComboboxValue(CATEGORY_COMBOBOX, "16")
                .checkComboboxValue(SUBCATEGORIES_COMBOBOX, "48")
                .checkComboboxValue(TASK_TYPE_COMBOBOX, "869")
                .checkComboboxValue(SOLVING_GROUP_COMBOBOX, "ou=Stížnosti,ou=TMS,ou=GEOrgStr,dc=ge,dc=com")
                .findUserAndSelectSolver()
                .checkBusiness("MONETA Money Bank")
                .checkRcClientAndType(rcOfExistingClient)
                .checkNameOfTask("Stížnosti - standardní")
                .checkCanalOfTask("UFO OPS")
                .fillDescription("aaaa")
                .typeIntoClientsEmail("matej.liska@moneta.cz")
                .clickAssign()
                .onTaskPage()
                .checkDescriptionSolverEmailAndSolver(rcOfExistingClient, "matej.liska@moneta.cz")
                .checkTitleOfFirstAttachment("Notifikace o přijetí reklamace")
                .clickFinishAndAcceptAnswerAlert()
                .fillNote("aaaa")
                .clickFinishOK();
    }

    @TestCase(name = "RaS - Filing a complaint on Car", environments = {PPE, TST1})
    @JiraTestCase(id = "CC-T2119")
    public void rasFilingAComplaintCar(Harness harness, @Key(Keys.ufo.banka.banker) Credentials credentials) {

        harness.withUfo()
                .openLoginPage()
                .then(operationsTasks.login().withCredentials(credentials))
                .fillSearchInput(rcOfExistingClient)
                .clickSearchClient()
                .onClientDetailsPage()
                .clickComplaint()
                .selectCategory(13)
                .selectSubcategory(48)
                .selectTypeOfTask(275)
                .clickAssignCategory()
                .selectPreferredCanal("email")
                .checkComboboxValue(CATEGORY_COMBOBOX, "13")
                .checkComboboxValue(SUBCATEGORIES_COMBOBOX, "48")
                .checkComboboxValue(TASK_TYPE_COMBOBOX, "275")
                .checkComboboxValue(SOLVING_GROUP_COMBOBOX, "ou=Stížnosti Auto,ou=TMS,ou=GEOrgStr,dc=ge,dc=com")
                .findUserAndSelectSolver()
                .checkBusiness("MONETA Auto")
                .checkRcClientAndType(rcOfExistingClient)
                .checkNameOfTask("Stížnosti - standardní auto")
                .checkCanalOfTask("UFO OPS")
                .fillDescription("aaaa")
                .clickAssign()
                .onTaskPage()
                .typeIntoClientsEmail("matej.liska@moneta.cz")
                .clickSaveTask()
                .checkDescriptionSolverEmailAndSolver(rcOfExistingClient, "matej.liska@moneta.cz")
                .checkStatusLabelContent(" - Update úkolu proběhl v pořádku !")
                .clickFinishAndAcceptAnswerAlert()
                .fillNote("aaaa")
                .clickFinishOK();
    }

    @TestCase(name = "RaS - Filing a complaint on building savings", environments = {PPE, TST1})
    @JiraTestCase(id = "CC-T2120")
    public void rasFilingAComplaintBuildingsSavings(Harness harness, @Key(Keys.ufo.banka.banker) Credentials credentials) {

        harness.withUfo()
                .openLoginPage()
                .then(operationsTasks.login().withCredentials(credentials))
                .fillSearchInput(rcOfExistingClient)
                .clickSearchClient()
                .onClientDetailsPage()
                .clickComplaint()
                .selectCategory(76)
                .selectSubcategory(48)
                .selectTypeOfTask(1576)
                .clickAssignCategory()
                .selectPreferredCanal("email")
                .checkComboboxValue(CATEGORY_COMBOBOX, "76")
                .checkComboboxValue(SUBCATEGORIES_COMBOBOX, "48")
                .checkComboboxValue(TASK_TYPE_COMBOBOX, "1576")
                .checkComboboxValue(SOLVING_GROUP_COMBOBOX, "ou=Stavební spořitelna - reklamace,ou=TMS,ou=GEOrgStr,dc=ge,dc=com")
                .findUserAndSelectSolver()
                .checkBusiness("MONETA Auto")
                .checkRcClientAndType(rcOfExistingClient)
                .checkNameOfTask("Reklamace")
                .checkCanalOfTask("UFO OPS")
                .fillDescription("aaaa")
                .clickAssign()
                .onTaskPage()
                .typeIntoClientsEmail("matej.liska@moneta.cz")
                .clickSaveTask()
                .checkDescriptionSolverEmailAndSolver(rcOfExistingClient, "matej.liska@moneta.cz")
                .checkStatusLabelContent(" - Update úkolu proběhl v pořádku !")
                .clickFinishAndAcceptAnswerAlert()
                .fillNote("aaaa")
                .clickFinishOK();
    }
}
