"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
const c8Run_8_10_1 = require("../../fixtures/c8Run-8.10");
const test_1 = require("@playwright/test");
const apiHelpers_1 = require("../../utils/apiHelpers");
const zeebeClient_1 = require("../../utils/zeebeClient");
const sleep_1 = require("../../utils/sleep");
const constants_1 = require("../../utils/constants");
c8Run_8_10_1.test.beforeAll(async () => {
    await Promise.all([
        (0, zeebeClient_1.deploy)('./resources/User_Task_Process_With_Form.bpmn'),
        (0, zeebeClient_1.deploy)('./resources/New Form.form'),
        (0, zeebeClient_1.deploy)('./resources/User_Task_Process_With_Form.bpmn'),
        (0, zeebeClient_1.deploy)('./resources/Start_Form_Process.bpmn'),
    ]);
    await Promise.all([
        (0, zeebeClient_1.createInstances)('Form_User_Task', 1, 3),
        (0, zeebeClient_1.createInstances)('Start_Form_Process', 1, 1),
    ]);
    await (0, sleep_1.sleep)(10000);
});
c8Run_8_10_1.test.describe('API tests for V2 @tasklistV2', () => {
    (0, c8Run_8_10_1.test)('Search for process definitions', async ({ request }) => {
        const processDefinitionsList = await request.post('/v2/process-definitions/search');
        await (0, apiHelpers_1.assertResponseStatus)(processDefinitionsList, 200);
    });
    (0, c8Run_8_10_1.test)('Search for process instances', async ({ request }) => {
        const processInstancesList = await request.post('/v2/process-instances/search');
        await (0, apiHelpers_1.assertResponseStatus)(processInstancesList, 200);
    });
    (0, c8Run_8_10_1.test)('Search for element-instances', async ({ request }) => {
        const elementInstancesList = await request.post('/v2/element-instances/search');
        await (0, apiHelpers_1.assertResponseStatus)(elementInstancesList, 200);
    });
    (0, c8Run_8_10_1.test)('Search for variables for process instances', async ({ request }) => {
        const variablesInstancesList = await request.post('/v2/variables/search');
        await (0, apiHelpers_1.assertResponseStatus)(variablesInstancesList, 200);
    });
    (0, c8Run_8_10_1.test)('Search for incidents', async ({ request }) => {
        const incidentsList = await request.post('/v2/incidents/search');
        await (0, apiHelpers_1.assertResponseStatus)(incidentsList, 200);
    });
    (0, c8Run_8_10_1.test)('Get connectors status', async ({ request }) => {
        await (0, test_1.expect)(async () => {
            const connectorsStatus = await request.get(process.env.C8RUN_CONNECTORS_API_URL_LATEST + '/actuator/health');
            await (0, apiHelpers_1.assertResponseStatus)(connectorsStatus, 200);
        }).toPass({ ...constants_1.defaultAssertionOptions, timeout: 120000 });
    });
    (0, c8Run_8_10_1.test)('Get a inbound connectors list', async ({ request }) => {
        const connectorsInboundList = await request.get(process.env.C8RUN_CONNECTORS_API_URL_LATEST + '/inbound');
        await (0, apiHelpers_1.assertResponseStatus)(connectorsInboundList, 200);
    });
    (0, c8Run_8_10_1.test)('Search for tasks', async ({ request }) => {
        const taskList = await request.post('/v2/user-tasks/search');
        (0, test_1.expect)(taskList.status()).toBe(200);
    });
});
