"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
const test_1 = require("@playwright/test");
const _8_6_1 = require("../../fixtures/8.6");
const _setup_1 = require("../../test-setup.js");
const users_1 = require("../../utils/users");
const UtilitiesPage_1 = require("../../pages/8.6/UtilitiesPage");
_8_6_1.test.describe.configure({ mode: 'parallel' });
_8_6_1.test.describe('Cluster Setup Tests', () => {
    _8_6_1.test.skip(process.env.IS_AG === 'true', 'Skipping Cluster Setup Tests due to console breaking changes');
    _8_6_1.test.afterEach(async ({ page }, testInfo) => {
        await (0, _setup_1.captureScreenshot)(page, testInfo);
        await (0, _setup_1.captureFailureVideo)(page, testInfo);
    });
    (0, _8_6_1.test)('Enable Alpha Features', async ({ page, loginPage, consoleOrganizationsPage, homePage, }, testInfo) => {
        if (process.env.IS_PROD === 'true') {
            _8_6_1.test.skip(true, 'Skipping test because not required on PROD test org');
        }
        await (0, UtilitiesPage_1.loginWithRetry)(page, loginPage, users_1.testUsers.mainUser, (testInfo.workerIndex + 1) * 1000);
        await homePage.clickOrganization();
        await (0, UtilitiesPage_1.assertLocatorVisibleWithRetry)(page, consoleOrganizationsPage.settingsTab, 'settings tab', 60000, 2);
        await consoleOrganizationsPage.enableAlphaFeature('AI-powered features');
    });
    (0, _8_6_1.test)('Create Default Cluster', async ({ page, loginPage, homePage, clusterPage, clusterDetailsPage, }, testInfo) => {
        _8_6_1.test.slow();
        const clusterName = 'Test Cluster';
        await (0, UtilitiesPage_1.loginWithRetry)(page, loginPage, users_1.testUsers.mainUser, (testInfo.workerIndex + 1) * 1000);
        await homePage.clickClusters();
        await clusterPage.createCluster(clusterName);
        await clusterPage.assertClusterHealthyStatusWithRetry(clusterName);
        await clusterPage.clickClusterLink(clusterName);
        await clusterDetailsPage.assertComponentsHealth();
    });
    for (const [index, user] of (0, users_1.getTestUsers)().entries()) {
        (0, _8_6_1.test)(`Create Project Folder for User ${index + 1}`, async ({ page, loginPage, homePage, appsPage, modelerHomePage, }, testInfo) => {
            await _8_6_1.test.step('Log in', async () => {
                await (0, UtilitiesPage_1.loginWithRetry)(page, loginPage, user, (testInfo.workerIndex + 1) * 1000);
            });
            await _8_6_1.test.step('Navigate to Web Modeler', async () => {
                await (0, test_1.expect)(homePage.camundaComponentsButton).toBeVisible({
                    timeout: 120000,
                });
                await appsPage.clickCamundaApps();
                await appsPage.clickModeler();
                await (0, test_1.expect)(modelerHomePage.modelerPageBanner).toBeVisible({
                    timeout: 180000,
                });
            });
            await _8_6_1.test.step('Create Cross Component Project Folder', async () => {
                await homePage.clickSkipCustomization();
                await modelerHomePage.createCrossComponentProjectFolder();
                await modelerHomePage.clickHomeBreadcrumb();
                await (0, test_1.expect)(modelerHomePage.crossComponentProjectFolder).toBeVisible({
                    timeout: 60000,
                });
            });
        });
    }
    (0, _8_6_1.test)('Create AWS Cluster', async ({ page, loginPage, homePage, clusterPage, clusterDetailsPage, }, testInfo) => {
        _8_6_1.test.slow();
        const clusterName = 'AWS Cluster';
        await (0, UtilitiesPage_1.loginWithRetry)(page, loginPage, users_1.testUsers.mainUser, (testInfo.workerIndex + 1) * 1000);
        await homePage.clickClusters();
        await clusterPage.createCluster(clusterName, 'AWS');
        await clusterPage.assertClusterHealthyStatusWithRetry(clusterName);
        await clusterPage.clickClusterLink(clusterName);
        await clusterDetailsPage.assertComponentsHealth();
    });
});
