"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");
SM_8_6_1.test.describe.configure({ mode: 'parallel' });
SM_8_6_1.test.describe('Deploy and run a process in Play', () => {
    SM_8_6_1.test.beforeEach(async ({ navigationPage }, testInfo) => {
        await navigationPage.goToModeler((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)('User Tasks and Service Task', async ({ modelerHomePage, modelerCreatePage, playPage, }) => {
        SM_8_6_1.test.slow();
        const randomString = await (0, _setup_1.generateRandomStringAsync)(3);
        const processName = 'Play_Test_Process' + randomString;
        await SM_8_6_1.test.step('Open Cross Component Test Project', async () => {
            await modelerHomePage.clickCrossComponentProjectFolder();
        });
        await SM_8_6_1.test.step('Add A BPMN Template To The Project', async () => {
            await modelerHomePage.clickDiagramTypeDropdown();
            await modelerHomePage.clickBpmnTemplateOption();
        });
        await SM_8_6_1.test.step('Create a BPMN Diagram with user tasks and service task', async () => {
            await (0, test_1.expect)(modelerCreatePage.generalPanel).toBeVisible({
                timeout: 120000,
            });
            await modelerCreatePage.enterDiagramName(processName);
            await (0, sleep_1.sleep)(20000);
            // Add a user task with Job worker implementation (default)
            await modelerCreatePage.clickAppendElementButton();
            await modelerCreatePage.clickAppendTaskButton();
            await modelerCreatePage.clickChangeTypeButton();
            await modelerCreatePage.clickUserTaskOption();
            await modelerCreatePage.chooseImplementationOption('jobWorker');
            await modelerCreatePage.clickGeneralPropertiesPanel();
            await modelerCreatePage.clickElemendIdInput();
            await modelerCreatePage.fillElementIdInput('tasklist-user-task' + randomString);
            // Add a user task with Zeebe user task implementation
            await modelerCreatePage.clickAppendElementButton();
            await modelerCreatePage.clickAppendTaskButton();
            await modelerCreatePage.clickChangeTypeButton();
            await modelerCreatePage.clickUserTaskOption();
            await modelerCreatePage.chooseImplementationOption('zeebeUserTask');
            await modelerCreatePage.clickElemendIdInput();
            await modelerCreatePage.fillElementIdInput('zeebe-user-task' + randomString);
            // Add a service task
            await modelerCreatePage.clickAppendElementButton();
            await modelerCreatePage.clickAppendTaskButton();
            await modelerCreatePage.clickChangeTypeButton();
            await modelerCreatePage.clickServiceTaskOption();
            await modelerCreatePage.clickElemendIdInput();
            await modelerCreatePage.fillElementIdInput('service-task' + randomString);
            await modelerCreatePage.clickTaskDefinitionPropertiesPanel();
            await modelerCreatePage.clickJobTypeInput();
            await modelerCreatePage.fillJobTypeInput('someJob' + randomString);
            // Add end event
            await modelerCreatePage.clickAppendElementButton();
            await modelerCreatePage.clickAppendEndEventButton();
        });
        await SM_8_6_1.test.step('Open Play', async () => {
            await modelerCreatePage.switchToPlay();
            await modelerCreatePage.completePlayConfiguration();
        });
        await SM_8_6_1.test.step('Start and complete the process instance in Play', async () => {
            await playPage.dismissStartModal();
            await playPage.clickStartInstanceButton();
            await playPage.waitForInstanceDetailsToBeLoaded();
            // wait for and complete the "tasklist user task"
            await playPage.waitForNextElementToBeActive('tasklist-user-task' + randomString);
            await playPage.waitForCompleteJobButtonToBeAvailable();
            await playPage.clickCompleteJobButton();
            // wait for and complete the "zeebe user task"
            await playPage.waitForNextElementToBeActive('zeebe-user-task' + randomString);
            await playPage.waitForCompleteJobButtonToBeAvailable();
            await playPage.clickCompleteJobButton();
            // wait for and complete the "service task"
            await playPage.waitForNextElementToBeActive('service-task' + randomString);
            await playPage.waitForCompleteJobButtonToBeAvailable();
            await playPage.clickCompleteJobButton();
            await playPage.waitForProcessToBeCompleted();
        });
    });
});
