package cz.moneta.test.regression.commercial.smallbusiness.digital.localtests.banka.client;

import cz.moneta.test.dsl.Harness;
import cz.moneta.test.dsl.ufo.banka.tasks.BankaTasks;
import cz.moneta.test.dsl.util.credentials.Keys;
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 cz.moneta.test.regression.commercial.smallbusiness.digital.DataPrepare;
import cz.moneta.test.regression.commercial.smallbusiness.digital.TearDown;
import org.junit.jupiter.api.AfterEach;
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 = "Create Fop CIF and edit")
public class CreateCifFopAndEdit {

    private NonClient nonClient;
    private BankaTasks bankaTasks;

    @BeforeAll
    protected void setUp(Harness harness) {
        bankaTasks = harness.tasks().ufo().banka();
        nonClient = DataPrepare.setUpFop(harness);
    }

    @TestCase(name = "Create New FOP Client and edit", environments = {TST1, PPE})
    @JiraTestCase(id = "SBD-T475")
    public void createNewFopCifAndEdit(Harness harness, @Key(Keys.ufo.banka.banker) Credentials credentials) {

        harness.withUfo()
                .openLoginPage()
                .then(bankaTasks.login().withCredentialsAndTurnOffSignpad(credentials))
                .then(bankaTasks.search().findByNewIco(nonClient.ico()))
                .then(bankaTasks.newFopClient().createFopCif(nonClient))
                .then(bankaTasks.sharedTasks().storeFullNameAndIco())
                .verifyThatCifIsValid()
                .clickEdit()
                .onEditPoFopPage()
                .fillPhoneNumber("725559544")
                .fillIdCard("209373723")
                .fillIdValid("19.02.2029")
                .clickSend()
                .onEditFoWhenEditingFopPage()
                .fillEmail(nonClient.email())
                .clickNotPoliticallyExposedPerson()
                .clickSend()
                .onAppendixConfirmationPage()
                .continueWithPrint()
                .onPrintPage()
                .saveDocumentUrl()
                .closePrintWindow()
                .onContinueAfterSignPage()
                .continueMainClientPage();

    }

    @AfterEach
    protected void tearDown(Harness harness) {
        TearDown.storeIcoFullNameCifSessionId(harness);
    }
}