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

import cz.moneta.test.dsl.Harness;
import cz.moneta.test.dsl.util.credentials.Keys;
import cz.moneta.test.dsl.util.task.brokerportal.BrokerPortalPreconditions;
import cz.moneta.test.dsl.util.task.brokerportal.BrokerPortalTasks;
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.BeforeEach;

@TestScenario(name = "Desktop valuation test for house")
public class DesktopHouse {
    private final static int DESKTOP_HOUSE = 0;
    private static String contractId;

    @BeforeEach
    public void setup(Harness harness, @Key(Keys.brokerPortal.broker) Credentials broker) {
        BrokerPortalPreconditions bpPreconditions = new BrokerPortalPreconditions(harness, broker);
        contractId = bpPreconditions.createNewContract();
        bpPreconditions.closeBrowser();
    }

    @TestCase(name = "Create valuation with desktop result for house")
    public void houseValuations(Harness harness, @Key(Keys.brokerPortal.broker) Credentials broker) {
        BrokerPortalTasks tasks = harness.tasks().brokerPortal();
        harness.withBrokerPortal().openLoginPage()
                .then(tasks.loginTasks().loginWithCredentials(broker))
                .then(tasks.brokerPortalValuations().findContract(contractId))
                .then(tasks.brokerPortalValuations().evaluateHouse(DESKTOP_HOUSE, contractId));
    }
}
