"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
const test_1 = require("@playwright/test");
const SM_8_7_1 = require("../../fixtures/SM-8.7");
const _setup_1 = require("../../test-setup.js");
const sleep_1 = require("../../utils/sleep");
const UtlitiesPage_1 = require("../../pages/SM-8.7/UtlitiesPage");
const KeycloakUtils_1 = require("../../pages/SM-8.7/KeycloakUtils");
const loggingUtils_1 = require("../../utils/loggingUtils");
if (process.env.IS_MT === 'true') {
    SM_8_7_1.test.describe.configure({ mode: 'parallel' });
    SM_8_7_1.test.describe('MT Enabled User Flows Test', () => {
        SM_8_7_1.test.beforeEach(async ({ navigationPage, identityPage, keycloakLoginPage, keycloakAdminPage, context, identityTenantPage, }, testInfo) => {
            (0, loggingUtils_1.setupTestLogging)(testInfo);
            await context.clearCookies();
            const user1 = 'lisa' + (await (0, _setup_1.generateRandomStringAsync)(3)).toLowerCase();
            const user2 = 'bart' + (await (0, _setup_1.generateRandomStringAsync)(3)).toLowerCase();
            navigationPage.user1 = user1;
            navigationPage.user2 = user2;
            navigationPage.user1password = 'test-password';
            navigationPage.user2password = 'test-password';
            await (0, KeycloakUtils_1.createUser)(navigationPage, identityPage, keycloakLoginPage, keycloakAdminPage, navigationPage.user1, navigationPage.user1password, identityTenantPage);
            await context.clearCookies();
            await (0, KeycloakUtils_1.createUser)(navigationPage, identityPage, keycloakLoginPage, keycloakAdminPage, navigationPage.user2, navigationPage.user2password, identityTenantPage);
            await context.clearCookies();
            await (0, KeycloakUtils_1.setupKeycloakUser)(navigationPage, identityPage, keycloakLoginPage, keycloakAdminPage, identityTenantPage);
        });
        SM_8_7_1.test.afterEach(async ({ page }, testInfo) => {
            await (0, _setup_1.captureScreenshot)(page, testInfo);
            await (0, _setup_1.captureFailureVideo)(page, testInfo);
            (0, loggingUtils_1.cleanupTestLogging)();
        });
        (0, SM_8_7_1.test)('Main User Can Create & Access Tenant & User Without Access Cannot - User Task Flow', async ({ page, modelerHomePage, modelerCreatePage, taskPanelPage, operateProcessInstancePage, operateProcessesPage, taskDetailsPage, operateHomePage, navigationPage, identityTenantPage, optimizeHomePage, optimizeDashboardPage, loginPage, context, }) => {
            SM_8_7_1.test.slow();
            const randomString = await (0, _setup_1.generateRandomStringAsync)(3);
            const processName = 'Main_User_Task_Flow_' + randomString;
            const tenantName = 'Tenant_Main_' + randomString;
            await SM_8_7_1.test.step('Create Tenant And Assign User', async () => {
                await context.clearCookies();
                await navigationPage.goToIdentity();
                await identityTenantPage.createTenant(tenantName);
                await identityTenantPage.assignUserToTenant(tenantName, navigationPage.activeUser, navigationPage.activeUser + '@camunda.com');
                await identityTenantPage.assignClientToTenant('Zeebe');
            });
            await SM_8_7_1.test.step('Open Cross Component Test Project', async () => {
                await context.clearCookies();
                await navigationPage.goToModeler();
                await modelerHomePage.clickCreateNewProjectButton();
                await modelerHomePage.createCrossComponentProjectFolder();
                await modelerHomePage.clickDiagramTypeDropdown();
                await modelerHomePage.clickBpmnTemplateOption();
            });
            await SM_8_7_1.test.step('Create A Diagram with a User Task and Start Process Instance', async () => {
                await modelerCreatePage.modelCamundaUserTaskDiagram(processName, processName);
                await modelerCreatePage.clickStartInstanceMainButton();
                await modelerCreatePage.clickTenantIdInput();
                await modelerCreatePage.fillTenantIdInput(tenantName);
                await modelerCreatePage.clickStartInstanceSubButton();
            });
            await SM_8_7_1.test.step('View Process Instance in Operate, complete User Task in Tasklist & assert process complete in Operate', async () => {
                await navigationPage.goToOperate();
                await operateHomePage.clickProcessesTab();
                await operateProcessesPage.clickProcessInstanceLink(processName);
                let result = await operateProcessInstancePage.assertEitherIncidentOrActiveIconVisible();
                (0, test_1.expect)(result).toBe('active');
                await navigationPage.goToTasklist();
                await taskPanelPage.openTask(processName);
                await taskDetailsPage.clickAssignToMeButton();
                await taskDetailsPage.clickCompleteTaskButton();
                await (0, test_1.expect)(page.getByText('Task completed')).toBeVisible({
                    timeout: 200000,
                });
                await navigationPage.goToOperate();
                await operateHomePage.clickProcessesTab();
                await operateProcessesPage.clickProcessInstanceLink(processName, 'completed');
                result =
                    await operateProcessInstancePage.assertEitherIncidentOrCompletedIconVisible();
                (0, test_1.expect)(result).toBe('completed');
                await operateProcessInstancePage.tenantNameAssertion(tenantName);
            });
            await SM_8_7_1.test.step('Assert Process has been successfully imported in Optimize', async () => {
                await navigationPage.goToOptimize();
                await optimizeHomePage.clickDashboardLink();
                await optimizeDashboardPage.processAssertion(processName, {
                    timeout: 300000,
                });
            });
            await SM_8_7_1.test.step('Logout and Login with "bart" User', async () => {
                await optimizeHomePage.clickOpenUserSettingsButton();
                await optimizeHomePage.clickLogoutButton();
                await loginPage.login(navigationPage.user1, navigationPage.user1password);
            });
            await SM_8_7_1.test.step('Open Cross Component Test Project', async () => {
                await navigationPage.goToModeler();
                await modelerHomePage.clickCreateNewProjectButton();
                await modelerHomePage.createCrossComponentProjectFolder();
                await modelerHomePage.clickDiagramTypeDropdown();
                await modelerHomePage.clickBpmnTemplateOption();
            });
            await SM_8_7_1.test.step('Create A Diagram with a User Task and Assert Cannot Start Process Instance With Tenant', async () => {
                await modelerCreatePage.modelCamundaUserTaskDiagram(processName, processName);
                await modelerCreatePage.clickStartInstanceMainButton();
                await modelerCreatePage.clickTenantIdInput();
                await modelerCreatePage.fillTenantIdInput(tenantName);
                await modelerCreatePage.clickStartInstanceSubButton();
                const result = await Promise.race([
                    page
                        .getByText('Instance could not be started')
                        .waitFor()
                        .then(() => true),
                    page
                        .getByText('Instance started!')
                        .waitFor()
                        .then(() => false),
                ]);
                (0, test_1.expect)(result).toBe(true);
            });
            await SM_8_7_1.test.step('Assert "bart" user cannot view process in Tasklist, Operate or Optimize', async () => {
                await navigationPage.goToOperate();
                await operateHomePage.clickProcessesTab();
                await (0, test_1.expect)(page.getByText(processName)).not.toBeVisible({
                    timeout: 60000,
                });
                await navigationPage.goToTasklist();
                await (0, test_1.expect)(page.getByText(processName)).not.toBeVisible({
                    timeout: 60000,
                });
                await navigationPage.goToOptimize();
                await optimizeHomePage.clickDashboardLink();
                await (0, test_1.expect)(page.getByText(processName)).not.toBeVisible({
                    timeout: 60000,
                });
            });
        });
        // Skipped due to 320: https://github.com/camunda/marketplace-api/issues/320
        SM_8_7_1.test.skip('Main User Can Create & Access Tenant - Connectors Flow', async ({ modelerHomePage, modelerCreatePage, operateProcessInstancePage, operateProcessesPage, operateHomePage, navigationPage, identityTenantPage, connectorSettingsPage, connectorMarketplacePage, optimizeHomePage, optimizeDashboardPage, context, }) => {
            SM_8_7_1.test.slow();
            const randomString = await (0, _setup_1.generateRandomStringAsync)(3);
            const processName = 'Main_User_Connectors_Flow_' + randomString;
            const tenantName = 'Tenant_Main_Connectors';
            await SM_8_7_1.test.step('Create Tenant And Assign User', async () => {
                await context.clearCookies();
                await navigationPage.goToIdentity();
                await identityTenantPage.createTenant(tenantName);
                await identityTenantPage.assignUserToTenant(tenantName, navigationPage.activeUser, navigationPage.activeUser + '@camunda.com');
                await identityTenantPage.assignClientToTenant('Zeebe');
                await identityTenantPage.assignClientToTenant('Operate');
            });
            await SM_8_7_1.test.step('Open Cross Component Test Project', async () => {
                await navigationPage.goToModeler();
                await modelerHomePage.clickCreateNewProjectButton();
                await modelerHomePage.createCrossComponentProjectFolder();
                await modelerHomePage.clickDiagramTypeDropdown();
                await modelerHomePage.clickBpmnTemplateOption();
            });
            await SM_8_7_1.test.step('Create A Diagram with a REST Connector and Start Process Instance', async () => {
                await (0, UtlitiesPage_1.modelRestConnector)(modelerCreatePage, connectorSettingsPage, connectorMarketplacePage, processName, 'https://camunda.proxy.beeceptor.com/pre-prod/no-auth-test', 'noAuth', 'body');
                await modelerCreatePage.clickStartInstanceMainButton();
                await modelerCreatePage.clickTenantIdInput();
                await modelerCreatePage.fillTenantIdInput(tenantName);
                await modelerCreatePage.clickStartInstanceSubButton();
                await modelerCreatePage.instanceStartedAssertion();
            });
            await SM_8_7_1.test.step('View Process Instance in Operate & assert process is complete', async () => {
                await navigationPage.goToOperate();
                await operateHomePage.clickProcessesTab();
                await operateProcessesPage.clickProcessInstanceLink(processName, 'completed');
                const result = await operateProcessInstancePage.assertEitherIncidentOrCompletedIconVisible();
                (0, test_1.expect)(result).toBe('completed');
                await operateProcessInstancePage.assertTextVisible('"Awesome!"');
                await operateProcessInstancePage.tenantNameAssertion(tenantName);
            });
            await SM_8_7_1.test.step('Assert Process has been successfully imported in Optimize', async () => {
                await navigationPage.goToOptimize();
                await optimizeHomePage.clickDashboardLink();
                await optimizeDashboardPage.processAssertion(processName, {
                    timeout: 300000,
                });
            });
        });
        (0, SM_8_7_1.test)('Second User Can Access Tenant Created By Main User - User Task Flow', async ({ page, modelerHomePage, modelerCreatePage, taskPanelPage, operateProcessInstancePage, operateProcessesPage, taskDetailsPage, operateHomePage, navigationPage, identityTenantPage, loginPage, optimizeDashboardPage, optimizeHomePage, }) => {
            SM_8_7_1.test.slow();
            const randomString = await (0, _setup_1.generateRandomStringAsync)(3);
            const processName = 'Second_User_User_Task_Flow_' + randomString;
            const tenantName = 'Tenant_Second_User_' + randomString;
            await SM_8_7_1.test.step('Create Tenant And Assign User', async () => {
                await navigationPage.goToIdentity();
                await identityTenantPage.createTenant(tenantName);
                await identityTenantPage.assignUserToTenant(tenantName, navigationPage.user2, navigationPage.user2 + '@camunda.com');
                await identityTenantPage.assignClientToTenant('Zeebe');
            });
            await SM_8_7_1.test.step('Logout and Login with "lisa" User', async () => {
                await identityTenantPage.clickOpenSidebarButton();
                await identityTenantPage.clickLogoutButton();
                await loginPage.login(navigationPage.user2, navigationPage.user2password);
            });
            await SM_8_7_1.test.step('Open Cross Component Test Project', async () => {
                await navigationPage.goToModeler();
                await modelerHomePage.clickCreateNewProjectButton();
                await modelerHomePage.createCrossComponentProjectFolder();
                await modelerHomePage.clickDiagramTypeDropdown();
                await modelerHomePage.clickBpmnTemplateOption();
            });
            await SM_8_7_1.test.step('Create A Diagram with a User Task and Start Process Instance', async () => {
                await modelerCreatePage.modelCamundaUserTaskDiagram(processName, processName);
                await modelerCreatePage.clickStartInstanceMainButton();
                await modelerCreatePage.clickTenantIdInput();
                await modelerCreatePage.fillTenantIdInput(tenantName);
                await modelerCreatePage.clickStartInstanceSubButton();
            });
            await SM_8_7_1.test.step('View Process Instance in Operate, complete User Task in Tasklist & assert process complete in Operate', async () => {
                await navigationPage.goToOperate();
                await operateHomePage.clickProcessesTab();
                await operateProcessesPage.clickProcessInstanceLink(processName);
                await operateProcessInstancePage.activeIconAssertion();
                await navigationPage.goToTasklist();
                await taskPanelPage.openTask(processName);
                await taskDetailsPage.clickAssignToMeButton();
                await taskDetailsPage.clickCompleteTaskButton();
                await (0, test_1.expect)(page.getByText('Task completed')).toBeVisible({
                    timeout: 200000,
                });
                await navigationPage.goToOperate();
                await operateHomePage.clickProcessesTab();
                await operateProcessesPage.clickProcessInstanceLink(processName, 'completed');
                const result = await operateProcessInstancePage.assertEitherIncidentOrCompletedIconVisible();
                (0, test_1.expect)(result).toBe('completed');
                await operateProcessInstancePage.tenantNameAssertion(tenantName);
            });
            await SM_8_7_1.test.step('Assert Process has been successfully imported in Optimize', async () => {
                await navigationPage.goToOptimize();
                await optimizeHomePage.clickDashboardLink();
                await optimizeDashboardPage.processAssertion(processName, {
                    timeout: 300000,
                });
            });
        });
        // Skipped due to 320: https://github.com/camunda/marketplace-api/issues/320
        SM_8_7_1.test.skip('Second User Can Access Tenant Created By Main User - Connectors Flow', async ({ modelerHomePage, modelerCreatePage, operateProcessInstancePage, operateProcessesPage, operateHomePage, navigationPage, identityTenantPage, connectorSettingsPage, connectorMarketplacePage, loginPage, optimizeHomePage, optimizeDashboardPage, }) => {
            SM_8_7_1.test.slow();
            const randomString = await (0, _setup_1.generateRandomStringAsync)(3);
            const processName = 'Second_User_Connectors_Flow_' + randomString;
            const tenantName = 'Tenant_Second_Connectors';
            await SM_8_7_1.test.step('Create Tenant And Assign User', async () => {
                await navigationPage.goToIdentity();
                await identityTenantPage.createTenant(tenantName);
                await identityTenantPage.assignUserToTenant(tenantName, navigationPage.user2, navigationPage.user2 + '@camunda.com');
                await identityTenantPage.assignClientToTenant('Zeebe');
                await identityTenantPage.assignClientToTenant('Operate');
            });
            await SM_8_7_1.test.step('Logout and Login with "bart" User', async () => {
                await identityTenantPage.clickOpenSidebarButton();
                await identityTenantPage.clickLogoutButton();
                await loginPage.login(navigationPage.user2, navigationPage.user2password);
            });
            await SM_8_7_1.test.step('Open Cross Component Test Project', async () => {
                await navigationPage.goToModeler();
                await modelerHomePage.clickCreateNewProjectButton();
                await modelerHomePage.createCrossComponentProjectFolder();
                await modelerHomePage.clickDiagramTypeDropdown();
                await modelerHomePage.clickBpmnTemplateOption();
            });
            await SM_8_7_1.test.step('Create A Diagram with a REST Connector and Start Process Instance', async () => {
                await (0, UtlitiesPage_1.modelRestConnector)(modelerCreatePage, connectorSettingsPage, connectorMarketplacePage, processName, 'https://camunda.proxy.beeceptor.com/pre-prod/no-auth-test', 'noAuth', 'body');
                await modelerCreatePage.clickStartInstanceMainButton();
                await modelerCreatePage.clickTenantIdInput();
                await modelerCreatePage.fillTenantIdInput(tenantName);
                await modelerCreatePage.clickStartInstanceSubButton();
            });
            await SM_8_7_1.test.step('View Process Instance in Operate & assert process is complete', async () => {
                await navigationPage.goToOperate();
                await operateHomePage.clickProcessesTab();
                await operateProcessesPage.clickProcessInstanceLink(processName, 'completed');
                await operateProcessInstancePage.completedIconAssertion();
                await operateProcessInstancePage.assertTextVisible('"Awesome!"');
                await operateProcessInstancePage.tenantNameAssertion(tenantName);
            });
            await SM_8_7_1.test.step('Assert Process has been successfully imported in Optimize', async () => {
                await navigationPage.goToOptimize();
                await optimizeHomePage.clickDashboardLink();
                await optimizeDashboardPage.processAssertion(processName, {
                    timeout: 300000,
                });
            });
        });
        (0, SM_8_7_1.test)('Default Tenant Is Available And Used When Tenant Not Set In Deployment', async ({ page, modelerHomePage, modelerCreatePage, taskPanelPage, operateProcessInstancePage, operateProcessesPage, taskDetailsPage, operateHomePage, navigationPage, identityTenantPage, optimizeHomePage, optimizeDashboardPage, context, }) => {
            SM_8_7_1.test.slow();
            const randomString = await (0, _setup_1.generateRandomStringAsync)(3);
            const processName = 'Default_Tenant_Flow_' + randomString;
            const tenantName = 'Default';
            await SM_8_7_1.test.step('Assign User To Default Tenant', async () => {
                await navigationPage.goToIdentity();
                await identityTenantPage.assignUserToTenant(tenantName, navigationPage.activeUser, navigationPage.activeUser + '@camunda.com');
                await identityTenantPage.assignClientToTenant('Zeebe');
            });
            await SM_8_7_1.test.step('Open Cross Component Test Project', async () => {
                await context.clearCookies();
                await navigationPage.goToModeler();
                await modelerHomePage.clickCreateNewProjectButton();
                await modelerHomePage.createCrossComponentProjectFolder();
                await modelerHomePage.clickDiagramTypeDropdown();
                await modelerHomePage.clickBpmnTemplateOption();
            });
            await SM_8_7_1.test.step('Create A Diagram with a User Task and Start Process Instance', async () => {
                await modelerCreatePage.modelCamundaUserTaskDiagram(processName, processName);
                await modelerCreatePage.clickStartInstanceMainButton();
                await modelerCreatePage.clickStartInstanceSubButton();
            });
            await SM_8_7_1.test.step('View Process Instance in Operate, complete User Task in Tasklist & assert process complete in Operate', async () => {
                await navigationPage.goToOperate();
                await operateHomePage.clickProcessesTab();
                await operateProcessesPage.clickProcessInstanceLink(processName);
                await operateProcessInstancePage.activeIconAssertion();
                await navigationPage.goToTasklist();
                await taskPanelPage.openTask(processName);
                await taskDetailsPage.clickAssignToMeButton();
                await taskDetailsPage.clickCompleteTaskButton();
                await (0, test_1.expect)(page.getByText('Task completed')).toBeVisible({
                    timeout: 200000,
                });
                await navigationPage.goToOperate();
                await operateHomePage.clickProcessesTab();
                await operateProcessesPage.clickProcessCompletedCheckbox();
                await operateProcessesPage.clickProcessInstanceLink(processName, 'completed');
                await operateProcessInstancePage.completedIconAssertion();
                await operateProcessInstancePage.tenantNameAssertion(tenantName);
            });
            await SM_8_7_1.test.step('Assert Process has been successfully imported in Optimize', async () => {
                await navigationPage.goToOptimize();
                await optimizeHomePage.clickDashboardLink();
                await optimizeDashboardPage.processAssertion(processName, {
                    timeout: 300000,
                });
            });
        });
        // Skipped due to 320: https://github.com/camunda/marketplace-api/issues/320
        SM_8_7_1.test.skip('User Can Be Assigned To Multiple Tenants', async ({ page, identityPage, modelerHomePage, modelerCreatePage, operateProcessInstancePage, operateProcessesPage, operateHomePage, navigationPage, identityTenantPage, connectorSettingsPage, connectorMarketplacePage, context, }) => {
            SM_8_7_1.test.slow();
            const randomString = await (0, _setup_1.generateRandomStringAsync)(3);
            const processName1 = 'Multiple_Tenant_Flow_1' + randomString;
            const processName2 = 'Multiple_Tenant_Flow_2' + randomString;
            const tenantName1 = 'Tenant_1_Connectors';
            const tenantName2 = 'Tenant_2_Connectors';
            await SM_8_7_1.test.step('Create Two Tenants And Assign to Demo User', async () => {
                await navigationPage.goToIdentity();
                await identityTenantPage.createTenant(tenantName1);
                await identityTenantPage.assignUserToTenant(tenantName1, navigationPage.activeUser, navigationPage.activeUser + '@camunda.com');
                await identityTenantPage.assignClientToTenant('Zeebe');
                await identityTenantPage.assignClientToTenant('Operate');
                await identityPage.clickTenantTab();
                await identityTenantPage.createTenant(tenantName2);
                await identityTenantPage.assignUserToTenant(tenantName2, navigationPage.activeUser, navigationPage.activeUser + '@camunda.com');
                await identityTenantPage.assignClientToTenant('Zeebe');
                await identityTenantPage.assignClientToTenant('Operate');
            });
            await SM_8_7_1.test.step('Open Cross Component Test Project', async () => {
                await context.clearCookies();
                await navigationPage.goToModeler();
                await modelerHomePage.clickCreateNewProjectButton();
                await modelerHomePage.createCrossComponentProjectFolder();
                await modelerHomePage.clickDiagramTypeDropdown();
                await modelerHomePage.clickBpmnTemplateOption();
            });
            await SM_8_7_1.test.step('Create A Diagram with a REST Connector and Start Process Instance With Tenant 1', async () => {
                await (0, UtlitiesPage_1.modelRestConnector)(modelerCreatePage, connectorSettingsPage, connectorMarketplacePage, processName1, 'https://camunda.proxy.beeceptor.com/pre-prod/no-auth-test', 'noAuth', 'body');
                await modelerCreatePage.clickStartInstanceMainButton();
                await modelerCreatePage.clickTenantIdInput();
                await modelerCreatePage.fillTenantIdInput(tenantName1);
                await modelerCreatePage.clickStartInstanceSubButton();
            });
            await SM_8_7_1.test.step('Create A Diagram with a REST Connector and Start Process Instance With Tenant 2', async () => {
                await modelerHomePage.clickProjectBreadcrumb();
                await modelerHomePage.clickDiagramTypeDropdown();
                await modelerHomePage.clickBpmnTemplateOption();
                await (0, UtlitiesPage_1.modelRestConnector)(modelerCreatePage, connectorSettingsPage, connectorMarketplacePage, processName2, 'https://camunda.proxy.beeceptor.com/pre-prod/no-auth-test', 'noAuth', 'body');
                await modelerCreatePage.clickStartInstanceMainButton();
                await modelerCreatePage.clickTenantIdInput();
                await modelerCreatePage.fillTenantIdInput(tenantName2);
                await modelerCreatePage.clickStartInstanceSubButton();
            });
            await SM_8_7_1.test.step('View Process Instances in Operate, and Assert Process Complete in Operate with Correct Tenant', async () => {
                await navigationPage.goToOperate();
                await operateHomePage.clickProcessesTab();
                await operateProcessesPage.clickProcessInstanceLink(processName1, 'completed');
                await operateProcessInstancePage.completedIconAssertion();
                await operateProcessInstancePage.assertTextVisible('"Awesome!"');
                await operateProcessInstancePage.tenantNameAssertion(tenantName1);
                await operateHomePage.clickProcessesTab();
                await operateProcessesPage.clickProcessInstanceLink(processName2, 'completed');
                await operateProcessInstancePage.completedIconAssertion();
                await (0, sleep_1.sleep)(2000); // moving too fast here means the text is not displayed.. clicking the row would fix this but there is no testId on the row so that would be flaky
                await page.reload();
                await (0, test_1.expect)(page.getByText('"Awesome!"')).toBeVisible({
                    timeout: 60000,
                });
                await operateProcessInstancePage.tenantNameAssertion(tenantName2);
            });
        });
        (0, SM_8_7_1.test)('Revoking Tenant Access User Flow', async ({ page, modelerHomePage, modelerCreatePage, taskPanelPage, operateProcessInstancePage, operateProcessesPage, taskDetailsPage, operateHomePage, navigationPage, identityTenantPage, optimizeHomePage, optimizeDashboardPage, context, }) => {
            SM_8_7_1.test.slow();
            const randomString = await (0, _setup_1.generateRandomStringAsync)(3);
            const processName1 = 'Revoke_Tenant_Flow_1' + randomString;
            const processName2 = 'Revoke_Tenant_Flow_2' + randomString;
            const tenantName = 'Revoke_' + randomString;
            await SM_8_7_1.test.step('Create Tenant And Assign User', async () => {
                await context.clearCookies();
                await navigationPage.goToIdentity();
                await identityTenantPage.createTenant(tenantName);
                await identityTenantPage.assignUserToTenant(tenantName, navigationPage.activeUser, navigationPage.activeUser + '@camunda.com');
                await identityTenantPage.assignClientToTenant('Zeebe');
            });
            await SM_8_7_1.test.step('Open Cross Component Test Project', async () => {
                await navigationPage.goToModeler();
                await modelerHomePage.clickCreateNewProjectButton();
                await modelerHomePage.createCrossComponentProjectFolder();
                await modelerHomePage.clickDiagramTypeDropdown();
                await modelerHomePage.clickBpmnTemplateOption();
            });
            await SM_8_7_1.test.step('Create A Diagram with a User Task and Start Process Instance', async () => {
                await modelerCreatePage.modelCamundaUserTaskDiagram(processName1, processName1);
                await modelerCreatePage.clickStartInstanceMainButton();
                await modelerCreatePage.clickTenantIdInput();
                await modelerCreatePage.fillTenantIdInput(tenantName);
                await modelerCreatePage.clickStartInstanceSubButton();
            });
            await SM_8_7_1.test.step('View Process Instance in Operate, complete User Task in Tasklist & assert process complete in Operate', async () => {
                await navigationPage.goToOperate();
                await operateHomePage.clickProcessesTab();
                await operateProcessesPage.clickProcessInstanceLink(processName1);
                await operateProcessInstancePage.activeIconAssertion();
                await navigationPage.goToTasklist();
                await taskPanelPage.openTask(processName1);
                await taskDetailsPage.clickAssignToMeButton();
                await taskDetailsPage.clickCompleteTaskButton();
                await (0, test_1.expect)(page.getByText('Task completed')).toBeVisible({
                    timeout: 200000,
                });
                await navigationPage.goToOperate();
                await operateHomePage.clickProcessesTab();
                await operateProcessesPage.clickProcessInstanceLink(processName1, 'completed');
                await operateProcessInstancePage.completedIconAssertion();
                await operateProcessInstancePage.tenantNameAssertion(tenantName);
            });
            await SM_8_7_1.test.step('Assert Process has been successfully imported in Optimize', async () => {
                await navigationPage.goToOptimize();
                await optimizeHomePage.clickDashboardLink();
                await optimizeDashboardPage.processAssertion(processName1, {
                    timeout: 300000,
                });
            });
            await SM_8_7_1.test.step('Delete Tenant Access For Demo User', async () => {
                await context.clearCookies();
                await navigationPage.goToIdentity();
                await identityTenantPage.removeUserFromTenant(tenantName);
            });
            await SM_8_7_1.test.step('Open Cross Component Test Project', async () => {
                await context.clearCookies();
                await navigationPage.goToModeler();
                await modelerHomePage.clickCreateNewProjectButton();
                await modelerHomePage.createCrossComponentProjectFolder();
                await modelerHomePage.clickDiagramTypeDropdown();
                await modelerHomePage.clickBpmnTemplateOption();
            });
            await SM_8_7_1.test.step('Create A Diagram with a User Task and Assert Cannot Start Process Instance With Tenant', async () => {
                await modelerCreatePage.modelCamundaUserTaskDiagram(processName2);
                await modelerCreatePage.clickStartInstanceMainButton();
                await modelerCreatePage.clickTenantIdInput();
                await modelerCreatePage.fillTenantIdInput(tenantName);
                await modelerCreatePage.clickStartInstanceSubButton();
                await (0, test_1.expect)(page.getByText('Instance could not be started')).toBeVisible({ timeout: 60000 });
            });
            await SM_8_7_1.test.step('Assert "demo" user cannot view process in Tasklist, Operate or Optimize', async () => {
                await navigationPage.goToOperate();
                await operateHomePage.clickProcessesTab();
                await (0, test_1.expect)(page.getByText(processName1)).not.toBeVisible({
                    timeout: 60000,
                });
                await (0, test_1.expect)(page.getByText(processName2)).not.toBeVisible({
                    timeout: 60000,
                });
                await navigationPage.goToTasklist();
                await (0, test_1.expect)(page.getByText(processName1)).not.toBeVisible({
                    timeout: 60000,
                });
                await (0, test_1.expect)(page.getByText(processName2)).not.toBeVisible({
                    timeout: 60000,
                });
                await navigationPage.goToOptimize();
                await optimizeHomePage.clickDashboardLink();
                await optimizeDashboardPage.processAssertion(processName1, {
                    not: true,
                    timeout: 300000,
                });
                await optimizeDashboardPage.processAssertion(processName2, { not: true });
            });
        });
    });
}
