package cz.moneta.test.regression.commercial.cb.archive;

import cz.moneta.test.dsl.Harness;
import cz.moneta.test.dsl.ufo.cb.landing.IKL402_S001_ClientPage;
import cz.moneta.test.dsl.ufo.cb.landing.SME451_S001_UfoCbLandingPage;
import cz.moneta.test.dsl.util.task.ufo.cb.CommercialTasks;
import cz.moneta.test.harness.annotations.Environment;
import cz.moneta.test.harness.annotations.JiraTestCase;
import cz.moneta.test.harness.annotations.TestCase;
import cz.moneta.test.harness.annotations.TestScenario;
import org.junit.jupiter.api.BeforeAll;
import org.junit.jupiter.api.Disabled;

import static cz.moneta.test.dsl.util.task.ufo.cb.CommercialTasks.JIRA_COMMENT_STORE_KEY;

@Disabled
@TestScenario(name = "Test loading pages")
public class CheckLoadingPages {
    private CommercialTasks tasks;

    private SME451_S001_UfoCbLandingPage accessLandingPage(Harness harness) {
        return harness.withUfo()
                .openLoginPage()
                .then(tasks.loginAsCbBanker());
    }

    private IKL402_S001_ClientPage accessClientPage(Harness harness) {
        String ico = harness.getConfig("commercial.cb.ico");
        harness.store(JIRA_COMMENT_STORE_KEY, String.format("ICO: %s <br>", ico));
        return harness.withUfo()
                .openLoginPage()
                .then(tasks.loginAsCbBanker())
                .then(tasks.searchClient(ico));
    }

    @BeforeAll
    public void setUp(Harness harness) {
        tasks = harness.tasks().ufo().cb();
    }

    @TestCase(name = "Check loading page EVD420_S001 from SME451_S001", environments = {Environment.TST1, Environment.PPE})
    @JiraTestCase(id = "SC-T365")
    public void checkBillGuarantorPage(Harness harness) {
        accessLandingPage(harness)
                .clickBillGuarantorLink()
                .clickSearchButton()
                .checkResultTablePresent();
    }

    @TestCase(name = "Check loading page ZST425_S001 from SME451_S001", environments = {Environment.TST1, Environment.PPE})
    @JiraTestCase(id = "SC-T366")
    public void checkSearchCollateralPage(Harness harness) {
        accessLandingPage(harness)
                .clickCollateralLink();
    }

    @TestCase(name = "Check loading page DSB451_S001 from SME451_S001", environments = {Environment.TST1, Environment.PPE})
    @JiraTestCase(id = "SC-T367")
    public void checkTaskPage(Harness harness) {
        accessLandingPage(harness)
                .clickTasksLink();
    }

    @TestCase(name = "Check loading page PRC402_S001 from SME451_S001", environments = {Environment.TST1, Environment.PPE})
    @JiraTestCase(id = "SC-T368")
    public void checkPricingApprovalPage(Harness harness) {
        accessLandingPage(harness)
                .clickPricingApprovalLink();
    }

    @TestCase(name = "Check loading page SME401_S001 from SME451_S001", environments = {Environment.TST1, Environment.PPE})
    @JiraTestCase(id = "SC-T481")
    public void checkSearchPage(Harness harness) {
        accessLandingPage(harness)
                .clickSearchLink();
    }

    @TestCase(name = "Check loading page DMS402_S001 from SME451_S001", environments = {Environment.TST1, Environment.PPE})
    @JiraTestCase(id = "SC-T482")
    public void checkSearchDocumentPage(Harness harness) {
        accessLandingPage(harness)
                .clickDocumentsLink();
    }

    @TestCase(name = "Check loading page NAP401_S001 from SME451_S001", environments = {Environment.TST1, Environment.PPE})
    @JiraTestCase(id = "SC-T483")
    public void checkUserHelpContactPage(Harness harness) {
        accessLandingPage(harness)
                .clickUserHelpLink();
    }

    @TestCase(name = "Check loading page SPV412_S001 from SME451_S001", environments = {Environment.TST1, Environment.PPE})
    @JiraTestCase(id = "SC-T484")
    public void checkSupervisionPage(Harness harness) {
        accessLandingPage(harness)
                .clickSupervisionLink();
    }

    @TestCase(name = "Check loading page DMS421_S001 from SME451_S001", environments = {Environment.TST1, Environment.PPE})
    @JiraTestCase(id = "SC-T485")
    public void checkDocumentScanPage(Harness harness) {
        accessLandingPage(harness)
                .clickDocumentScanLink();
    }

    @TestCase(name = "Check loading page CPL401_S001 from SME451_S001", environments = {Environment.TST1, Environment.PPE})
    @JiraTestCase(id = "SC-T486")
    public void checkCashPoolingPage(Harness harness) {
        accessLandingPage(harness)
                .clickCashPoolingLink();
    }

    @TestCase(name = "Check loading page SME410_S001 from SME451_S001", environments = {Environment.TST1, Environment.PPE})
    @JiraTestCase(id = "SC-T487")
    public void checkTemplatesPage(Harness harness) {
        accessLandingPage(harness)
                .clickTemplatesLink();
    }

    @TestCase(name = "Check loading page KAC402_S001 from SME451_S001", environments = {Environment.TST1, Environment.PPE})
    @JiraTestCase(id = "SC-T488")
    public void checkEventCalendarPage(Harness harness) {
        accessLandingPage(harness)
                .clickEventCalendarLink();
    }

    @TestCase(name = "Check opening signpost report from SME451_S001", environments = {Environment.TST1, Environment.PPE})
    @JiraTestCase(id = "SC-T414")
    public void checkOpeningSignpostReport(Harness harness) {
        accessLandingPage(harness)
                .clickSignPostLink()
                .switchToSignPostReportsWindowAndCheckUrl("https://financesupport2/retailsales/mainPage.php");
    }

    @TestCase(name = "Check loading CLIENT CARD PAGE from CLIENT PAGE", environments = {Environment.TST1, Environment.PPE})
    @JiraTestCase(id = "SC-T579")
    public void checkClientCardPage(Harness harness) {
        accessClientPage(harness)
                .clickClientCard();
    }

    @TestCase(name = "Check loading RELATIONS PAGE from CLIENT PAGE", environments = {Environment.TST1, Environment.PPE})
    @JiraTestCase(id = "SC-T580")
    public void checkRelationsPage(Harness harness) {
        accessClientPage(harness)
                .clickRelationsButton();
    }

    @TestCase(name = "Check loading FINANCIAL SHEETS PAGE from CLIENT PAGE", environments = {Environment.TST1, Environment.PPE})
    @JiraTestCase(id = "SC-T581")
    public void checkFinancialSheetsPage(Harness harness) {
        accessClientPage(harness)
                .clickFinancialSheets();
    }

    @TestCase(name = "Check loading SUMMARY OF TASKS from CLIENT PAGE", environments = {Environment.TST1, Environment.PPE})
    @JiraTestCase(id = "SC-T582")
    public void checkSummaryOfTasksPage(Harness harness) {
        accessClientPage(harness)
                .clickTasks();
    }

    @TestCase(name = "Check loading PRICING PAGE from CLIENT PAGE", environments = {Environment.TST1, Environment.PPE})
    @JiraTestCase(id = "SC-T583")
    public void checkPricingPage(Harness harness) {
        accessClientPage(harness)
                .clickPricing();
    }

    @TestCase(name = "Check loading COLLATERAL PAGE from CLIENT PAGE", environments = {Environment.TST1, Environment.PPE})
    @JiraTestCase(id = "SC-T584")
    public void checkCollateralPage(Harness harness) {
        accessClientPage(harness)
                .clickCollateral();
    }

    @TestCase(name = "Check loading DOCUMENTS PAGE from CLIENT PAGE", environments = {Environment.TST1, Environment.PPE})
    @JiraTestCase(id = "SC-T585")
    public void checkDocumentsPage(Harness harness) {
        accessClientPage(harness)
                .clickDocuments();
    }

    @TestCase(name = "Check loading CLIENT RECORDS PAGE from CLIENT PAGE", environments = {Environment.TST1, Environment.PPE})
    @JiraTestCase(id = "SC-T586")
    public void checkClientRecordsPage(Harness harness) {
        String registrationNumber = harness.getConfig("commercial.cb.reg-number");
        String selectValue = registrationNumber + "|||";
        accessClientPage(harness)
                .clickClientRecord()
                .selectRegistrationNumberAndClick(selectValue)
                .checkFirstRecordRegistrationNumber(registrationNumber);
    }

    @TestCase(name = "Check loading CHECKLISTS PAGE from CLIENT PAGE", environments = {Environment.TST1, Environment.PPE})
    @JiraTestCase(id = "SC-T587")
    public void checkChecklistsPage(Harness harness) {
        accessClientPage(harness)
                .clickChecklists();
    }

    @TestCase(name = "Check loading RATING LGD PAGE from CLIENT PAGE", environments = {Environment.TST1, Environment.PPE})
    @JiraTestCase(id = "SC-T588")
    public void checkRatingLgdPage(Harness harness) {
        accessClientPage(harness)
                .clickRatingLgd();
    }

}
