package cz.moneta.test.regression.investments;

import cz.moneta.test.dsl.Harness;
import cz.moneta.test.dsl.newib.tasks.NewIbTasks;
import cz.moneta.test.harness.annotations.JiraTestCase;
import cz.moneta.test.harness.annotations.TestCase;
import cz.moneta.test.harness.annotations.TestScenario;

@TestScenario()
public class InvestmentsSaleTests {

    @TestCase(name = "Sale assets in IB")
    @JiraTestCase(id = "INVEST-T591", project = "Investments")
    public void investmentSale(Harness harness) {
        String username = harness.getConfig("investments.sale.nib-credentials.clientUsername");
        String password = harness.getConfig("investments.sale.nib-credentials.clientPassword");
        String isin = harness.getConfig("investments.sale.isin");
        harness.log("username: " + username);
        harness.log("password: " + password);
        harness.log("isin: " + isin);
        NewIbTasks ib = harness.tasks().newIb();
        harness.withNewIb().openLoginPage()
                .then(ib.loginWithUsernamePasswordAndDefaultMobKey(username, password))
                .goToInvestments()
                .clickInvestmentsCard()
                .confirmDisclaimer()
                .waitForMenu()
                .clickMyPortfolio()
                .clickInvestmentByIsin(isin)
                .clickSale()
                .fillAmount("5")
                .clickSubmit()
                .clickSaleAnyway()
                .fillMobileKey("12341234")
                .clickSecondFactorSubmit();
    }
}