package cz.moneta.test.regression.channels.digital.ib.oldib.insurance;

import cz.moneta.test.dsl.Harness;
import cz.moneta.test.dsl.util.credentials.Keys;
import cz.moneta.test.dsl.util.data.client.NewClientWithCurrentAccountInformation;
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.*;
import cz.moneta.test.harness.annotations.JiraTestCase;
import org.junit.jupiter.api.parallel.Execution;
import org.junit.jupiter.api.parallel.ExecutionMode;

import static cz.moneta.test.harness.annotations.Environment.PPE;
import static cz.moneta.test.harness.annotations.Environment.TST1;

@Execution(ExecutionMode.SAME_THREAD)
@TestMethodOrder(MethodOrderer.OrderAnnotation.class)
@TestScenario(name = "Verify long-term travel insurance")
public class LongTermTravelInsuranceTest {

    private Credentials credentials;

    @BeforeEach
    public void createClientWithBuAndIb(Harness harness, @Key(Keys.ufo.banka.banker) Credentials banker) {
        NewClientWithCurrentAccountInformation newCustomerWithCurrentAccountAndIb = harness.dataPrepare()
                .createNewFoCustomerWithCurrentAccountAndIbViaWso2(banker.getUsername());

        String clientBirthNumber = newCustomerWithCurrentAccountAndIb.getClientData().birthNumber();

        credentials = harness.tasks().wso2().idm().getIbCredentialsByRC(clientBirthNumber);
    }

    @Disabled
    @Order(1)
    @TestCase(name = "Go to insurance page and create long-term travel insurance variant Europe-Single", environments = {TST1, PPE})
    @JiraTestCase(id = "IB-T8228")
    void userWithCurrentAccount_shouldCreateLongTermInsuranceEuropeSingle(Harness harness) {

        harness.withIB()
                .openLoginPage()
                .then(harness.tasks().ib().loginWithDefaultMobileKeyAnd(credentials))
                .clickInsurance()
                .clickCreateLongTermInsurance()
                .clickAccountSelect()
                .clickRegionEuropeSelect()
                .clickVariantSingleSelect()
                .clickLicenceAgreement()
                .clickInsuranceAgreement()
                .clickContinueButton()
                .typeSmsCode("12341234")
                .clickSend()
                .clickListInsurace()
                .checkInsuranceIsFound("Dlouhodobé cestovní pojištění Evropa (single)");
    }

    @Disabled
    @Order(2)
    @TestCase(name = "Go to insurance page and create long-term travel insurance variant Europe-Family", environments = {TST1, PPE})
    @JiraTestCase(id = "IB-T8229")
    void userWithCurrentAccount_shouldCreateLongTermInsuranceEuropeFamily(Harness harness) {

        harness.withIB()
                .openLoginPage()
                .then(harness.tasks().ib().loginWithDefaultMobileKeyAnd(credentials))
                .clickInsurance()
                .clickCreateLongTermInsurance()
                .clickAccountSelect()
                .clickRegionEuropeSelect()
                .clickVariantFamilySelect()
                .clickLicenceAgreement()
                .clickInsuranceAgreement()
                .clickContinueButton()
                .typeSmsCode("12341234")
                .clickSend()
                .clickListInsurace()
                .checkInsuranceIsFound("Dlouhodobé cestovní pojištění Evropa (family)");
    }

    @Disabled
    @Order(3)
    @TestCase(name = "Go to insurance page and create long-term travel insurance variant World-Single", environments = {TST1, PPE})
    @JiraTestCase(id = "IB-T8230")
    void userWithCurrentAccount_shouldCreateLongTermInsuranceWorldSingle(Harness harness) {

        harness.withIB()
                .openLoginPage()
                .then(harness.tasks().ib().loginWithDefaultMobileKeyAnd(credentials))
                .clickInsurance()
                .clickCreateLongTermInsurance()
                .clickAccountSelect()
                .clickRegionWorldSelect()
                .clickVariantSingleSelect()
                .clickLicenceAgreement()
                .clickInsuranceAgreement()
                .clickContinueButton()
                .typeSmsCode("12341234")
                .clickSend()
                .clickListInsurace()
                .checkInsuranceIsFound("Dlouhodobé cestovní pojištění Svět (single)");
    }

    @Disabled
    @Order(4)
    @TestCase(name = "Go to insurance page and create long-term travel insurance variant World-Family", environments = {TST1, PPE})
    @JiraTestCase(id = "IB-T8231")
    void userWithCurrentAccount_shouldCreateLongTermInsuranceWorldFamily(Harness harness) {

        harness.withIB()
                .openLoginPage()
                .then(harness.tasks().ib().loginWithDefaultMobileKeyAnd(credentials))
                .clickInsurance()
                .clickCreateLongTermInsurance()
                .clickAccountSelect()
                .clickRegionWorldSelect()
                .clickVariantFamilySelect()
                .clickLicenceAgreement()
                .clickInsuranceAgreement()
                .clickContinueButton()
                .typeSmsCode("12341234")
                .clickSend()
                .clickListInsurace()
                .checkInsuranceIsFound("Dlouhodobé cestovní pojištění Svět (family)");
    }
}