package cz.moneta.test.regression.backoffice.callcenter.jenkinstests;
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.harness.annotations.Environment.PPE;
import static cz.moneta.test.harness.annotations.Environment.TST1;

@TestScenario(name = "Access employee")
public class AccessEmployee {
    private OperationsTasks operationsTasks;
    private String rcOfExistingClient;

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

    @TestCase(name = "Access employee", environments = {PPE, TST1})
    @JiraTestCase(id = "CC-T2147")
    public void accessEmployee(Harness harness, @Key(Keys.ufo.banka.banker) Credentials credentials) {
        harness.withUfo()
                .openLoginPage()
                .then(operationsTasks.login().withCredentials(credentials))
                .fillSearchInput(rcOfExistingClient)
                .clickSearchClient()
                .onEmployeeDetailsConfirmationPage()
                .checkConfirmationButtonsOfEmployeePrivilege(2)
                .clickYes()
                .assertClientRc(rcOfExistingClient)
                .checkListOfProducts()
                .clickHomePage()
                .fillSearchInput(rcOfExistingClient)
                .clickSearchClient()
                .onEmployeeDetailsConfirmationPage()
                .checkConfirmationButtonsOfEmployeePrivilege(2)
                .clickNo()
                .checkSearchInputInMainPage()
                .clickSettings()
                .doubleClickEmployeeAccess()
                .clickSaveChangeOfPrivilages()
                .fillSearchInput(rcOfExistingClient)
                .clickSearchClient()
                .onEmployeeDetailsConfirmationPage()
                .checkConfirmationButtonsOfEmployeePrivilege(1)
                .clickNo();
    }
}
