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

import cz.moneta.test.dsl.Harness;
import cz.moneta.test.dsl.ufo.banka.tasks.BankaTasks;
import cz.moneta.test.dsl.util.data.client.NonClient;
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.Disabled;

import static cz.moneta.test.dsl.ufo.banka.pages.common.pages.OBR001_S001_PrintInstructionPage.ROOT_ID_KEY;
import static cz.moneta.test.dsl.util.credentials.Keys.ufo;
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;

@Disabled
@TestScenario(name = "Create new payment order")
public class CreateNewPaymentOrder {

    @TestCase(name = "Create new payment order", environments = {TST1, PPE, EDU})
    @JiraTestCase(id = "POB-T19493")
    public void tc_create_new_payment_order(Harness harness, @Key(ufo.banka.banker) Credentials credentials) {
        BankaTasks bankaTasks = harness.tasks().ufo().banka();
        String rcClient = harness.getConfig("branch.squad.rc.client");
        NonClient nonClient = harness.data().newNonClient()
                .withBirthNumber(rcClient);
        String receiverBankAccount = "115";
        String receiverBankCode = "0300";
        String amount = "1";
        String VARIABLE_SYMBOL = "2";
        String CONSTANT_SYMBOL = "3";
        String SPECIFIC_SYMBOL = "4";
        String MESSAGE = "nova platba";

        harness.withUfo()
                .openLoginPage()
                .then(bankaTasks.login().withCredentialsAndTurnOffSignpad(credentials))
                .then(bankaTasks.search().findByRC(nonClient.birthNumber()))
                .checkProductActive("Běžný účet")
                .openCurrentAccountDetailPage()
                .openCreatePaymentOrderPage()
                .fillCreditorAccNumber(receiverBankAccount)
                .fillCreditorAccBankCode(receiverBankCode)
                .fillAmountInput(amount)
                .fillOptionalData(VARIABLE_SYMBOL, CONSTANT_SYMBOL, SPECIFIC_SYMBOL, MESSAGE)
                .checkNotSavingNotFilledForm()
                .clickTodayButton()
                .clickSaveButton()
                .closePrintWindow()
                .onPrintInstructionPage()
                .clickLeftButton()
                .onPrintInstructionPage()
                .storeRootId()
                .clickCenterButton()
                .onCreatePaymentOrderPage()
                .checkFirstOrderPaymentId(harness.get(ROOT_ID_KEY));
    }
}
