package cz.moneta.test.regression.transactional.payments.cash.kasanovaLastTest;

import cz.moneta.test.dsl.Harness;
import cz.moneta.test.dsl.util.credentials.Keys.kasanova;
import cz.moneta.test.harness.annotations.JiraTestCase;
import cz.moneta.test.harness.annotations.NonConcurrentTestScenario;
import cz.moneta.test.harness.annotations.TestCase;
import cz.moneta.test.harness.support.auth.Credentials;
import cz.moneta.test.harness.support.auth.Key;
import org.junit.jupiter.api.MethodOrderer;
import org.junit.jupiter.api.Order;
import org.junit.jupiter.api.TestMethodOrder;

/**
 * Process:
 *  1) Function 88 - Uzaverka
 *  2) Function 93 - Permanent Logout
 *  3) Login
 *  4) Function 95 - get Till Summary
 *  5) Function 91 - Start Day
 *  6) Logout
 */
@TestMethodOrder(MethodOrderer.OrderAnnotation.class)
@NonConcurrentTestScenario(name = "(Fce 88 + Fce 91) Uzávěrka + Start Dne")
public class KSNFunction88Test {

    @Order(1)
    @JiraTestCase(id = "PAY-T1788")
    @TestCase(name = "(Fce 88 - Uzávěrka)")
    public void func88uzaverka(Harness harness, @Key(kasanova.banker) Credentials banker, @Key(kasanova.verifyBanker) Credentials verifyBanker) {

        harness.log("---------------- START TEST (FUNCTION 88 Uzaverka) ----------------");
        harness.withKasanova()
                .openLoginPage()
                .then(harness.tasks().kasanova().loginWithUserAndPassword(banker))
                .KSNSection8()
                .KSNFunction88()
                .checkCurrencyAndGoNext("CZK")
                .checkCurrencyAndGoNext("USD")
                .checkCurrencyAndGoNext("EUR")
                .clickCashBalance()
                .checkCurrencyAndGoNext("CZK")
                .checkCurrencyAndGoNext("USD")
                .checkCurrencyAndGoNext("EUR")
                .fillVerification(harness.getConfig("kasanova-config.verify-banker.uid"), verifyBanker.getUsername(), verifyBanker.getPassword())
                .clickNext()
                .kasaDialogClickOK(15)
                .kasaDialogClickOK(15)
                .verificationInfoDialogClose()
                .KSNSection9()
                .KSNFunction93();
        harness.log("---------------- END TEST (FUNCTION 88 Uzaverka) ----------------");
    }

    @Order(2)
    @JiraTestCase(id = "PAY-T1797")
    @TestCase(name = "(Fce 91 - Start Dne)")
    public void func91startDay(Harness harness, @Key(kasanova.banker) Credentials banker) {
        harness.log("---------------- START TEST (FUNCTION 91 StartDay) ----------------");
        harness.withKasanova()
                .openLoginPage()
                .then(harness.tasks().kasanova().loginWithUserAndPassword(banker))
                .KSNSection9()
                .KSNFunction95()
                .fillTillId("7043")
                .enterFunction95()
                .switchToDefaultFrame()
                .switchToMainFrame()
                .checkRedirect("95 - Celkový sumář pokladny")
                .executeStartDay("7043")
                .logOut();
        harness.log("---------------- END TEST (FUNCTION 91 StartDay) ----------------");
    }

}
