package cz.moneta.test.regression.channels.branch;

import cz.moneta.test.dsl.Harness;
import cz.moneta.test.dsl.ufo.banka.tasks.BankaTasks;
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 static cz.moneta.test.dsl.ufo.banka.pages.main.HKO101_S001_MainClientPage.CLIENT_CIF_STORE_KEY;
import static cz.moneta.test.harness.annotations.Environment.EDU;
import static cz.moneta.test.harness.annotations.Environment.PPE;
import static cz.moneta.test.harness.annotations.Environment.TST1;

@TestScenario(name = "Teller must set a static and physical signature")
public class SignatureSettingScenario {

    @TestCase(name = "Bank teller is able to login and set static signature to a client", environments = {TST1, PPE, EDU})
    @JiraTestCase(id = "POB-T19507")
    public void static_signature_test(Harness harness, @Key("ufo-banka-banker") Credentials credentials) {
        BankaTasks bankaTasks = harness.tasks().ufo().banka();

        harness.withUfo()
                .openLoginPage()
                .then(bankaTasks.login().withCredentialsAndTurnOffSignpad(credentials))
                .then(bankaTasks.newClient().create(credentials.getUsername()))
                .clickSearch()
                .clickSignatureTemplates()
                .turnSignpadOn()
                .fillSearchTerm(harness.get(CLIENT_CIF_STORE_KEY))
                .clickSearchByCif()
                .onClientDetailPage()
                .clickSignaturePatterns()
                .clickSignaturePatternsPage()
                .clickSignaturePatternsEdit()
                .clickSignatureStatic()
                .then(bankaTasks.newProduct().skipSignPadIfVisibleAfterPrintInstruction())
                .clickCenterButton()
                .onPrintPage()
                .closePrintWindow()
                .onPrintInstructionPage()
                .clickRightButton()
                .onPrintInstructionPage()
                .clickCenterButton()
                .onSignaturePatternsPage()
                .isSignatureStatic();
    }
}
