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 short-term travel insurance")
public class ShortTermTravelInsuranceTest {

    private Credentials credentials;

    @BeforeAll
    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 short-term travel insurance variant europe-single", environments = {TST1, PPE})
    @JiraTestCase(id = "IB-T8224")
    void userWithCurrentAccount_shouldCreateShortTermInsuranceEuropeSingle(Harness harness) {

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

    @Disabled
    @Order(2)
    @TestCase(name = "Go to insurance page and create short-term travel insurance variant europe-family", environments = {TST1, PPE})
    @JiraTestCase(id = "IB-T8225")
    void userWithCurrentAccount_shouldCreateShortTermInsuranceEuropeFamily(Harness harness) {

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

    @Disabled
    @Order(3)
    @TestCase(name = "Go to insurance page and create short-term travel insurance variant world-single", environments = {TST1, PPE})
    @JiraTestCase(id = "IB-T8226")
    void userWithCurrentAccount_shouldCreateShortTermInsuranceWorldSingle(Harness harness) {

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

    @Disabled
    @Order(4)
    @TestCase(name = "Go to insurance page and create short-term travel insurance variant world-family", environments = {TST1, PPE})
    @JiraTestCase(id = "IB-T8227")
    void userWithCurrentAccount_shouldCreateShortTermInsuranceWorldFamily(Harness harness) {

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