"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
const test_1 = require("@playwright/test");
const _8_10_1 = require("../../fixtures/8.10");
const _setup_1 = require("../../test-setup.js");
const UtilitiesPage_1 = require("../../pages/8.10/UtilitiesPage");
const users_1 = require("../../utils/users");
const testUser = (0, users_1.getTestUser)('twentySecondUser');
const clusterName = 'Test Cluster';
_8_10_1.test.describe.configure({ mode: 'parallel' });
_8_10_1.test.describe('Optimize Collections Lifecycle UI Tests @optimize-collections-ui @8.10', () => {
    _8_10_1.test.beforeEach(async ({ page, loginPage }, testInfo) => {
        await (0, UtilitiesPage_1.loginWithRetry)(page, loginPage, testUser, (testInfo.workerIndex + 1) * 1000);
    });
    _8_10_1.test.afterEach(async ({ page }, testInfo) => {
        await (0, _setup_1.captureScreenshot)(page, testInfo);
        await (0, _setup_1.captureFailureVideo)(page, testInfo);
    });
    (0, _8_10_1.test)('Create, rename and delete a collection', async ({ appsPage, optimizeHomePage, optimizeCollectionsPage, }) => {
        _8_10_1.test.slow();
        const collectionName = 'E2E Collection ' + (await (0, _setup_1.generateRandomStringAsync)(5));
        const renamedCollectionName = 'E2E Collection Renamed ' + (await (0, _setup_1.generateRandomStringAsync)(5));
        await _8_10_1.test.step('Navigate to Optimize from the Camunda apps menu', async () => {
            await appsPage.clickCamundaApps();
            await appsPage.clickOptimize(clusterName);
            await test_1.expect
                .poll(async () => optimizeHomePage.optimizeBanner.isVisible({ timeout: 5000 }), { timeout: 120000 })
                .toBe(true);
        });
        await _8_10_1.test.step('Open the Collections page', async () => {
            await optimizeHomePage.clickCollectionsLink();
        });
        await _8_10_1.test.step('Create a new collection and verify it is created', async () => {
            await optimizeCollectionsPage.createCollection(collectionName);
            await optimizeCollectionsPage.assertCollectionVisible(collectionName);
        });
        await _8_10_1.test.step('Rename the collection and verify the new name', async () => {
            await optimizeCollectionsPage.renameCollection(renamedCollectionName);
            await optimizeCollectionsPage.assertCollectionVisible(renamedCollectionName);
        });
        await _8_10_1.test.step('Delete the collection and verify it is removed', async () => {
            await optimizeCollectionsPage.deleteCollection();
            await optimizeCollectionsPage.assertCollectionNotVisible(renamedCollectionName);
        });
    });
});
