"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
const test_1 = require("@playwright/test");
const SM_8_6_1 = require("../../fixtures/SM-8.6");
const _setup_1 = require("../../test-setup.js");
const sleep_1 = require("../../utils/sleep");
const UtlitiesPage_1 = require("../../pages/SM-8.6/UtlitiesPage");
const resetSession_1 = require("../../utils/resetSession");
const expectTextWithRetry_1 = require("../../utils/assertionHelpers/expectTextWithRetry");
const demoUserEmail = process.env.DEMO_USER_EMAIL || 'demo@example.org';
const demoUserDisplayText = `Demo User${demoUserEmail}`;
if (process.env.IS_MT === 'true') {
    SM_8_6_1.test.describe.configure({ mode: 'parallel' });
    SM_8_6_1.test.describe('MT Enabled User Flows Test', () => {
        SM_8_6_1.test.beforeEach(async ({ navigationPage }, testInfo) => {
            await navigationPage.goToIdentity((testInfo.workerIndex + 1) * 1000);
        });
        SM_8_6_1.test.afterEach(async ({ page }, testInfo) => {
            await (0, _setup_1.captureScreenshot)(page, testInfo);
            await (0, _setup_1.captureFailureVideo)(page, testInfo);
        });
        (0, SM_8_6_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, }) => {
            SM_8_6_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_6_1.test.step('Create Tenant And Assign User', async () => {
                await identityTenantPage.createTenant(tenantName);
                await identityTenantPage.assignUserToTenant(tenantName, 'demo', demoUserDisplayText);
                await identityTenantPage.assignClientToTenant('Zeebe');
                await identityTenantPage.assignClientToTenant('Test');
            });
            await SM_8_6_1.test.step('Open Cross Component Test Project', async () => {
                await navigationPage.goToModeler();
                await modelerHomePage.clickCrossComponentProjectFolder();
                await modelerHomePage.clickDiagramTypeDropdown();
                await modelerHomePage.clickBpmnTemplateOption();
            });
            await SM_8_6_1.test.step('Create A Diagram with a User Task and Start Process Instance', async () => {
                await modelerCreatePage.modelCamundaUserTaskDiagram(processName);
                await modelerCreatePage.clickStartInstanceMainButton();
                await modelerCreatePage.completeDeploymentEndpointConfiguration();
                await modelerCreatePage.clickTenantIdInput();
                await modelerCreatePage.fillTenantIdInput(tenantName);
                await modelerCreatePage.clickStartInstanceSubButton();
            });
            await SM_8_6_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.clickProcessActiveCheckbox();
                await operateProcessesPage.selectTenant(tenantName);
                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.selectTenant(tenantName);
                await operateProcessesPage.clickProcessInstanceLink(processName, 'completed');
                await operateProcessInstancePage.completedIconAssertion();
                await operateProcessInstancePage.tenantNameAssertion(tenantName);
            });
            await SM_8_6_1.test.step('Assert Process has been successfully imported in Optimize', async () => {
                await navigationPage.goToOptimize();
                await optimizeHomePage.clickDashboardLink();
                await (0, sleep_1.sleep)(60000);
                await page.reload();
                await optimizeDashboardPage.clickFilterTable();
                await optimizeDashboardPage.fillFilterTable(processName);
                await optimizeDashboardPage.processAssertion(processName);
            });
            await SM_8_6_1.test.step('Logout and Login with "bart" User', async () => {
                await optimizeHomePage.clickOpenUserSettingsButton();
                await optimizeHomePage.clickLogoutButton();
                await loginPage.login('bart', process.env.DISTRO_QA_E2E_TESTS_IDENTITY_THIRDUSER_PASSWORD);
            });
            await SM_8_6_1.test.step('Open Cross Component Test Project', async () => {
                await navigationPage.goToModeler();
                await modelerHomePage.createCrossComponentProjectFolder();
                await modelerHomePage.clickDiagramTypeDropdown();
                await modelerHomePage.clickBpmnTemplateOption();
            });
            await SM_8_6_1.test.step('Create A Diagram with a User Task and Assert Cannot Start Process Instance With Tenant', async () => {
                await modelerCreatePage.modelCamundaUserTaskDiagram(processName);
                await modelerCreatePage.clickStartInstanceMainButton();
                await modelerCreatePage.completeDeploymentEndpointConfiguration();
                await modelerCreatePage.clickTenantIdInput();
                await modelerCreatePage.fillTenantIdInput(tenantName);
                await modelerCreatePage.clickStartInstanceSubButton();
            });
            await SM_8_6_1.test.step('Assert "bart" user cannot view process in Tasklist, Operate or Optimize', async () => {
                await navigationPage.goToTasklist();
                await (0, test_1.expect)(page.getByText(processName)).not.toBeVisible({
                    timeout: 60000,
                });
                await navigationPage.goToOperate();
                await operateHomePage.clickProcessesTab();
                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,
                });
            });
        });
        (0, SM_8_6_1.test)('Main User Can Create & Access Tenant - Connectors Flow', async ({ page, modelerHomePage, modelerCreatePage, operateProcessInstancePage, operateProcessesPage, operateHomePage, navigationPage, identityTenantPage, connectorSettingsPage, connectorMarketplacePage, optimizeHomePage, optimizeDashboardPage, }) => {
            SM_8_6_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_6_1.test.step('Create Tenant And Assign User', async () => {
                await identityTenantPage.createTenant(tenantName);
                await identityTenantPage.assignUserToTenant(tenantName, 'demo', demoUserDisplayText);
                await identityTenantPage.assignClientToTenant('Zeebe');
                await identityTenantPage.assignClientToTenant('Test');
            });
            await SM_8_6_1.test.step('Open Cross Component Test Project', async () => {
                await navigationPage.goToModeler();
                await modelerHomePage.clickCrossComponentProjectFolder();
                await modelerHomePage.clickDiagramTypeDropdown();
                await modelerHomePage.clickBpmnTemplateOption();
            });
            await SM_8_6_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.completeDeploymentEndpointConfiguration();
                await modelerCreatePage.clickTenantIdInput();
                await modelerCreatePage.fillTenantIdInput(tenantName);
                await modelerCreatePage.clickStartInstanceSubButton();
            });
            await SM_8_6_1.test.step('View Process Instance in Operate & assert process is complete', async () => {
                await navigationPage.goToOperate();
                await operateHomePage.clickProcessesTab();
                await operateProcessesPage.selectTenant(tenantName);
                await operateProcessesPage.clickProcessInstanceLink(processName, 'completed');
                await operateProcessInstancePage.completedIconAssertion();
                await (0, test_1.expect)(page.getByTestId('variables-list')).toBeVisible({
                    timeout: 30000,
                });
                await (0, test_1.expect)(page.getByText('"Awesome!"')).toBeVisible({
                    timeout: 60000,
                });
                await operateProcessInstancePage.tenantNameAssertion(tenantName);
            });
            await SM_8_6_1.test.step('Assert Process has been successfully imported in Optimize', async () => {
                await navigationPage.goToOptimize();
                await optimizeHomePage.clickDashboardLink();
                await (0, sleep_1.sleep)(60000);
                await page.reload();
                await optimizeDashboardPage.clickFilterTable();
                await optimizeDashboardPage.fillFilterTable(processName);
                await optimizeDashboardPage.processAssertion(processName);
            });
        });
        (0, SM_8_6_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_6_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_6_1.test.step('Create Tenant And Assign User', async () => {
                await identityTenantPage.createTenant(tenantName);
                await identityTenantPage.assignUserToTenant(tenantName, 'lisa', 'Lisa Doecawemodev+lisa@gmail.');
                await identityTenantPage.assignClientToTenant('Zeebe');
                await identityTenantPage.assignClientToTenant('Test');
            });
            await SM_8_6_1.test.step('Logout and Login with "lisa" User', async () => {
                await identityTenantPage.clickOpenSidebarButton();
                await identityTenantPage.clickLogoutButton();
                await loginPage.login('lisa', process.env.DISTRO_QA_E2E_TESTS_IDENTITY_SECONDUSER_PASSWORD);
            });
            await SM_8_6_1.test.step('Open Cross Component Test Project', async () => {
                await navigationPage.goToModeler();
                await modelerHomePage.createCrossComponentProjectFolder();
                await modelerHomePage.clickDiagramTypeDropdown();
                await modelerHomePage.clickBpmnTemplateOption();
            });
            await SM_8_6_1.test.step('Create A Diagram with a User Task and Start Process Instance', async () => {
                await modelerCreatePage.modelCamundaUserTaskDiagram(processName);
                await modelerCreatePage.clickStartInstanceMainButton();
                await modelerCreatePage.completeDeploymentEndpointConfiguration();
                await modelerCreatePage.clickTenantIdInput();
                await modelerCreatePage.fillTenantIdInput(tenantName);
                await modelerCreatePage.clickStartInstanceSubButton();
            });
            await SM_8_6_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.clickProcessActiveCheckbox();
                await operateProcessesPage.selectTenant(tenantName);
                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.selectTenant(tenantName);
                await operateProcessesPage.clickProcessInstanceLink(processName, 'completed');
                await operateProcessInstancePage.completedIconAssertion();
                await operateProcessInstancePage.tenantNameAssertion(tenantName);
            });
            await SM_8_6_1.test.step('Assert Process has been successfully imported in Optimize', async () => {
                await navigationPage.goToOptimize();
                await optimizeHomePage.clickDashboardLink();
                await (0, sleep_1.sleep)(60000);
                await page.reload();
                await optimizeDashboardPage.clickFilterTable();
                await optimizeDashboardPage.fillFilterTable(processName);
                await optimizeDashboardPage.processAssertion(processName);
            });
        });
        (0, SM_8_6_1.test)('Second User Can Access Tenant Created By Main User - Connectors Flow', async ({ page, modelerHomePage, modelerCreatePage, operateProcessInstancePage, operateProcessesPage, operateHomePage, navigationPage, identityTenantPage, connectorSettingsPage, connectorMarketplacePage, loginPage, optimizeHomePage, optimizeDashboardPage, }) => {
            SM_8_6_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_6_1.test.step('Create Tenant And Assign User', async () => {
                await identityTenantPage.createTenant(tenantName);
                await identityTenantPage.assignUserToTenant(tenantName, 'lisa', 'Lisa Doecawemodev+lisa@gmail.');
                await identityTenantPage.assignClientToTenant('Zeebe');
                await identityTenantPage.assignClientToTenant('Test');
            });
            await SM_8_6_1.test.step('Logout and Login with "lisa" User', async () => {
                await identityTenantPage.clickOpenSidebarButton();
                await identityTenantPage.clickLogoutButton();
                await loginPage.login('lisa', process.env.DISTRO_QA_E2E_TESTS_IDENTITY_SECONDUSER_PASSWORD);
            });
            await SM_8_6_1.test.step('Open Cross Component Test Project', async () => {
                await navigationPage.goToModeler();
                await modelerHomePage.clickCrossComponentProjectFolder();
                await modelerHomePage.clickDiagramTypeDropdown();
                await modelerHomePage.clickBpmnTemplateOption();
            });
            await SM_8_6_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.completeDeploymentEndpointConfiguration();
                await modelerCreatePage.clickTenantIdInput();
                await modelerCreatePage.fillTenantIdInput(tenantName);
                await modelerCreatePage.clickStartInstanceSubButton();
            });
            await SM_8_6_1.test.step('View Process Instance in Operate & assert process is complete', async () => {
                await navigationPage.goToOperate();
                await operateHomePage.clickProcessesTab();
                await operateProcessesPage.selectTenant(tenantName);
                await operateProcessesPage.clickProcessInstanceLink(processName, 'completed');
                await operateProcessInstancePage.completedIconAssertion();
                await (0, test_1.expect)(page.getByTestId('variables-list')).toBeVisible({
                    timeout: 30000,
                });
                await (0, test_1.expect)(page.getByText('"Awesome!"')).toBeVisible({
                    timeout: 60000,
                });
                await operateProcessInstancePage.tenantNameAssertion(tenantName);
            });
            await SM_8_6_1.test.step('Assert Process has been successfully imported in Optimize', async () => {
                await navigationPage.goToOptimize();
                await optimizeHomePage.clickDashboardLink();
                await (0, sleep_1.sleep)(60000);
                await page.reload();
                await optimizeDashboardPage.clickFilterTable();
                await optimizeDashboardPage.fillFilterTable(processName);
                await optimizeDashboardPage.processAssertion(processName);
            });
        });
        (0, SM_8_6_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, }) => {
            SM_8_6_1.test.slow();
            const randomString = await (0, _setup_1.generateRandomStringAsync)(3);
            const processName = 'Default_Tenant_Flow_' + randomString;
            const tenantName = 'Default';
            await SM_8_6_1.test.step('Assign User To Default Tenant', async () => {
                await identityTenantPage.assignUserToTenant(tenantName, 'demo', demoUserDisplayText);
                await identityTenantPage.assignClientToTenant('Zeebe');
                await identityTenantPage.assignClientToTenant('Test');
            });
            await SM_8_6_1.test.step('Open Cross Component Test Project', async () => {
                await navigationPage.goToModeler();
                await modelerHomePage.clickCrossComponentProjectFolder();
                await modelerHomePage.clickDiagramTypeDropdown();
                await modelerHomePage.clickBpmnTemplateOption();
            });
            await SM_8_6_1.test.step('Create A Diagram with a User Task and Start Process Instance', async () => {
                await modelerCreatePage.modelCamundaUserTaskDiagram(processName);
                await modelerCreatePage.clickStartInstanceMainButton();
                await modelerCreatePage.completeDeploymentEndpointConfiguration();
                await modelerCreatePage.clickStartInstanceSubButton();
                await modelerCreatePage.instanceStartedAssertion();
            });
            await SM_8_6_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.clickProcessActiveCheckbox();
                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');
                await operateProcessInstancePage.completedIconAssertion();
                await operateProcessInstancePage.tenantNameAssertion(tenantName);
            });
            await SM_8_6_1.test.step('Assert Process has been successfully imported in Optimize', async () => {
                await navigationPage.goToOptimize();
                await optimizeHomePage.clickDashboardLink();
                await (0, sleep_1.sleep)(60000);
                await page.reload();
                await optimizeDashboardPage.clickFilterTable();
                await optimizeDashboardPage.fillFilterTable(processName);
                await optimizeDashboardPage.processAssertion(processName);
            });
        });
        (0, SM_8_6_1.test)('User Can Be Assigned To Multiple Tenants', async ({ page, identityPage, modelerHomePage, modelerCreatePage, operateProcessInstancePage, operateProcessesPage, operateHomePage, navigationPage, identityTenantPage, connectorSettingsPage, connectorMarketplacePage, }) => {
            SM_8_6_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_6_1.test.step('Create Two Tenants And Assign to Demo User', async () => {
                await identityTenantPage.createTenant(tenantName1);
                await identityTenantPage.assignUserToTenant(tenantName1, 'demo', demoUserDisplayText);
                await identityTenantPage.assignClientToTenant('Zeebe');
                await identityTenantPage.assignClientToTenant('Test');
                await identityPage.clickTenantTab();
                await identityTenantPage.createTenant(tenantName2);
                await identityTenantPage.assignUserToTenant(tenantName2, 'demo', demoUserDisplayText);
                await identityTenantPage.assignClientToTenant('Zeebe');
                await identityTenantPage.assignClientToTenant('Test');
            });
            await SM_8_6_1.test.step('Open Cross Component Test Project', async () => {
                await navigationPage.goToModeler();
                await modelerHomePage.clickCrossComponentProjectFolder();
                await modelerHomePage.clickDiagramTypeDropdown();
                await modelerHomePage.clickBpmnTemplateOption();
            });
            await SM_8_6_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.completeDeploymentEndpointConfiguration();
                await modelerCreatePage.clickTenantIdInput();
                await modelerCreatePage.fillTenantIdInput(tenantName1);
                await modelerCreatePage.clickStartInstanceSubButton();
            });
            await SM_8_6_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.completeDeploymentEndpointConfiguration();
                await modelerCreatePage.clickTenantIdInput();
                await modelerCreatePage.fillTenantIdInput(tenantName2);
                await modelerCreatePage.clickStartInstanceSubButton();
            });
            await SM_8_6_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.selectTenant(tenantName1);
                await operateProcessesPage.clickProcessInstanceLink(processName1, 'completed');
                await operateProcessInstancePage.completedIconAssertion();
                await (0, expectTextWithRetry_1.expectTextWithRetry)(page, '"Awesome!"', {
                    postAction: async () => {
                        await page.reload();
                    },
                });
                await operateProcessInstancePage.tenantNameAssertion(tenantName1);
                await operateHomePage.clickProcessesTab();
                await operateProcessesPage.selectTenant(tenantName2);
                await operateProcessesPage.clickProcessInstanceLink(processName2, 'completed');
                await operateProcessInstancePage.completedIconAssertion();
                await (0, expectTextWithRetry_1.expectTextWithRetry)(page, '"Awesome!"', {
                    postAction: async () => {
                        await page.reload();
                    },
                });
                await operateProcessInstancePage.tenantNameAssertion(tenantName2);
            });
        });
        (0, SM_8_6_1.test)('Revoking Tenant Access User Flow', async ({ page, modelerHomePage, modelerCreatePage, taskPanelPage, operateProcessInstancePage, operateProcessesPage, taskDetailsPage, operateHomePage, navigationPage, identityTenantPage, optimizeHomePage, optimizeDashboardPage, browser, }) => {
            SM_8_6_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_6_1.test.step('Create Tenant And Assign User', async () => {
                await identityTenantPage.createTenant(tenantName);
                await identityTenantPage.assignUserToTenant(tenantName, 'demo', demoUserDisplayText);
                await identityTenantPage.assignClientToTenant('Zeebe');
                await identityTenantPage.assignClientToTenant('Test');
            });
            await SM_8_6_1.test.step('Open Cross Component Test Project', async () => {
                await navigationPage.goToModeler();
                await modelerHomePage.clickCrossComponentProjectFolder();
                await modelerHomePage.clickDiagramTypeDropdown();
                await modelerHomePage.clickBpmnTemplateOption();
            });
            await SM_8_6_1.test.step('Create A Diagram with a User Task and Start Process Instance', async () => {
                await modelerCreatePage.modelCamundaUserTaskDiagram(processName1);
                await modelerCreatePage.clickStartInstanceMainButton();
                await modelerCreatePage.completeDeploymentEndpointConfiguration();
                await modelerCreatePage.clickTenantIdInput();
                await modelerCreatePage.fillTenantIdInput(tenantName);
                await modelerCreatePage.clickStartInstanceSubButton();
            });
            await SM_8_6_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.clickProcessActiveCheckbox();
                await operateProcessesPage.selectTenant(tenantName);
                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.selectTenant(tenantName);
                await operateProcessesPage.clickProcessInstanceLink(processName1, 'completed');
                await operateProcessInstancePage.completedIconAssertion();
                await operateProcessInstancePage.tenantNameAssertion(tenantName);
            });
            await SM_8_6_1.test.step('Assert Process has been successfully imported in Optimize', async () => {
                await navigationPage.goToOptimize();
                await optimizeHomePage.clickDashboardLink();
                await (0, sleep_1.sleep)(60000);
                await page.reload();
                await optimizeDashboardPage.clickFilterTable();
                await optimizeDashboardPage.fillFilterTable(processName1);
                await optimizeDashboardPage.processAssertion(processName1);
            });
            await SM_8_6_1.test.step('Delete Tenant Access For Demo User', async () => {
                await navigationPage.goToIdentity();
                await identityTenantPage.removeUserFromTenant(tenantName);
            });
            await SM_8_6_1.test.step('Clear cookies and reset session', async () => {
                await (0, resetSession_1.resetSession)(browser, page);
                await (0, sleep_1.sleep)(10000);
            });
            await SM_8_6_1.test.step('Open Cross Component Test Project', async () => {
                await navigationPage.goToModeler();
                await modelerHomePage.createCrossComponentProjectFolder();
                await modelerHomePage.clickDiagramTypeDropdown();
                await modelerHomePage.clickBpmnTemplateOption();
            });
            await SM_8_6_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.completeDeploymentEndpointConfiguration();
                await modelerCreatePage.clickTenantIdInput();
                await modelerCreatePage.fillTenantIdInput(tenantName);
                await modelerCreatePage.clickStartInstanceSubButton();
            });
            await SM_8_6_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 });
            });
        });
    });
}
