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

import cz.moneta.test.dsl.hypos.contractPrepare.HyposContractPrepare;
import cz.moneta.test.dsl.Harness;
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.BeforeAll;


@TestScenario(name = "Tests with unit in realties")
public class RealtyUnitTests {

    final static int REALTY_FLAT = 0;
    final static int REALTY_HOUSE = 1;

    private HyposTasks tasks;
    private static String contractId;

    @BeforeAll
    public void setup(Harness harness){
        HyposContractPrepare contractPrepare = new HyposContractPrepare(harness);
        contractId = contractPrepare.createNewContract(harness);
        contractPrepare.closeBrowser();
    }

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