package cz.moneta.test.regression.collateral.hypos;

import cz.moneta.test.dsl.Harness;
import cz.moneta.test.dsl.hypos.contractPrepare.HyposContractPrepare;
import cz.moneta.test.dsl.hypos.enums.HyposProfile;
import cz.moneta.test.dsl.hypos.tasks.HyposTasks;
import cz.moneta.test.harness.annotations.TestCase;
import cz.moneta.test.harness.annotations.TestScenario;
import org.junit.jupiter.api.BeforeEach;

@TestScenario(name = "Tests in Hypos")
public class MarketValuationOrderForm {

    private HyposTasks tasks;
    private static String contractId;
    final static int REALTY_FLAT_VERIFICATION = 0;
    final static int REALTY_FLAT_DESKTOP = 1;
    final static int REALTY_FLAT_FULL = 2;

    final static int REALTY_HOUSE_DESKTOP = 0;
    final static int REALTY_HOUSE_FULL = 1;

    @BeforeEach
    public void setup(Harness harness){
        HyposContractPrepare contractPrepare = new HyposContractPrepare(harness);
        contractId = contractPrepare.createNewContract(harness);
        contractPrepare.createNewContract(harness);
        contractPrepare.closeBrowser();
        contractPrepare.addUnitToRealty(harness, contractId, REALTY_FLAT_VERIFICATION);
        contractPrepare.closeBrowser();
    }

    @TestCase(name = "Adding unit to created realty.")
    public void checkOrderFormElements(Harness harness) {
        tasks = harness.tasks().hypos();
        harness.withHypos()
                .openLoginPage()
                .then(tasks.loginToHyposWithProfile(HyposProfile.SUPERVISOR))
                .then(tasks.searchAndOpenContract(contractId))
                .then(tasks.valuationTasks().goToMarketValuationForm())
                .then(tasks.valuationTasks().checkElementsInOrderForm())
        ;
    }

    @TestCase(name = "Creating a new valuation for flat.")
    public void createValuationFlat(Harness harness){
        tasks = harness.tasks().hypos();
        harness.withHypos()
                .openLoginPage()
                .then(tasks.loginToHyposWithProfile(HyposProfile.SUPERVISOR))
                .then(tasks.searchAndOpenContract(contractId))
                .then(tasks.valuationTasks().goToMarketValuationForm())
                .then(tasks.valuationTasks().doFlatMarketValuation(REALTY_FLAT_DESKTOP))
        ;
    }

    @TestCase(name = "Creating a new valuation for house.")
    public void createValuationHouse(Harness harness){
        tasks = harness.tasks().hypos();
        harness.withHypos()
                .openLoginPage()
                .then(tasks.loginToHyposWithProfile(HyposProfile.SUPERVISOR))
                .then(tasks.searchAndOpenContract(contractId))
                .then(tasks.valuationTasks().goToMarketValuationForm())
                .then(tasks.valuationTasks().doHouseMarketValuation(REALTY_HOUSE_FULL))
        ;
    }
}

