var __assign = (this && this.__assign) || function () {
    __assign = Object.assign || function(t) {
        for (var s, i = 1, n = arguments.length; i < n; i++) {
            s = arguments[i];
            for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p))
                t[p] = s[p];
        }
        return t;
    };
    return __assign.apply(this, arguments);
};
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
    function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
    return new (P || (P = Promise))(function (resolve, reject) {
        function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
        function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
        function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
        step((generator = generator.apply(thisArg, _arguments || [])).next());
    });
};
var __generator = (this && this.__generator) || function (thisArg, body) {
    var _ = { label: 0, sent: function() { if (t[0] & 1) throw t[1]; return t[1]; }, trys: [], ops: [] }, f, y, t, g = Object.create((typeof Iterator === "function" ? Iterator : Object).prototype);
    return g.next = verb(0), g["throw"] = verb(1), g["return"] = verb(2), typeof Symbol === "function" && (g[Symbol.iterator] = function() { return this; }), g;
    function verb(n) { return function (v) { return step([n, v]); }; }
    function step(op) {
        if (f) throw new TypeError("Generator is already executing.");
        while (g && (g = 0, op[0] && (_ = 0)), _) try {
            if (f = 1, y && (t = op[0] & 2 ? y["return"] : op[0] ? y["throw"] || ((t = y["return"]) && t.call(y), 0) : y.next) && !(t = t.call(y, op[1])).done) return t;
            if (y = 0, t) op = [op[0] & 2, t.value];
            switch (op[0]) {
                case 0: case 1: t = op; break;
                case 4: _.label++; return { value: op[1], done: false };
                case 5: _.label++; y = op[1]; op = [0]; continue;
                case 7: op = _.ops.pop(); _.trys.pop(); continue;
                default:
                    if (!(t = _.trys, t = t.length > 0 && t[t.length - 1]) && (op[0] === 6 || op[0] === 2)) { _ = 0; continue; }
                    if (op[0] === 3 && (!t || (op[1] > t[0] && op[1] < t[3]))) { _.label = op[1]; break; }
                    if (op[0] === 6 && _.label < t[1]) { _.label = t[1]; t = op; break; }
                    if (t && _.label < t[2]) { _.label = t[2]; _.ops.push(op); break; }
                    if (t[2]) _.ops.pop();
                    _.trys.pop(); continue;
            }
            op = body.call(thisArg, _);
        } catch (e) { op = [6, e]; y = 0; } finally { f = t = 0; }
        if (op[0] & 5) throw op[1]; return { value: op[0] ? op[1] : void 0, done: true };
    }
};
var __spreadArray = (this && this.__spreadArray) || function (to, from, pack) {
    if (pack || arguments.length === 2) for (var i = 0, l = from.length, ar; i < l; i++) {
        if (ar || !(i in from)) {
            if (!ar) ar = Array.prototype.slice.call(from, 0, i);
            ar[i] = from[i];
        }
    }
    return to.concat(ar || Array.prototype.slice.call(from));
};
import React from 'react';
import { render, screen, within } from '@testing-library/react';
import userEvent from '@testing-library/user-event';
import moment from 'moment';
import { LocalizationProvider } from '@mui/x-date-pickers/LocalizationProvider';
import { AdapterMoment } from '@mui/x-date-pickers/AdapterMoment';
import { DCROperationTypes, DCRTypes, getDataChangeRequest, getEntitiesByUris, runTaskAction } from '@reltio/mdm-sdk';
import { MdmModuleProvider } from '../../../../../contexts/MdmModuleContext';
import { CommentDialogProvider } from '../../../../../contexts/CommentDialogContext';
import { DataChangeRequestTaskCard } from './DataChangeRequestTaskCard';
import { WorkflowTasksContext } from '../../../../../contexts/WorkflowTasksContext';
jest.mock('@reltio/mdm-sdk', function () { return (__assign(__assign({}, jest.requireActual('@reltio/mdm-sdk')), { getDataChangeRequest: jest.fn(), getEntitiesByUris: jest.fn(), runTaskAction: jest.fn() })); });
var onActionSuccess = jest.fn();
var workflowTaskContextValue = { onActionSuccess: onActionSuccess };
describe('DataChangeRequestTaskCard tests', function () {
    var _a, _b;
    var metadata = {
        entityTypes: [
            {
                uri: 'configuration/entityTypes/Company',
                label: 'Company',
                description: 'Company',
                extendsTypeURI: 'configuration/entityTypes/Organization',
                attributes: [
                    {
                        label: 'Activation Date',
                        name: 'ActivationDate',
                        type: 'String',
                        uri: 'configuration/entityTypes/Company/attributes/ActivationDate'
                    },
                    {
                        label: 'Name',
                        name: 'Name',
                        type: 'String',
                        uri: 'configuration/entityTypes/Company/attributes/Name'
                    },
                    {
                        dependentLookupCode: 'COUNTRY_CD',
                        label: 'Country Code',
                        name: 'CountryCode',
                        type: 'String',
                        uri: 'configuration/entityTypes/Company/attributes/CountryCode'
                    },
                    {
                        label: 'Address',
                        name: 'Address',
                        type: 'Reference',
                        uri: 'configuration/entityTypes/Company/attributes/Address',
                        referencedAttributeURIs: ['configuration/entityTypes/Location/attributes/City'],
                        referencedEntityTypeURI: 'configuration/entityTypes/Location'
                    },
                    {
                        label: 'NestedFirstLevel',
                        name: 'NestedFirstLevel',
                        type: 'Nested',
                        uri: 'configuration/entityTypes/Company/attributes/NestedFirstLevel',
                        attributes: [
                            {
                                label: 'NestedSecondLevel',
                                name: 'NestedSecondLevel',
                                type: 'Nested',
                                uri: 'configuration/entityTypes/Company/attributes/NestedFirstLevel/attributes/NestedSecondLevel',
                                attributes: [
                                    {
                                        label: 'FifthLevelSimple4',
                                        name: 'FifthLevelSimple4',
                                        type: 'String',
                                        uri: 'configuration/entityTypes/Company/attributes/NestedFirstLevel/attributes/NestedSecondLevel/attributes/FifthLevelSimple4'
                                    },
                                    {
                                        label: 'FifthLevelSimple5',
                                        name: 'FifthLevelSimple5',
                                        type: 'String',
                                        uri: 'configuration/entityTypes/Company/attributes/NestedFirstLevel/attributes/NestedSecondLevel/attributes/FifthLevelSimple5'
                                    }
                                ]
                            }
                        ]
                    }
                ],
                abstract: false
            },
            {
                uri: 'configuration/entityTypes/Location',
                label: 'Address',
                attributes: [
                    {
                        label: 'City',
                        name: 'City',
                        type: 'String',
                        uri: 'configuration/entityTypes/Location/attributes/City'
                    }
                ],
                abstract: false
            }
        ],
        relationTypes: [
            {
                uri: 'configuration/relationTypes/Managed',
                label: 'Managed',
                startObject: {
                    uri: 'configuration/relationTypes/Managed/startObject',
                    objectTypeURI: 'configuration/entityTypes/Company'
                },
                endObject: {
                    uri: 'configuration/relationTypes/Managed/endObject',
                    objectTypeURI: 'configuration/entityTypes/Company'
                },
                attributes: [],
                direction: 'directed'
            }
        ]
    };
    var entityUri = 'entities/00COBWl';
    var relationUri = 'relations/07VxtSE';
    var userName = 'eugeny.sokolov';
    var priorityClass = 'Medium';
    var displayName = 'DCR Review';
    var processDefinitionDisplayName = 'Data Change Request Review';
    var dcrId = '0kCnzFE';
    var dcrUri = "changeRequests/".concat(dcrId);
    var dueDate = 1731825314640;
    var newStartDate = moment('11/15/2024', 'MM/DD/YYYY').valueOf();
    var defaultTask = {
        assignee: userName,
        processInstanceId: '60260030',
        processType: 'dataChangeRequestReview',
        objectURIs: [dcrUri, entityUri, relationUri],
        suspended: false,
        createdBy: userName,
        priorityClass: priorityClass,
        taskType: 'dcrReview',
        createTime: 1731652514639,
        dueDate: dueDate,
        taskId: '60260042',
        displayName: displayName,
        processDefinitionDisplayName: processDefinitionDisplayName
    };
    var entityLabel = 'EntityLabel';
    var relationEntityLabel = 'RelationEntityLabel';
    var refEntityLabel = 'RefEntityLabel';
    var oldNameValue = 'oldNameValue';
    var newNameValue = 'newNameValue';
    var dcr = {
        uri: 'changeRequests/0kCnzFE',
        createdBy: userName,
        createdTime: 1731652509123,
        updatedBy: userName,
        updatedTime: 1731652511713,
        changes: (_a = {},
            _a[entityUri] = [
                {
                    id: '0kCo7lk',
                    type: DCRTypes.UPDATE_ATTRIBUTE,
                    createdTime: 1731652511713,
                    createdBy: userName,
                    attributePath: 'Name/xhGw4BJ',
                    oldValue: {
                        value: oldNameValue
                    },
                    newValue: {
                        value: newNameValue
                    },
                    attributeType: 'configuration/entityTypes/Company/attributes/Name'
                }
            ],
            _a[relationUri] = [
                {
                    id: '0kCnuyy',
                    type: DCRTypes.UPDATE_START_DATE,
                    createdTime: 1731652509123,
                    createdBy: userName,
                    newValue: [newStartDate]
                }
            ],
            _a),
        objectsInfo: (_b = {},
            _b[entityUri] = {
                type: 'configuration/entityTypes/Company',
                label: entityLabel
            },
            _b[relationUri] = {
                type: 'configuration/relationTypes/Managed',
                startObjectUri: 'entities/07AWt2z',
                startObjectLabel: relationEntityLabel,
                endObjectUri: entityUri,
                endObjectLabel: entityLabel
            },
            _b['entities/19emZkLd'] = {
                type: 'configuration/entityTypes/Location',
                label: refEntityLabel
            },
            _b),
        type: 'configuration/changeRequestTypes/default',
        state: 'AWAITING_REVIEW'
    };
    var entities = [
        {
            uri: 'entities/07AWt2z',
            type: 'configuration/entityTypes/Company',
            label: relationEntityLabel
        }
    ];
    var tenant = { id: 't1', name: 't1' };
    var workflowPath = 'workflowPath';
    var workflowEnvironmentUrl = 'workflowEnvironmentUrl';
    var mdmDefaultValues = {
        metadata: metadata,
        user: {
            username: userName
        },
        tenant: tenant,
        workflowPath: workflowPath,
        workflowEnvironmentUrl: workflowEnvironmentUrl,
        entity: { uri: entityUri }
    };
    var setUp = function (_a) {
        var _b = _a === void 0 ? {} : _a, _c = _b.task, task = _c === void 0 ? defaultTask : _c, _d = _b.mdmValues, mdmValues = _d === void 0 ? mdmDefaultValues : _d;
        var user = userEvent.setup();
        var Providers = function (_a) {
            var children = _a.children;
            return (React.createElement(MdmModuleProvider, { values: mdmValues },
                React.createElement(LocalizationProvider, { dateAdapter: AdapterMoment },
                    React.createElement(WorkflowTasksContext.Provider, { value: workflowTaskContextValue },
                        React.createElement(CommentDialogProvider, null, children)))));
        };
        return __assign(__assign({}, render(React.createElement(DataChangeRequestTaskCard, { task: task }), { wrapper: Providers })), { user: user });
    };
    beforeAll(function () {
        getEntitiesByUris.mockResolvedValue(entities);
        runTaskAction.mockResolvedValue(null);
    });
    afterEach(function () {
        jest.clearAllMocks();
    });
    it('should render main parts', function () { return __awaiter(void 0, void 0, void 0, function () {
        var user, changesContainers;
        return __generator(this, function (_a) {
            switch (_a.label) {
                case 0:
                    getDataChangeRequest.mockResolvedValue(dcr);
                    user = setUp().user;
                    expect(screen.getByTestId('SvgDcrTaskIcon')).toBeInTheDocument();
                    expect(screen.getByText(processDefinitionDisplayName)).toBeInTheDocument();
                    expect(screen.getByText(moment(dueDate).format('MM/DD/YYYY'))).toBeInTheDocument();
                    expect(screen.getByText(dcrId)).toBeInTheDocument();
                    expect(screen.getByText(userName)).toBeInTheDocument();
                    expect(screen.getByText(displayName)).toBeInTheDocument();
                    return [4 /*yield*/, user.click(screen.getByTestId('collapse-button'))];
                case 1:
                    _a.sent();
                    changesContainers = screen.getAllByTestId('changes-container');
                    expect(changesContainers).toHaveLength(2);
                    expect(within(changesContainers[0]).getByText('Name')).toBeInTheDocument();
                    expect(within(changesContainers[0]).getByText(entityLabel)).toBeInTheDocument();
                    expect(within(changesContainers[0]).getByText(new RegExp("^".concat(oldNameValue, ".*").concat(newNameValue, "$")))).toBeInTheDocument();
                    expect(within(changesContainers[0]).getByTestId('arrow-right')).toBeInTheDocument();
                    expect(within(changesContainers[0]).getByText(DCROperationTypes.EDITED)).toBeInTheDocument();
                    expect(within(changesContainers[1]).getByText(relationEntityLabel)).toBeInTheDocument();
                    expect(within(changesContainers[1]).getByText('Relationships')).toBeInTheDocument();
                    expect(within(changesContainers[1]).getByText('Managed')).toBeInTheDocument();
                    expect(within(changesContainers[1]).getByText(entityLabel)).toBeInTheDocument();
                    expect(within(changesContainers[1]).getByText('Start date')).toBeInTheDocument();
                    expect(within(changesContainers[1]).getByText(moment(newStartDate).format('MM/DD/YYYY'))).toBeInTheDocument();
                    expect(within(changesContainers[1]).getByText(DCROperationTypes.ADDED)).toBeInTheDocument();
                    expect(within(changesContainers[1]).queryByTestId('arrow-right')).not.toBeInTheDocument();
                    return [2 /*return*/];
            }
        });
    }); });
    it('should work correctly with nested attributes', function () { return __awaiter(void 0, void 0, void 0, function () {
        var nestedAttrName, subNestedAttrName, subSubNestedAttr1, addedNestedValue, changedWithNested, dcrWithNested, user;
        var _a, _b;
        return __generator(this, function (_c) {
            switch (_c.label) {
                case 0:
                    nestedAttrName = 'NestedFirstLevel';
                    subNestedAttrName = 'NestedSecondLevel';
                    subSubNestedAttr1 = 'FifthLevelSimple4';
                    addedNestedValue = 'addedNestedValue';
                    changedWithNested = (_a = {},
                        _a[entityUri] = [
                            {
                                id: '0kCoGIG',
                                type: DCRTypes.INSERT_ATTRIBUTE,
                                createdTime: 1731652511713,
                                createdBy: userName,
                                attributePath: nestedAttrName,
                                newValue: {
                                    value: (_b = {},
                                        _b[subNestedAttrName] = [
                                            {
                                                value: {
                                                    FifthLevelSimple4: [
                                                        {
                                                            value: addedNestedValue
                                                        }
                                                    ]
                                                }
                                            }
                                        ],
                                        _b)
                                },
                                attributeType: 'configuration/entityTypes/Company/attributes/NestedFirstLevel'
                            }
                        ],
                        _a);
                    dcrWithNested = __assign(__assign({}, dcr), { changes: changedWithNested });
                    getDataChangeRequest.mockResolvedValue(dcrWithNested);
                    user = setUp().user;
                    return [4 /*yield*/, user.click(screen.getByTestId('collapse-button'))];
                case 1:
                    _c.sent();
                    expect(screen.getByText(nestedAttrName)).toBeInTheDocument();
                    expect(screen.getByText(subNestedAttrName)).toBeInTheDocument();
                    expect(screen.getByText(subSubNestedAttr1)).toBeInTheDocument();
                    expect(screen.getByText(DCROperationTypes.ADDED)).toBeInTheDocument();
                    expect(screen.queryByTestId('arrow-right')).not.toBeInTheDocument();
                    return [2 /*return*/];
            }
        });
    }); });
    it('should work correctly with reference attributes', function () { return __awaiter(void 0, void 0, void 0, function () {
        var attributePath, refAttributeName, addedRefValue, changedWithRef, dcrWithRef, user;
        var _a;
        return __generator(this, function (_b) {
            switch (_b.label) {
                case 0:
                    attributePath = 'Address';
                    refAttributeName = 'City';
                    addedRefValue = 'addedRefValue';
                    changedWithRef = (_a = {},
                        _a[entityUri] = [
                            {
                                id: '0kCoC20',
                                type: DCRTypes.INSERT_ATTRIBUTE,
                                createdTime: 1731652511713,
                                createdBy: 'eugeny.sokolov',
                                attributePath: attributePath,
                                newValue: {
                                    value: {
                                        City: [
                                            {
                                                value: addedRefValue
                                            }
                                        ]
                                    },
                                    refEntity: {
                                        objectURI: 'entities/19emZkLd'
                                    }
                                },
                                attributeType: 'configuration/entityTypes/Company/attributes/Address'
                            }
                        ],
                        _a);
                    dcrWithRef = __assign(__assign({}, dcr), { changes: changedWithRef });
                    getDataChangeRequest.mockResolvedValue(dcrWithRef);
                    user = setUp().user;
                    return [4 /*yield*/, user.click(screen.getByTestId('collapse-button'))];
                case 1:
                    _b.sent();
                    expect(screen.getByText(attributePath)).toBeInTheDocument();
                    expect(screen.getByText(refAttributeName)).toBeInTheDocument();
                    expect(screen.getByText(refEntityLabel)).toBeInTheDocument();
                    expect(screen.getByText(addedRefValue)).toBeInTheDocument();
                    expect(screen.getByText(DCROperationTypes.ADDED)).toBeInTheDocument();
                    expect(screen.queryByTestId('arrow-right')).not.toBeInTheDocument();
                    return [2 /*return*/];
            }
        });
    }); });
    it('should render ShowMoreLink if length of merged changes more than 3', function () { return __awaiter(void 0, void 0, void 0, function () {
        var bigChanges, dcrWithBigChanges, user;
        var _a;
        return __generator(this, function (_b) {
            switch (_b.label) {
                case 0:
                    bigChanges = (_a = {},
                        _a[entityUri] = __spreadArray(__spreadArray([], dcr.changes[entityUri], true), [
                            {
                                attributePath: 'CountryCode',
                                attributeType: 'configuration/entityTypes/Company/attributes/CountryCode',
                                id: '41cb3c0i',
                                newValue: { value: 'Bahamas', lookupCode: 'BS', lookupRawValue: 'BS', pin: true },
                                type: DCRTypes.INSERT_ATTRIBUTE
                            },
                            {
                                attributePath: 'ActivationDate',
                                attributeType: 'configuration/entityTypes/Company/attributes/ActivationDate',
                                id: '41cb3t3k',
                                newValue: { value: '12.10.2011' },
                                type: DCRTypes.INSERT_ATTRIBUTE
                            },
                            {
                                attributePath: 'CountryCode/3AqlrpfGa',
                                attributeType: 'configuration/entityTypes/Company/attributes/CountryCode',
                                id: '41cb3gGy',
                                newValue: { value: 'Chile', lookupCode: 'CL', lookupRawValue: 'Chile', pin: true },
                                oldValue: { value: 'Chile', lookupCode: 'CL', lookupRawValue: 'Chile', pin: true },
                                type: DCRTypes.IGNORE_ATTRIBUTE
                            }
                        ], false),
                        _a);
                    dcrWithBigChanges = __assign(__assign({}, dcr), { changes: bigChanges });
                    getDataChangeRequest.mockResolvedValue(dcrWithBigChanges);
                    user = setUp().user;
                    return [4 /*yield*/, user.click(screen.getByTestId('collapse-button'))];
                case 1:
                    _b.sent();
                    expect(screen.getByText('Country Code')).toBeInTheDocument();
                    expect(screen.getByText('Bahamas (BS)')).toBeInTheDocument();
                    expect(screen.getByText('Activation Date')).toBeInTheDocument();
                    expect(screen.getByText('12.10.2011')).toBeInTheDocument();
                    expect(screen.getByText('Name')).toBeInTheDocument();
                    expect(screen.queryByText('Chile (CL)')).not.toBeInTheDocument();
                    return [4 /*yield*/, user.click(screen.getByText('View 1 more suggestions'))];
                case 2:
                    _b.sent();
                    expect(screen.getByText('Chile (CL)')).toBeInTheDocument();
                    return [4 /*yield*/, user.click(screen.getByText('View less suggestions'))];
                case 3:
                    _b.sent();
                    expect(screen.queryByText('Chile (CL)')).not.toBeInTheDocument();
                    return [2 /*return*/];
            }
        });
    }); });
    it('should not show Review DCR button when current entity is a new created entity by DCR', function () { return __awaiter(void 0, void 0, void 0, function () {
        var mdmValues;
        return __generator(this, function (_a) {
            mdmValues = __assign(__assign({}, mdmDefaultValues), { reviewDCREnabled: true, entity: { uri: "".concat(dcrUri, "/changes/").concat(entityUri) } });
            getDataChangeRequest.mockResolvedValue(dcr);
            setUp({ mdmValues: mdmValues });
            expect(screen.queryByRole('button', { name: 'Review DCR' })).not.toBeInTheDocument();
            return [2 /*return*/];
        });
    }); });
    it('should create correct link for new entity', function () { return __awaiter(void 0, void 0, void 0, function () {
        var changesWithNewEntity, dcrWithNewEntity, user, linkElement, href;
        var _a;
        return __generator(this, function (_b) {
            switch (_b.label) {
                case 0:
                    changesWithNewEntity = (_a = {},
                        _a[entityUri] = [
                            {
                                id: '3aMaA7ds',
                                type: DCRTypes.CREATE_ENTITY,
                                createdBy: 'alan.khugaev',
                                newValue: {
                                    uri: 'entities/1WNHTsJw',
                                    type: 'configuration/entityTypes/HCA',
                                    attributes: {
                                        CountryCode: [
                                            {
                                                value: 'Germany',
                                                lookupCode: 'DE',
                                                lookupRawValue: 'DE'
                                            }
                                        ],
                                        ActivationDate: [
                                            {
                                                value: '12.10.2011'
                                            }
                                        ]
                                    },
                                    isFavorite: false
                                }
                            }
                        ],
                        _a);
                    dcrWithNewEntity = __assign(__assign({}, dcr), { changes: changesWithNewEntity });
                    getDataChangeRequest.mockResolvedValue(dcrWithNewEntity);
                    user = setUp().user;
                    return [4 /*yield*/, user.click(screen.getByTestId('collapse-button'))];
                case 1:
                    _b.sent();
                    linkElement = screen.getByRole('link');
                    href = linkElement.getAttribute('href');
                    expect(href).toMatch(new RegExp("".concat(dcrUri, "/changes/").concat(entityUri, "$")));
                    return [2 /*return*/];
            }
        });
    }); });
    describe('Required comments', function () {
        it('should show comment dialog when user runs action and comment is required', function () { return __awaiter(void 0, void 0, void 0, function () {
            var task, user, dialog, comment, commentInput;
            return __generator(this, function (_a) {
                switch (_a.label) {
                    case 0:
                        task = __assign(__assign({}, defaultTask), { possibleActions: [
                                {
                                    action: 'Approve',
                                    label: 'Approve',
                                    commentRequired: true
                                },
                                {
                                    action: 'Reject',
                                    label: 'Reject',
                                    commentRequired: false
                                }
                            ] });
                        getDataChangeRequest.mockResolvedValue(dcr);
                        user = setUp({ task: task }).user;
                        return [4 /*yield*/, user.click(screen.getByTestId('task-actions'))];
                    case 1:
                        _a.sent();
                        return [4 /*yield*/, user.click(screen.getByText(task.possibleActions[0].label))];
                    case 2:
                        _a.sent();
                        expect(runTaskAction).not.toHaveBeenCalled();
                        dialog = screen.getAllByRole('presentation')[1];
                        expect(within(dialog).getByText('Please provide a comment for your action')).toBeInTheDocument();
                        expect(within(dialog).getByText('Type a comment')).toBeInTheDocument();
                        expect(within(dialog).getByText('Cancel')).toBeInTheDocument();
                        expect(within(dialog).getByText('Done')).toBeInTheDocument();
                        comment = 'Some comment';
                        commentInput = screen.getAllByRole('textbox')[0];
                        return [4 /*yield*/, user.click(commentInput)];
                    case 3:
                        _a.sent();
                        return [4 /*yield*/, user.paste(comment)];
                    case 4:
                        _a.sent();
                        return [4 /*yield*/, user.click(within(dialog).getByText('Done'))];
                    case 5:
                        _a.sent();
                        expect(screen.queryByText('Please provide a comment for your action')).not.toBeInTheDocument();
                        expect(runTaskAction).toHaveBeenCalledWith({
                            workflowPath: workflowPath,
                            environment: workflowEnvironmentUrl,
                            tenant: tenant.id,
                            taskId: task.taskId,
                            action: task.possibleActions[0].action,
                            processInstanceComment: comment
                        });
                        return [2 /*return*/];
                }
            });
        }); });
    });
});
