"use strict";
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 __importDefault = (this && this.__importDefault) || function (mod) {
    return (mod && mod.__esModule) ? mod : { "default": mod };
};
Object.defineProperty(exports, "__esModule", { value: true });
var react_1 = __importDefault(require("react"));
var react_2 = require("@testing-library/react");
var user_event_1 = __importDefault(require("@testing-library/user-event"));
var ramda_1 = require("ramda");
var AdapterMoment_1 = require("@mui/x-date-pickers/AdapterMoment");
var LocalizationProvider_1 = require("@mui/x-date-pickers/LocalizationProvider");
var mdm_sdk_1 = require("@reltio/mdm-sdk");
var ScrollToElementContext_1 = require("../contexts/ScrollToElementContext");
var MdmModuleContext_1 = require("../contexts/MdmModuleContext");
var HiddenAttributesContext_1 = require("../contexts/HiddenAttributesContext");
var RelationEditor_1 = __importDefault(require("./RelationEditor"));
jest.mock('@reltio/mdm-sdk', function () { return (__assign(__assign({}, jest.requireActual('@reltio/mdm-sdk')), { typeAheadSearch: jest.fn() })); });
var highlightError = jest.fn();
var scrollIntoRef = jest.fn();
var mdmAction = jest.fn();
var mdmActions = {
    setInitialInfo: jest.fn(function () { return mdmAction(); }),
    setRelationType: jest.fn(function () { return mdmAction(); }),
    closeRelationEditor: jest.fn(function () { return mdmAction(); }),
    entityCreated: jest.fn(function () { return mdmAction(); }),
    entityDeleted: jest.fn(function () { return mdmAction(); }),
    setRelationEntity: jest.fn(function () { return mdmAction(); }),
    errorDeactivated: jest.fn(function () { return mdmAction(); }),
    errorsSet: jest.fn(function () { return mdmAction(); }),
    addAttributes: jest.fn(function () { return mdmAction(); }),
    modifyAttribute: jest.fn(function () { return mdmAction(); }),
    removeAttribute: jest.fn(function () { return mdmAction(); }),
    addRelation: jest.fn(function (_id, _connection) { return mdmAction(); }),
    editRelation: jest.fn(function (_id, _connection) { return mdmAction(); })
};
var defaultRelation = {
    relationUri: 'relations/uri$$Qgs4qfvmR3Daksyb1697627670006',
    relationType: 'configuration/relationTypes/HasAddress',
    relationLabel: 'has address',
    object: {
        type: 'configuration/relationTypes/HasAddress',
        attributes: {},
        uri: 'relations/uri$$Qgs4qfvmR3Daksyb1697627670006'
    },
    direction: 'out'
};
var defaultEntity = {
    uri: 'entities/uri$$123',
    type: 'configuration/entityTypes/HCP',
    attributes: {}
};
var defaultMdmValues = {
    relations: {},
    modifiedEntities: {},
    entity: defaultEntity,
    dependentLookups: { editors: {}, structure: {}, initedTypeUris: [] },
    uiConfigLayout: [],
    uiConfigProfile: [],
    profileErrors: [],
    showMasking: true
};
var defaultProps = {
    connection: { relation: defaultRelation, entity: {} },
    config: {
        id: 'relationView',
        component: mdm_sdk_1.ProfileViewType.Relations,
        content: {
            entityTypes: ['configuration/entityTypes/Location'],
            outRelations: [{ uri: 'configuration/relationTypes/HasAddress', label: '{directionalLabel}' }]
        }
    },
    metadata: {
        entityTypes: [
            {
                uri: 'configuration/entityTypes/HCP',
                label: 'HCP'
            },
            {
                uri: 'configuration/entityTypes/Location',
                label: 'Address',
                dataLabelPattern: '{FirstName}',
                attributes: [
                    {
                        uri: 'configuration/entityTypes/Location/attributes/FirstName',
                        type: 'String',
                        name: 'FirstName',
                        label: 'First Name'
                    },
                    {
                        uri: 'configuration/entityTypes/Location/attributes/Address',
                        type: 'Reference',
                        name: 'Address',
                        label: 'Address',
                        referencedAttributeURIs: []
                    }
                ]
            },
            {
                uri: 'configuration/entityTypes/HCA',
                label: 'HCA'
            }
        ],
        relationTypes: [
            {
                uri: 'configuration/relationTypes/HasAddress',
                label: 'has address',
                startObject: {
                    objectTypeURI: 'configuration/entityTypes/HCP',
                    uri: 'configuration/relationTypes/HasAddress/startObject'
                },
                endObject: {
                    objectTypeURI: 'configuration/entityTypes/Location',
                    uri: 'configuration/relationTypes/HasAddress/endObject'
                },
                attributes: [
                    {
                        label: 'ActiveHiddenAttribute',
                        name: 'Active',
                        type: 'Boolean',
                        uri: 'configuration/relationTypes/HasAddress/attributes/Active'
                    },
                    {
                        label: 'Name',
                        name: 'Name',
                        type: 'String',
                        uri: 'configuration/relationTypes/HasAddress/attributes/Name',
                        required: true
                    }
                ]
            },
            {
                uri: 'configuration/relationTypes/InternalHCAtoHCA',
                label: 'InternalHCAtoHCA affiliation',
                startObject: {
                    objectTypeURI: 'configuration/entityTypes/HCA',
                    uri: 'configuration/relationTypes/InternalHCAtoHCA/startObject'
                },
                endObject: {
                    objectTypeURI: 'configuration/entityTypes/HCA',
                    uri: 'configuration/relationTypes/InternalHCAtoHCA/endObject'
                },
                attributes: [
                    {
                        label: 'Title',
                        name: 'Title',
                        type: 'String',
                        uri: 'configuration/relationTypes/InternalHCAtoHCA/attributes/Title'
                    },
                    {
                        label: 'Affiliation Status',
                        name: 'AffiliationStatus',
                        type: 'String',
                        uri: 'configuration/relationTypes/InternalHCAtoHCA/attributes/AffiliationStatus'
                    }
                ]
            }
        ]
    },
    mode: mdm_sdk_1.Mode.Editing
};
var entityWithMasking = {
    uri: 'entities/uri$$123',
    type: 'configuration/entityTypes/HCP',
    object: {
        uri: 'entities/04B1CqH',
        type: 'configuration/entityTypes/Location',
        attributes: {
            Address: [
                {
                    label: 'AcOEvPaVqTfzZCE Josogaf VA',
                    relationshipLabel: '',
                    value: {
                        AddressLine1: [
                            {
                                type: 'configuration/entityTypes/Location/attributes/AddressLine1',
                                ov: true,
                                value: 'AcOEvPaVqTfzZCE',
                                uri: 'entities/04B1CqH/attributes/Address/03R51aT/AddressLine1/1XFBcmPYm'
                            }
                        ],
                        AddressLine2: [
                            {
                                type: 'configuration/entityTypes/Location/attributes/AddressLine2',
                                ov: true,
                                masked: true,
                                value: 'KBmiSMlqhElLHMH',
                                uri: 'entities/04B1CqH/attributes/Address/03R51aT/AddressLine2/1XFBcmTp2'
                            }
                        ]
                    }
                }
            ]
        }
    }
};
var setUp = function (_a) {
    var _b = _a === void 0 ? {} : _a, _c = _b.props, props = _c === void 0 ? defaultProps : _c, _d = _b.mdmValues, mdmValues = _d === void 0 ? defaultMdmValues : _d, _e = _b.error, error = _e === void 0 ? null : _e, _f = _b.hiddenAttributes, hiddenAttributes = _f === void 0 ? {} : _f;
    var user = user_event_1.default.setup();
    var Providers = function (_a) {
        var children = _a.children;
        return (react_1.default.createElement(HiddenAttributesContext_1.HiddenAttributesContext.Provider, { value: hiddenAttributes },
            react_1.default.createElement(ScrollToElementContext_1.ScrollToElementContext.Provider, { value: { element: error, highlightError: highlightError, scrollIntoRef: scrollIntoRef, type: ScrollToElementContext_1.ScrollType.Error } },
                react_1.default.createElement(LocalizationProvider_1.LocalizationProvider, { dateAdapter: AdapterMoment_1.AdapterMoment }, children))));
    };
    var result = (0, react_2.render)(react_1.default.createElement(MdmModuleContext_1.MdmModuleProvider, { actions: mdmActions, values: mdmValues },
        react_1.default.createElement(RelationEditor_1.default, __assign({}, props))), { wrapper: Providers });
    var rerender = function (_a) {
        var newProps = _a.props, newMdmValues = _a.mdmValues;
        return result.rerender(react_1.default.createElement(MdmModuleContext_1.MdmModuleProvider, { actions: mdmActions, values: __assign(__assign({}, mdmValues), newMdmValues) },
            react_1.default.createElement(RelationEditor_1.default, __assign({}, props, newProps))));
    };
    return __assign(__assign({}, result), { user: user, rerender: rerender });
};
describe('relation editor behaviour', function () {
    beforeEach(function () {
        mdm_sdk_1.typeAheadSearch.mockResolvedValue([]);
    });
    afterEach(function () {
        jest.clearAllMocks();
    });
    it('should render entity selector correctly', function () { return __awaiter(void 0, void 0, void 0, function () {
        var activityFilter, searchOptions, mdmValues, user, options;
        return __generator(this, function (_a) {
            switch (_a.label) {
                case 0:
                    mdm_sdk_1.typeAheadSearch.mockResolvedValue([
                        { type: 'configuration/entityTypes/Location', label: 'location entity 1', uri: 'entities/0C32GxR' },
                        { type: 'configuration/entityTypes/Location', label: 'location entity 2', uri: 'entities/0G49Cnu' }
                    ]);
                    activityFilter = mdm_sdk_1.ActivityFilter.ACTIVE_ONLY;
                    searchOptions = { searchByOv: true, ovOnly: true };
                    mdmValues = __assign(__assign({}, defaultMdmValues), { activityFilter: activityFilter, searchOptions: searchOptions });
                    user = setUp({ mdmValues: mdmValues }).user;
                    react_2.screen.getByText('Select Address profile');
                    react_2.screen.getByRole('combobox');
                    return [4 /*yield*/, user.click(react_2.screen.getByTestId('select-dropdown-indicator'))];
                case 1:
                    _a.sent();
                    options = react_2.screen.getAllByRole('option');
                    expect(options).toHaveLength(2);
                    expect(options[0]).toHaveTextContent('location entity 1');
                    expect(options[1]).toHaveTextContent('location entity 2');
                    expect(mdm_sdk_1.typeAheadSearch).toHaveBeenCalledWith([defaultProps.metadata.entityTypes[1]], '', {
                        activityFilter: 'active',
                        globalFilter: '',
                        max: 20,
                        searchOptions: 'searchByOv',
                        sendMasked: false
                    });
                    return [2 /*return*/];
            }
        });
    }); });
    it('should render attributes list correctly', function () { return __awaiter(void 0, void 0, void 0, function () {
        var labels, values;
        return __generator(this, function (_a) {
            switch (_a.label) {
                case 0:
                    setUp();
                    return [4 /*yield*/, react_2.screen.findByText('More attributes')];
                case 1:
                    _a.sent();
                    labels = react_2.screen.getAllByTestId('reltio-attribute-label');
                    values = react_2.screen.getAllByTestId('reltio-attribute-value');
                    expect(labels).toHaveLength(4);
                    expect(values).toHaveLength(4);
                    expect(labels[0]).toHaveTextContent('Start date');
                    expect((0, react_2.within)(values[0]).getByRole('textbox')).toHaveValue('');
                    expect(labels[1]).toHaveTextContent('End date');
                    expect((0, react_2.within)(values[1]).getByRole('textbox')).toHaveValue('');
                    expect(labels[2]).toHaveTextContent('ActiveHiddenAttribute');
                    expect((0, react_2.within)(values[2]).getAllByRole('checkbox')[0]).not.toBeChecked();
                    expect((0, react_2.within)(values[2]).getAllByRole('checkbox')[1]).not.toBeChecked();
                    expect(labels[3]).toHaveTextContent('Name*');
                    expect((0, react_2.within)(values[3]).getByRole('textbox')).toHaveValue('');
                    return [2 /*return*/];
            }
        });
    }); });
    it('should render label correctly', function () { return __awaiter(void 0, void 0, void 0, function () {
        return __generator(this, function (_a) {
            switch (_a.label) {
                case 0:
                    setUp();
                    return [4 /*yield*/, react_2.screen.findByText('Edit item')];
                case 1:
                    _a.sent();
                    return [2 /*return*/];
            }
        });
    }); });
    it('should label for new connection correctly', function () { return __awaiter(void 0, void 0, void 0, function () {
        var connection, props;
        return __generator(this, function (_a) {
            switch (_a.label) {
                case 0:
                    connection = __assign(__assign({}, defaultProps.connection), { isNew: true });
                    props = __assign(__assign({}, defaultProps), { connection: connection });
                    setUp({ props: props });
                    return [4 /*yield*/, react_2.screen.findByText('Add new item')];
                case 1:
                    _a.sent();
                    return [2 /*return*/];
            }
        });
    }); });
    it('should render correctly if parentEntityUri and contentSecondLevel exists', function () { return __awaiter(void 0, void 0, void 0, function () {
        var connection, config, props;
        return __generator(this, function (_a) {
            switch (_a.label) {
                case 0:
                    connection = __assign(__assign({}, defaultProps.connection), { parentEntityUri: 'entities/HsPM72G' });
                    config = __assign(__assign({}, defaultProps.config), { contentSecondLevel: {
                            entityTypes: ['configuration/entityTypes/HCA'],
                            outRelations: [{ uri: 'configuration/relationTypes/InternalHCAtoHCA', label: '{directionalLabel}' }]
                        } });
                    props = __assign(__assign({}, defaultProps), { connection: connection, config: config });
                    setUp({ props: props });
                    return [4 /*yield*/, react_2.screen.findByText('Select HCA profile')];
                case 1:
                    _a.sent();
                    return [2 /*return*/];
            }
        });
    }); });
    it('should show error for entity selector correctly', function () { return __awaiter(void 0, void 0, void 0, function () {
        var profileErrors, mdmValues, errorMessage;
        return __generator(this, function (_a) {
            switch (_a.label) {
                case 0:
                    profileErrors = [
                        {
                            parentUri: 'relations/11',
                            uri: '',
                            attributeTypeUri: defaultRelation.relationType,
                            message: 'Entity is required',
                            deactivated: true,
                            type: mdm_sdk_1.ErrorType.missedRefEntity
                        },
                        {
                            parentUri: defaultRelation.relationUri,
                            uri: '',
                            attributeTypeUri: defaultRelation.relationType,
                            message: 'Entity is required - deactivated',
                            deactivated: true,
                            type: mdm_sdk_1.ErrorType.missedRefEntity
                        },
                        {
                            parentUri: defaultRelation.relationUri,
                            uri: '',
                            attributeTypeUri: defaultRelation.relationType,
                            message: 'Entity is required',
                            type: mdm_sdk_1.ErrorType.missedRefEntity
                        }
                    ];
                    mdmValues = __assign(__assign({}, defaultMdmValues), { profileErrors: profileErrors });
                    setUp({ mdmValues: mdmValues });
                    return [4 /*yield*/, react_2.screen.findByTestId('error-message')];
                case 1:
                    errorMessage = _a.sent();
                    expect(errorMessage).toHaveTextContent('Entity is required');
                    return [2 /*return*/];
            }
        });
    }); });
    it('should render relation type selector correctly if it is not possible to evaluate default relation type', function () { return __awaiter(void 0, void 0, void 0, function () {
        var config, props, user, relationTypeSelector, options;
        return __generator(this, function (_a) {
            switch (_a.label) {
                case 0:
                    config = __assign(__assign({}, defaultProps.config), { content: {
                            entityTypes: ['configuration/entityTypes/Location'],
                            inRelations: [{ uri: 'configuration/relationTypes/InternalHCAtoHCA', label: '{directionalLabel}' }],
                            outRelations: [{ uri: 'configuration/relationTypes/HasAddress', label: '{directionalLabel}' }]
                        } });
                    props = __assign(__assign({}, defaultProps), { config: config });
                    user = setUp({ props: props }).user;
                    relationTypeSelector = react_2.screen.getByTestId('relation-type-selector');
                    (0, react_2.within)(relationTypeSelector).getByText('Select relationship type');
                    (0, react_2.within)(relationTypeSelector).getByText('has address');
                    (0, react_2.within)(relationTypeSelector).getByRole('combobox');
                    return [4 /*yield*/, user.click((0, react_2.within)(relationTypeSelector).getByTestId('select-dropdown-indicator'))];
                case 1:
                    _a.sent();
                    options = react_2.screen.getAllByRole('option');
                    expect(options).toHaveLength(2);
                    expect(options[0]).toHaveTextContent('InternalHCAtoHCA affiliation');
                    expect(options[1]).toHaveTextContent('has address');
                    return [2 /*return*/];
            }
        });
    }); });
    it('should dispatch setRelationType action on relation type selector change', function () { return __awaiter(void 0, void 0, void 0, function () {
        var config, props, user;
        return __generator(this, function (_a) {
            switch (_a.label) {
                case 0:
                    config = __assign(__assign({}, defaultProps.config), { content: {
                            entityTypes: ['configuration/entityTypes/Location'],
                            inRelations: [{ uri: 'configuration/relationTypes/InternalHCAtoHCA', label: '{directionalLabel}' }],
                            outRelations: [{ uri: 'configuration/relationTypes/HasAddress', label: '{directionalLabel}' }]
                        } });
                    props = __assign(__assign({}, defaultProps), { config: config });
                    user = setUp({ props: props }).user;
                    return [4 /*yield*/, user.click((0, react_2.within)(react_2.screen.getByTestId('relation-type-selector')).getByTestId('select-dropdown-indicator'))];
                case 1:
                    _a.sent();
                    return [4 /*yield*/, user.click(react_2.screen.getByText('InternalHCAtoHCA affiliation'))];
                case 2:
                    _a.sent();
                    expect(mdmActions.setRelationType).toHaveBeenCalledWith(props.config.id, expect.any(String), {
                        direction: 'in',
                        type: __assign(__assign({}, defaultProps.metadata.relationTypes[1]), { endObject: __assign(__assign({}, defaultProps.metadata.relationTypes[1].endObject), { objectType: { label: 'HCA', uri: 'configuration/entityTypes/HCA' } }), startObject: __assign(__assign({}, defaultProps.metadata.relationTypes[1].startObject), { objectType: { label: 'HCA', uri: 'configuration/entityTypes/HCA' } }) })
                    });
                    return [2 /*return*/];
            }
        });
    }); });
    it('should show "create entity" button if mode is not suggesting', function () { return __awaiter(void 0, void 0, void 0, function () {
        var user, inputs;
        return __generator(this, function (_a) {
            switch (_a.label) {
                case 0:
                    user = setUp().user;
                    inputs = react_2.screen.getAllByRole('combobox');
                    return [4 /*yield*/, user.click(inputs[0])];
                case 1:
                    _a.sent();
                    expect(mdm_sdk_1.typeAheadSearch).toHaveBeenCalledWith([defaultProps.metadata.entityTypes[1]], '', {
                        globalFilter: '',
                        max: 20,
                        searchOptions: '',
                        sendMasked: false
                    });
                    react_2.screen.getByText('Create new Address');
                    return [2 /*return*/];
            }
        });
    }); });
    it('should hide create button when user lacks metadata permissions', function () { return __awaiter(void 0, void 0, void 0, function () {
        var props, user, inputs;
        return __generator(this, function (_a) {
            switch (_a.label) {
                case 0:
                    props = (0, ramda_1.assocPath)(['metadata', 'entityTypes', 1, 'access'], ['READ', 'UPDATE', 'INITIATE_CHANGE_REQUEST'], defaultProps);
                    user = setUp({ props: props }).user;
                    inputs = react_2.screen.getAllByRole('combobox');
                    return [4 /*yield*/, user.click(inputs[0])];
                case 1:
                    _a.sent();
                    expect(react_2.screen.queryByText('Create new Address')).not.toBeInTheDocument();
                    return [2 /*return*/];
            }
        });
    }); });
    it('should hide create button for one of the entity types when user lacks metadata permissions', function () { return __awaiter(void 0, void 0, void 0, function () {
        var props, user, inputs;
        return __generator(this, function (_a) {
            switch (_a.label) {
                case 0:
                    props = (0, ramda_1.pipe)((0, ramda_1.assocPath)(['metadata', 'entityTypes', 1, 'access'], ['READ', 'UPDATE', 'INITIATE_CHANGE_REQUEST']), (0, ramda_1.assocPath)(['config', 'content'], {
                        entityTypes: ['configuration/entityTypes/Location', 'configuration/entityTypes/HCA'],
                        outRelations: [
                            { uri: 'configuration/relationTypes/HasAddress', label: '{directionalLabel}' },
                            { uri: 'configuration/relationTypes/InternalHCAtoHCA', label: '{directionalLabel}' }
                        ]
                    }))(defaultProps);
                    user = setUp({ props: props }).user;
                    inputs = react_2.screen.getAllByRole('combobox');
                    return [4 /*yield*/, user.click(inputs[1])];
                case 1:
                    _a.sent();
                    expect(react_2.screen.queryByText('Create new Address')).not.toBeInTheDocument();
                    expect(react_2.screen.getByText('Create new HCA')).toBeInTheDocument();
                    return [2 /*return*/];
            }
        });
    }); });
    it('should show "create entity" button if mode is suggesting, but main entity uri is not temporary', function () { return __awaiter(void 0, void 0, void 0, function () {
        var props, mdmValues, user, inputs;
        return __generator(this, function (_a) {
            switch (_a.label) {
                case 0:
                    props = __assign(__assign({}, defaultProps), { mode: mdm_sdk_1.Mode.Suggesting });
                    mdmValues = __assign(__assign({}, defaultMdmValues), { entity: __assign(__assign({}, defaultEntity), { uri: 'entities/123' }) });
                    user = setUp({ props: props, mdmValues: mdmValues }).user;
                    inputs = react_2.screen.getAllByRole('combobox');
                    return [4 /*yield*/, user.click(inputs[0])];
                case 1:
                    _a.sent();
                    react_2.screen.getByText('Create new Address');
                    return [2 /*return*/];
            }
        });
    }); });
    it('should show "create entity" button if mode is suggesting, main entity uri is temporary, but authoring mode is enabled for current entity type', function () { return __awaiter(void 0, void 0, void 0, function () {
        var uiConfigProfile, props, mdmValues, user, inputs;
        return __generator(this, function (_a) {
            switch (_a.label) {
                case 0:
                    uiConfigProfile = [
                        {
                            label: 'Profile',
                            id: 'com.reltio.plugins.ProfileEntityAction',
                            class: mdm_sdk_1.ScreenType.Profile,
                            entityTypes: {
                                'configuration/entityTypes/HCP': {
                                    views: [],
                                    layout: [],
                                    sidePanelViews: [],
                                    authoring: [{ label: 'Profile details', views: [], layout: [] }]
                                }
                            }
                        }
                    ];
                    props = __assign(__assign({}, defaultProps), { mode: mdm_sdk_1.Mode.Suggesting });
                    mdmValues = __assign(__assign({}, defaultMdmValues), { uiConfigProfile: uiConfigProfile });
                    user = setUp({ props: props, mdmValues: mdmValues }).user;
                    inputs = react_2.screen.getAllByRole('combobox');
                    return [4 /*yield*/, user.click(inputs[0])];
                case 1:
                    _a.sent();
                    react_2.screen.getByText('Create new Address');
                    return [2 /*return*/];
            }
        });
    }); });
    it('should not show "create entity" button if mode is "Suggesting", main entity uri is temporary and authoring mode is not enabled for current entity type', function () { return __awaiter(void 0, void 0, void 0, function () {
        var props, user, inputs;
        return __generator(this, function (_a) {
            switch (_a.label) {
                case 0:
                    props = __assign(__assign({}, defaultProps), { mode: mdm_sdk_1.Mode.Suggesting });
                    user = setUp({ props: props }).user;
                    inputs = react_2.screen.getAllByRole('combobox');
                    return [4 /*yield*/, user.click(inputs[0])];
                case 1:
                    _a.sent();
                    expect(react_2.screen.queryByText('Create new Address')).not.toBeInTheDocument();
                    return [2 /*return*/];
            }
        });
    }); });
    it('should not hide hidden attributes', function () { return __awaiter(void 0, void 0, void 0, function () {
        var hiddenAttributes, user, inputs;
        return __generator(this, function (_a) {
            switch (_a.label) {
                case 0:
                    hiddenAttributes = { 'entities/uri$$123': ['configuration/relationTypes/HasAddress/attributes/Active'] };
                    user = setUp({ hiddenAttributes: hiddenAttributes }).user;
                    inputs = react_2.screen.getAllByRole('combobox');
                    return [4 /*yield*/, user.click(inputs[0])];
                case 1:
                    _a.sent();
                    expect(react_2.screen.getByText('ActiveHiddenAttribute')).toBeInTheDocument();
                    return [2 /*return*/];
            }
        });
    }); });
    it('should add sendMasked option if connection entity has attribute with masked value', function () { return __awaiter(void 0, void 0, void 0, function () {
        var props, user, inputs;
        return __generator(this, function (_a) {
            switch (_a.label) {
                case 0:
                    props = __assign(__assign({}, defaultProps), { connection: {
                            relation: defaultRelation,
                            entity: entityWithMasking
                        } });
                    user = setUp({ props: props }).user;
                    inputs = react_2.screen.getAllByRole('textbox');
                    return [4 /*yield*/, user.click(inputs[0])];
                case 1:
                    _a.sent();
                    expect(mdm_sdk_1.typeAheadSearch).toHaveBeenCalledWith([defaultProps.metadata.entityTypes[1]], '', {
                        globalFilter: '',
                        max: 20,
                        searchOptions: '',
                        sendMasked: true
                    });
                    return [2 /*return*/];
            }
        });
    }); });
    it('should not add sendMasked option if configuration showMasking property is false', function () { return __awaiter(void 0, void 0, void 0, function () {
        var props, mdmValues, user, inputs;
        return __generator(this, function (_a) {
            switch (_a.label) {
                case 0:
                    props = __assign(__assign({}, defaultProps), { connection: {
                            relation: defaultRelation,
                            entity: entityWithMasking
                        } });
                    mdmValues = __assign(__assign({}, defaultMdmValues), { showMasking: false });
                    user = setUp({ props: props, mdmValues: mdmValues }).user;
                    inputs = react_2.screen.getAllByRole('textbox');
                    return [4 /*yield*/, user.click(inputs[0])];
                case 1:
                    _a.sent();
                    expect(mdm_sdk_1.typeAheadSearch).toHaveBeenCalledWith([defaultProps.metadata.entityTypes[1]], '', {
                        globalFilter: '',
                        max: 20,
                        searchOptions: '',
                        sendMasked: false
                    });
                    return [2 /*return*/];
            }
        });
    }); });
    describe('apply button', function () {
        var createRelation = function (value) { return (__assign(__assign({}, defaultProps.connection.relation), { object: __assign(__assign({}, defaultProps.connection.relation.object), { attributes: {
                    Name: [
                        {
                            uri: 'relations/uri$$Qgs4qfvmR3Daksyb1697627670006/attributes/Name/uri$$jIo2A6VSD',
                            type: 'configuration/relationTypes/HasAddress/attributes/Name',
                            value: value
                        }
                    ]
                } }) })); };
        var createEntity = function (uri) { return ({
            entityUri: uri,
            entityType: 'configuration/entityTypes/Location',
            entityLabel: 'location entity',
            object: { uri: uri, type: 'configuration/entityTypes/Location', label: 'location entity' }
        }); };
        it('should be disables for new connections with added default values', function () { return __awaiter(void 0, void 0, void 0, function () {
            var connection, props, applyButton;
            return __generator(this, function (_a) {
                switch (_a.label) {
                    case 0:
                        connection = { relation: createRelation('name value'), entity: {}, isNew: true };
                        props = __assign(__assign({}, defaultProps), { connection: connection });
                        setUp({ props: props });
                        return [4 /*yield*/, react_2.screen.findByText('Apply')];
                    case 1:
                        applyButton = _a.sent();
                        expect(applyButton).toBeDisabled();
                        return [2 /*return*/];
                }
            });
        }); });
        it('should call addRelation action on Apply button click for new connections', function () { return __awaiter(void 0, void 0, void 0, function () {
            var entity, relation, connection, props, user;
            return __generator(this, function (_a) {
                switch (_a.label) {
                    case 0:
                        entity = createEntity('entities/0C32GxR');
                        relation = createRelation('new name value');
                        connection = __assign(__assign({}, defaultProps.connection), { relation: relation, entity: entity, isNew: true });
                        props = __assign(__assign({}, defaultProps), { connection: connection });
                        user = setUp({ props: props }).user;
                        return [4 /*yield*/, user.click(react_2.screen.getByText('Apply'))];
                    case 1:
                        _a.sent();
                        expect(mdmActions.addRelation).toHaveBeenCalledWith(props.config.id, connection);
                        expect(mdmActions.closeRelationEditor).toHaveBeenCalledWith(props.config.id, relation.relationUri);
                        return [2 /*return*/];
                }
            });
        }); });
        it('should not call addRelation action on Apply button if connection has validation errors', function () { return __awaiter(void 0, void 0, void 0, function () {
            var entity, relation, connection, props, user;
            return __generator(this, function (_a) {
                switch (_a.label) {
                    case 0:
                        entity = createEntity('entities/0C32GxR');
                        relation = createRelation('');
                        connection = __assign(__assign({}, defaultProps.connection), { relation: relation, entity: entity, isNew: true });
                        props = __assign(__assign({}, defaultProps), { connection: connection });
                        user = setUp({ props: props }).user;
                        return [4 /*yield*/, user.click(react_2.screen.getByText('Apply'))];
                    case 1:
                        _a.sent();
                        expect(mdmActions.addRelation).not.toHaveBeenCalled();
                        expect(mdmActions.errorsSet).toHaveBeenCalledWith([
                            {
                                attributeType: props.metadata.relationTypes[0].attributes[1],
                                attributeTypeUri: 'configuration/relationTypes/HasAddress/attributes/Name',
                                message: 'Attribute is required',
                                parentUri: connection.relation.relationUri,
                                path: [
                                    {
                                        label: 'location entity, has address',
                                        type: 'relationConnection',
                                        value: connection,
                                        valueType: props.metadata.relationTypes[0],
                                        viewId: props.config.id
                                    }
                                ],
                                source: mdm_sdk_1.ErrorSource.local,
                                type: mdm_sdk_1.ErrorType.missed,
                                uri: ''
                            }
                        ]);
                        expect(mdmActions.closeRelationEditor).not.toHaveBeenCalled();
                        return [2 /*return*/];
                }
            });
        }); });
        it('should call editRelation action on Apply button click for existing connections', function () { return __awaiter(void 0, void 0, void 0, function () {
            var entity, relation, connection, props, user;
            return __generator(this, function (_a) {
                switch (_a.label) {
                    case 0:
                        entity = createEntity('entities/0C32GxR');
                        relation = createRelation('new name value');
                        connection = __assign(__assign({}, defaultProps.connection), { relation: relation, entity: entity });
                        props = __assign(__assign({}, defaultProps), { connection: connection });
                        user = setUp({ props: props }).user;
                        return [4 /*yield*/, user.click(react_2.screen.getByText('Apply'))];
                    case 1:
                        _a.sent();
                        expect(mdmActions.editRelation).toHaveBeenCalledWith(props.config.id, connection);
                        expect(mdmActions.closeRelationEditor).toHaveBeenCalledWith(props.config.id, relation.relationUri);
                        return [2 /*return*/];
                }
            });
        }); });
        it('should not call editRelation action on Apply button click if connection has validation errors', function () { return __awaiter(void 0, void 0, void 0, function () {
            var entity, relation, connection, props, user;
            return __generator(this, function (_a) {
                switch (_a.label) {
                    case 0:
                        entity = createEntity('entities/0C32GxR');
                        relation = createRelation('');
                        connection = __assign(__assign({}, defaultProps.connection), { relation: relation, entity: entity });
                        props = __assign(__assign({}, defaultProps), { connection: connection });
                        user = setUp({ props: props }).user;
                        return [4 /*yield*/, user.click(react_2.screen.getByText('Apply'))];
                    case 1:
                        _a.sent();
                        expect(mdmActions.editRelation).not.toHaveBeenCalled();
                        expect(mdmActions.errorsSet).toHaveBeenCalledWith([
                            {
                                attributeType: props.metadata.relationTypes[0].attributes[1],
                                attributeTypeUri: 'configuration/relationTypes/HasAddress/attributes/Name',
                                message: 'Attribute is required',
                                parentUri: connection.relation.relationUri,
                                path: [
                                    {
                                        label: 'location entity, has address',
                                        type: 'relationConnection',
                                        value: connection,
                                        valueType: props.metadata.relationTypes[0],
                                        viewId: props.config.id
                                    }
                                ],
                                source: mdm_sdk_1.ErrorSource.local,
                                type: mdm_sdk_1.ErrorType.missed,
                                uri: ''
                            }
                        ]);
                        expect(mdmActions.closeRelationEditor).not.toHaveBeenCalled();
                        return [2 /*return*/];
                }
            });
        }); });
        it('should evaluate and update connection entity label if modified entity is specified', function () { return __awaiter(void 0, void 0, void 0, function () {
            var entityUri, entity, relation, connection, modifiedEntity, props, mdmValues, user;
            var _a;
            return __generator(this, function (_b) {
                switch (_b.label) {
                    case 0:
                        entityUri = 'entities/uri$$kAp2KJM8';
                        entity = createEntity(entityUri);
                        relation = createRelation('new name value');
                        connection = __assign(__assign({}, defaultProps.connection), { relation: relation, entity: entity });
                        modifiedEntity = {
                            type: 'configuration/entityTypes/Location',
                            uri: entityUri,
                            attributes: {
                                FirstName: [
                                    {
                                        uri: 'entities/uri$$kAp2KJM8/attributes/FirstName/uri$$wsbN3s0X',
                                        type: 'configuration/entityTypes/Location/attributes/FirstName',
                                        value: 'first name value'
                                    }
                                ]
                            }
                        };
                        props = __assign(__assign({}, defaultProps), { connection: connection });
                        mdmValues = __assign(__assign({}, defaultMdmValues), { modifiedEntities: (_a = {}, _a[entityUri] = modifiedEntity, _a) });
                        user = setUp({ mdmValues: mdmValues, props: props }).user;
                        return [4 /*yield*/, user.click(react_2.screen.getByText('Apply'))];
                    case 1:
                        _b.sent();
                        expect(mdmActions.editRelation).toHaveBeenCalledWith(props.config.id, {
                            entity: __assign(__assign({}, entity), { entityLabel: 'first name value', object: __assign(__assign({}, entity.object), { label: 'first name value' }) }),
                            relation: relation
                        });
                        expect(mdmActions.closeRelationEditor).toHaveBeenCalledWith(props.config.id, relation.relationUri);
                        return [2 /*return*/];
                }
            });
        }); });
        it('should clean up outdated temp modified entities', function () { return __awaiter(void 0, void 0, void 0, function () {
            var entityUri, entity, relation, connection, modifiedEntities, props, mdmValues, _a, user, rerender, updatedModifiedEntities, updatedEntity, updatedConnection;
            var _b;
            return __generator(this, function (_c) {
                switch (_c.label) {
                    case 0:
                        entityUri = 'entities/uri$$kAp2KJM8';
                        entity = createEntity(entityUri);
                        relation = createRelation('new name value');
                        connection = __assign(__assign({}, defaultProps.connection), { relation: relation, entity: entity });
                        modifiedEntities = (_b = {},
                            _b[entityUri] = {
                                type: 'configuration/entityTypes/Location',
                                uri: entityUri,
                                attributes: {
                                    Address: [
                                        {
                                            refEntity: [{ objectURI: 'entities/uri$$kLnBs782' }],
                                            refRelation: null,
                                            uri: 'entities/uri$$kAp2KJM8/attributes/Address/uri$$nbsAsD',
                                            value: {},
                                            relationshipLabel: '',
                                            startObjectCrosswalks: []
                                        },
                                        {
                                            refEntity: [{ objectURI: 'entities/uri$$bAWp0mnS' }],
                                            refRelation: null,
                                            uri: 'entities/uri$$kAp2KJM8/attributes/Address/uri$$nSplKs321',
                                            value: {},
                                            relationshipLabel: '',
                                            startObjectCrosswalks: []
                                        }
                                    ]
                                }
                            },
                            _b['entities/uri$$kLnBs782'] = {
                                type: 'configuration/entityTypes/Location',
                                uri: 'entities/uri$$kLnBs782',
                                attributes: {
                                    Address: [
                                        {
                                            refEntity: [
                                                {
                                                    objectURI: 'entities/uri$$ks0PsMA'
                                                }
                                            ],
                                            refRelation: null,
                                            uri: 'entities/uri$$kLnBs782/attributes/Address/uri$$o23NbsDA',
                                            value: {},
                                            relationshipLabel: '',
                                            startObjectCrosswalks: []
                                        }
                                    ]
                                }
                            },
                            _b['entities/uri$$bAWp0mnS'] = {
                                uri: 'entities/uri$$bAWp0mnS',
                                type: 'configuration/entityTypes/HCP'
                            },
                            _b['entities/uri$$ks0PsMA'] = {
                                uri: 'entities/uri$$ks0PsMA',
                                type: 'configuration/entityTypes/HCP'
                            },
                            _b['entities/uri$$MsS01sDA'] = {
                                uri: 'entities/uri$$MsS01sDA',
                                type: 'configuration/entityTypes/HCP'
                            },
                            _b);
                        props = __assign(__assign({}, defaultProps), { connection: connection });
                        mdmValues = __assign(__assign({}, defaultMdmValues), { modifiedEntities: modifiedEntities });
                        _a = setUp({ mdmValues: mdmValues, props: props }), user = _a.user, rerender = _a.rerender;
                        updatedModifiedEntities = __assign(__assign({}, modifiedEntities), { 'entities/uri$$jSdsAA32': {
                                uri: 'entities/uri$$jSdsAA32',
                                type: 'configuration/entityTypes/Location',
                                attributes: {}
                            } });
                        updatedEntity = createEntity('entities/uri$$jSdsAA32');
                        updatedConnection = __assign(__assign({}, connection), { entity: updatedEntity });
                        rerender({
                            mdmValues: __assign(__assign({}, mdmValues), { modifiedEntities: updatedModifiedEntities }),
                            props: __assign(__assign({}, props), { connection: updatedConnection })
                        });
                        return [4 /*yield*/, user.click(react_2.screen.getByText('Apply'))];
                    case 1:
                        _c.sent();
                        expect(mdmActions.editRelation).toHaveBeenCalledWith(props.config.id, __assign(__assign({}, connection), { entity: __assign(__assign({}, updatedEntity), { entityLabel: '', object: __assign(__assign({}, updatedEntity.object), { label: '' }) }) }));
                        expect(mdmActions.closeRelationEditor).toHaveBeenCalledWith(props.config.id, relation.relationUri);
                        expect(mdmActions.entityDeleted).toHaveBeenCalledWith('entities/uri$$kLnBs782');
                        expect(mdmActions.entityDeleted).toHaveBeenCalledWith('entities/uri$$bAWp0mnS');
                        expect(mdmActions.entityDeleted).toHaveBeenCalledWith('entities/uri$$ks0PsMA');
                        expect(mdmActions.entityDeleted).not.toHaveBeenCalledWith('entities/uri$$MsS01sDA');
                        return [2 /*return*/];
                }
            });
        }); });
        it('should disable apply button if modified entity and connection was not changed', function () { return __awaiter(void 0, void 0, void 0, function () {
            var entityUri, entity, relation, modifiedEntity, connection, mdmConnection, props, mdmValues, applyButton;
            var _a, _b;
            return __generator(this, function (_c) {
                switch (_c.label) {
                    case 0:
                        entityUri = 'entities/uri$$kAp2KJM8';
                        entity = createEntity(entityUri);
                        relation = createRelation('name value');
                        modifiedEntity = {
                            type: 'configuration/entityTypes/Location',
                            uri: entityUri,
                            attributes: {
                                FirstName: [
                                    {
                                        uri: 'entities/uri$$kAp2KJM8/attributes/FirstName/uri$$wsbN3s0X',
                                        type: 'configuration/entityTypes/Location/attributes/FirstName',
                                        value: 'first name value'
                                    }
                                ]
                            }
                        };
                        connection = __assign(__assign({}, defaultProps.connection), { relation: relation, entity: entity, isNew: true });
                        mdmConnection = __assign(__assign({}, defaultProps.connection), { relation: relation, entity: entity, initial: { modifiedEntity: modifiedEntity, connection: connection } });
                        props = __assign(__assign({}, defaultProps), { connection: connection });
                        mdmValues = __assign(__assign({}, defaultMdmValues), { relations: (_a = {}, _a[props.config.id] = { relationsToEdit: [mdmConnection] }, _a), modifiedEntities: (_b = {}, _b[entityUri] = modifiedEntity, _b) });
                        setUp({ props: props, mdmValues: mdmValues });
                        return [4 /*yield*/, react_2.screen.findByText('Apply')];
                    case 1:
                        applyButton = _c.sent();
                        expect(applyButton).toBeDisabled();
                        return [2 /*return*/];
                }
            });
        }); });
        it('should enable apply button if modified entity was changed', function () { return __awaiter(void 0, void 0, void 0, function () {
            var createModifiedEntity, entityUri, entity, relation, connection, mdmConnection, props, mdmValues, applyButton;
            var _a, _b;
            return __generator(this, function (_c) {
                switch (_c.label) {
                    case 0:
                        createModifiedEntity = function (value) { return ({
                            type: 'configuration/entityTypes/Location',
                            uri: entityUri,
                            attributes: {
                                FirstName: [
                                    {
                                        uri: 'entities/uri$$kAp2KJM8/attributes/FirstName/uri$$wsbN3s0X',
                                        type: 'configuration/entityTypes/Location/attributes/FirstName',
                                        value: value
                                    }
                                ]
                            }
                        }); };
                        entityUri = 'entities/uri$$kAp2KJM8';
                        entity = createEntity(entityUri);
                        relation = createRelation('name value');
                        connection = __assign(__assign({}, defaultProps.connection), { relation: relation, entity: entity, isNew: true });
                        mdmConnection = __assign(__assign({}, defaultProps.connection), { relation: relation, entity: entity, initial: { modifiedEntity: createModifiedEntity('initial first name'), connection: connection } });
                        props = __assign(__assign({}, defaultProps), { connection: connection });
                        mdmValues = __assign(__assign({}, defaultMdmValues), { relations: (_a = {}, _a[props.config.id] = { relationsToEdit: [mdmConnection] }, _a), modifiedEntities: (_b = {}, _b[entityUri] = createModifiedEntity('changed first name'), _b) });
                        setUp({ props: props, mdmValues: mdmValues });
                        return [4 /*yield*/, react_2.screen.findByText('Apply')];
                    case 1:
                        applyButton = _c.sent();
                        expect(applyButton).not.toBeDisabled();
                        return [2 /*return*/];
                }
            });
        }); });
        it('should enable apply button if connection was changed', function () { return __awaiter(void 0, void 0, void 0, function () {
            var entityUri, entity, relation, modifiedEntity, connection, mdmConnection, props, mdmValues, applyButton;
            var _a, _b;
            return __generator(this, function (_c) {
                switch (_c.label) {
                    case 0:
                        entityUri = 'entities/uri$$kAp2KJM8';
                        entity = createEntity(entityUri);
                        relation = createRelation('name value');
                        modifiedEntity = {
                            type: 'configuration/entityTypes/Location',
                            uri: entityUri,
                            attributes: {
                                FirstName: [
                                    {
                                        uri: 'entities/uri$$kAp2KJM8/attributes/FirstName/uri$$wsbN3s0X',
                                        type: 'configuration/entityTypes/Location/attributes/FirstName',
                                        value: 'first name value'
                                    }
                                ]
                            }
                        };
                        connection = __assign(__assign({}, defaultProps.connection), { relation: relation, entity: entity, isNew: true });
                        mdmConnection = __assign(__assign({}, defaultProps.connection), { relation: relation, entity: entity, initial: { modifiedEntity: modifiedEntity, connection: __assign(__assign({}, connection), { relation: createRelation('changed name value') }) } });
                        props = __assign(__assign({}, defaultProps), { connection: connection });
                        mdmValues = __assign(__assign({}, defaultMdmValues), { relations: (_a = {}, _a[props.config.id] = { relationsToEdit: [mdmConnection] }, _a), modifiedEntities: (_b = {}, _b[entityUri] = modifiedEntity, _b) });
                        setUp({ props: props, mdmValues: mdmValues });
                        return [4 /*yield*/, react_2.screen.findByText('Apply')];
                    case 1:
                        applyButton = _c.sent();
                        expect(applyButton).not.toBeDisabled();
                        return [2 /*return*/];
                }
            });
        }); });
        it('should enable apply button if some referenced entity related to modified entity was changed', function () { return __awaiter(void 0, void 0, void 0, function () {
            var entityUri, entity, relation, modifiedEntity, modifiedEntities, connection, mdmConnection, props, mdmValues, rerender, updatedModifiedEntities, applyButton;
            var _a, _b;
            return __generator(this, function (_c) {
                switch (_c.label) {
                    case 0:
                        entityUri = 'entities/uri$$kAp2KJM8';
                        entity = createEntity(entityUri);
                        relation = createRelation('name value');
                        modifiedEntity = {
                            type: 'configuration/entityTypes/Location',
                            uri: entityUri,
                            attributes: {
                                Address: [
                                    {
                                        refEntity: [{ objectURI: 'entities/uri$$kLnBs782' }],
                                        refRelation: null,
                                        uri: 'entities/uri$$kAp2KJM8/attributes/Address/uri$$nbsAsD',
                                        value: {},
                                        relationshipLabel: '',
                                        startObjectCrosswalks: []
                                    }
                                ]
                            }
                        };
                        modifiedEntities = (_a = {},
                            _a[entityUri] = modifiedEntity,
                            _a['entities/uri$$kLnBs782'] = {
                                uri: 'entities/uri$$MsS01sDA',
                                type: 'configuration/entityTypes/Location',
                                attributes: {
                                    FirstName: [
                                        {
                                            uri: 'entities/uri$$MsS01sDA/attributes/FirstName/uri$$jsNs01HO',
                                            type: 'configuration/entityTypes/Location/attributes/FirstName',
                                            value: 'initial first name value'
                                        }
                                    ]
                                }
                            },
                            _a);
                        connection = __assign(__assign({}, defaultProps.connection), { relation: relation, entity: entity, isNew: true });
                        mdmConnection = __assign(__assign({}, defaultProps.connection), { relation: relation, entity: entity, initial: { modifiedEntity: modifiedEntity, connection: connection } });
                        props = __assign(__assign({}, defaultProps), { connection: connection });
                        mdmValues = __assign(__assign({}, defaultMdmValues), { relations: (_b = {}, _b[props.config.id] = { relationsToEdit: [mdmConnection] }, _b), modifiedEntities: modifiedEntities });
                        rerender = setUp({ props: props, mdmValues: mdmValues }).rerender;
                        updatedModifiedEntities = __assign(__assign({}, modifiedEntities), { 'entities/uri$$kLnBs782': {
                                uri: 'entities/uri$$MsS01sDA',
                                type: 'configuration/entityTypes/Location',
                                attributes: {
                                    FirstName: [
                                        {
                                            uri: 'entities/uri$$MsS01sDA/attributes/FirstName/uri$$jsNs01HO',
                                            type: 'configuration/entityTypes/Location/attributes/FirstName',
                                            value: 'changed first name value'
                                        }
                                    ]
                                }
                            } });
                        rerender({ mdmValues: __assign(__assign({}, mdmValues), { modifiedEntities: updatedModifiedEntities }) });
                        return [4 /*yield*/, react_2.screen.findByText('Apply')];
                    case 1:
                        applyButton = _c.sent();
                        expect(applyButton).not.toBeDisabled();
                        return [2 /*return*/];
                }
            });
        }); });
    });
    describe('cancel button', function () {
        it('should call closeRelationEditor action and remove related errors', function () { return __awaiter(void 0, void 0, void 0, function () {
            var profileErrors, mdmValues, user;
            return __generator(this, function (_a) {
                switch (_a.label) {
                    case 0:
                        profileErrors = [
                            {
                                parentUri: 'relations/11',
                                uri: '',
                                attributeTypeUri: defaultRelation.relationType,
                                message: 'Entity is required',
                                deactivated: true,
                                type: mdm_sdk_1.ErrorType.missedRefEntity
                            },
                            {
                                parentUri: defaultRelation.relationUri,
                                uri: '',
                                attributeTypeUri: defaultRelation.relationType,
                                message: 'Entity is required - deactivated',
                                deactivated: true,
                                type: mdm_sdk_1.ErrorType.missedRefEntity
                            },
                            {
                                parentUri: defaultRelation.relationUri,
                                uri: '',
                                attributeTypeUri: defaultRelation.relationType,
                                message: 'Entity is required',
                                type: mdm_sdk_1.ErrorType.missedRefEntity
                            }
                        ];
                        mdmValues = __assign(__assign({}, defaultMdmValues), { profileErrors: profileErrors });
                        user = setUp({ mdmValues: mdmValues }).user;
                        return [4 /*yield*/, user.click(react_2.screen.getByText('Cancel'))];
                    case 1:
                        _a.sent();
                        expect(mdmActions.errorsSet).toHaveBeenCalledWith([
                            {
                                attributeTypeUri: defaultRelation.relationType,
                                deactivated: true,
                                message: 'Entity is required',
                                parentUri: 'relations/11',
                                type: mdm_sdk_1.ErrorType.missedRefEntity,
                                uri: ''
                            }
                        ]);
                        expect(mdmActions.closeRelationEditor).toHaveBeenCalledWith(defaultProps.config.id, defaultProps.connection.relation.relationUri);
                        expect(mdmAction).toHaveBeenCalledTimes(2);
                        return [2 /*return*/];
                }
            });
        }); });
        it('should delete modified entity if there was no entity initially but it was set after', function () { return __awaiter(void 0, void 0, void 0, function () {
            var entityUri, connection, modifiedEntity, props, mdmValues, user;
            var _a, _b;
            return __generator(this, function (_c) {
                switch (_c.label) {
                    case 0:
                        entityUri = 'entities/uri$$kAp2KJM8';
                        connection = __assign(__assign({}, defaultProps.connection), { entity: {
                                entityUri: entityUri,
                                entityType: 'configuration/entityTypes/Location',
                                entityLabel: 'location entity',
                                object: { uri: entityUri, type: 'configuration/entityTypes/Location', label: 'location entity' }
                            } });
                        modifiedEntity = { type: 'configuration/entityTypes/Location', uri: entityUri, attributes: {} };
                        props = __assign(__assign({}, defaultProps), { connection: connection });
                        mdmValues = __assign(__assign({}, defaultMdmValues), { relations: (_a = {},
                                _a[props.config.id] = {
                                    relationsToEdit: [__assign(__assign({}, defaultProps.connection), { initial: { connection: connection } })]
                                },
                                _a), modifiedEntities: (_b = {},
                                _b[entityUri] = modifiedEntity,
                                _b) });
                        user = setUp({ props: props, mdmValues: mdmValues }).user;
                        mdmAction.mockClear();
                        return [4 /*yield*/, user.click(react_2.screen.getByText('Cancel'))];
                    case 1:
                        _c.sent();
                        expect(mdmActions.entityDeleted).toHaveBeenCalledWith(entityUri);
                        expect(mdmActions.errorsSet).toHaveBeenCalledWith([]);
                        expect(mdmActions.closeRelationEditor).toHaveBeenCalledWith(props.config.id, connection.relation.relationUri);
                        expect(mdmAction).toHaveBeenCalledTimes(3);
                        return [2 /*return*/];
                }
            });
        }); });
        it('should restore modified entity to initial state if there was initial entity and it was changed/cleared', function () { return __awaiter(void 0, void 0, void 0, function () {
            var entityUri, modifiedEntity, relationToEdit, mdmValues, user;
            var _a;
            return __generator(this, function (_b) {
                switch (_b.label) {
                    case 0:
                        entityUri = 'entities/uri$$kAp2KJM8';
                        modifiedEntity = { type: 'configuration/entityTypes/Location', uri: entityUri, attributes: {} };
                        relationToEdit = __assign(__assign({}, defaultProps.connection), { initial: { connection: defaultProps.connection, modifiedEntity: modifiedEntity } });
                        mdmValues = __assign(__assign({}, defaultMdmValues), { relations: (_a = {}, _a[defaultProps.config.id] = { relationsToEdit: [relationToEdit] }, _a), modifiedEntities: {} });
                        user = setUp({ mdmValues: mdmValues }).user;
                        return [4 /*yield*/, user.click(react_2.screen.getByText('Cancel'))];
                    case 1:
                        _b.sent();
                        expect(mdmActions.entityCreated).toHaveBeenCalledWith(modifiedEntity);
                        expect(mdmActions.errorsSet).toHaveBeenCalledWith([]);
                        expect(mdmActions.closeRelationEditor).toHaveBeenCalledWith(defaultProps.config.id, defaultProps.connection.relation.relationUri);
                        expect(mdmAction).toHaveBeenCalledTimes(3);
                        return [2 /*return*/];
                }
            });
        }); });
        it('should restore initial modified entity if it was changed to another one (and delete new one)', function () { return __awaiter(void 0, void 0, void 0, function () {
            var entityUri, modifiedEntity, connection, relationToEdit, mdmValues, props, user;
            var _a;
            return __generator(this, function (_b) {
                switch (_b.label) {
                    case 0:
                        entityUri = 'entities/uri$$kAp2KJM8';
                        modifiedEntity = { type: 'configuration/entityTypes/Location', uri: entityUri, attributes: {} };
                        connection = __assign(__assign({}, defaultProps.connection), { entity: { entityUri: 'entities/uri$$7BhsS31L' } });
                        relationToEdit = __assign(__assign({}, connection), { initial: { connection: defaultProps.connection, modifiedEntity: modifiedEntity } });
                        mdmValues = __assign(__assign({}, defaultMdmValues), { relations: (_a = {}, _a[defaultProps.config.id] = { relationsToEdit: [relationToEdit] }, _a), modifiedEntities: { 'entities/uri$$7BhsS31L': __assign(__assign({}, modifiedEntity), { uri: 'entities/uri$$7BhsS31L' }) } });
                        props = __assign(__assign({}, defaultProps), { connection: connection });
                        user = setUp({ mdmValues: mdmValues, props: props }).user;
                        return [4 /*yield*/, user.click(react_2.screen.getByText('Cancel'))];
                    case 1:
                        _b.sent();
                        expect(mdmActions.entityCreated).toHaveBeenCalledWith(modifiedEntity);
                        expect(mdmActions.entityDeleted).toHaveBeenCalledWith('entities/uri$$7BhsS31L');
                        expect(mdmActions.errorsSet).toHaveBeenCalledWith([]);
                        expect(mdmActions.closeRelationEditor).toHaveBeenCalledWith(props.config.id, connection.relation.relationUri);
                        expect(mdmAction).toHaveBeenCalledTimes(4);
                        return [2 /*return*/];
                }
            });
        }); });
        it('should not call additional actions if modifiedEntity prop was not changed', function () { return __awaiter(void 0, void 0, void 0, function () {
            var entityUri, modifiedEntity, connection, relationToEdit, mdmValues, props, user;
            var _a, _b;
            return __generator(this, function (_c) {
                switch (_c.label) {
                    case 0:
                        entityUri = 'entities/uri$$kAp2KJM8';
                        modifiedEntity = { type: 'configuration/entityTypes/Location', uri: entityUri, attributes: {} };
                        connection = __assign(__assign({}, defaultProps.connection), { entity: { entityUri: entityUri } });
                        relationToEdit = __assign(__assign({}, connection), { initial: { connection: defaultProps.connection, modifiedEntity: modifiedEntity } });
                        mdmValues = __assign(__assign({}, defaultMdmValues), { relations: (_a = {}, _a[defaultProps.config.id] = { relationsToEdit: [relationToEdit] }, _a), modifiedEntities: (_b = {}, _b[entityUri] = modifiedEntity, _b) });
                        props = __assign(__assign({}, defaultProps), { connection: connection });
                        user = setUp({ mdmValues: mdmValues, props: props }).user;
                        return [4 /*yield*/, user.click(react_2.screen.getByText('Cancel'))];
                    case 1:
                        _c.sent();
                        expect(mdmActions.entityCreated).not.toHaveBeenCalled();
                        expect(mdmActions.errorsSet).toHaveBeenCalledWith([]);
                        expect(mdmActions.closeRelationEditor).toHaveBeenCalledWith(props.config.id, connection.relation.relationUri);
                        expect(mdmAction).toHaveBeenCalledTimes(2);
                        return [2 /*return*/];
                }
            });
        }); });
        it('should restore all related referenced entities to their initial state and delete outdated related referenced entities', function () { return __awaiter(void 0, void 0, void 0, function () {
            var entityUri, connection, modifiedEntities, relationToEdit, mdmValues, props, _a, user, rerender, updatedModifiedEntities;
            var _b, _c;
            return __generator(this, function (_d) {
                switch (_d.label) {
                    case 0:
                        entityUri = 'entities/uri$$kAp2KJM8';
                        connection = __assign(__assign({}, defaultProps.connection), { entity: { entityUri: entityUri } });
                        modifiedEntities = (_b = {},
                            _b[entityUri] = {
                                type: 'configuration/entityTypes/Location',
                                uri: entityUri,
                                attributes: {
                                    Address: [
                                        {
                                            refEntity: [{ objectURI: 'entities/uri$$kLnBs782' }],
                                            refRelation: null,
                                            uri: 'entities/uri$$kAp2KJM8/attributes/Address/uri$$nbsAsD',
                                            value: {},
                                            relationshipLabel: '',
                                            startObjectCrosswalks: []
                                        }
                                    ]
                                }
                            },
                            _b['entities/uri$$kLnBs782'] = {
                                type: 'configuration/entityTypes/Location',
                                uri: 'entities/uri$$kLnBs782',
                                attributes: {
                                    Address: [
                                        {
                                            refEntity: [
                                                {
                                                    objectURI: 'entities/uri$$ks0PsMA'
                                                }
                                            ],
                                            refRelation: null,
                                            uri: 'entities/uri$$kLnBs782/attributes/Address/uri$$o23NbsDA',
                                            value: {},
                                            relationshipLabel: '',
                                            startObjectCrosswalks: []
                                        }
                                    ]
                                }
                            },
                            _b['entities/uri$$ks0PsMA'] = {
                                uri: 'entities/uri$$ks0PsMA',
                                type: 'configuration/entityTypes/Location'
                            },
                            _b);
                        relationToEdit = __assign(__assign({}, connection), { initial: { connection: defaultProps.connection, modifiedEntity: modifiedEntities[entityUri] } });
                        mdmValues = __assign(__assign({}, defaultMdmValues), { relations: (_c = {}, _c[defaultProps.config.id] = { relationsToEdit: [relationToEdit] }, _c), modifiedEntities: modifiedEntities });
                        props = __assign(__assign({}, defaultProps), { connection: connection });
                        _a = setUp({ mdmValues: mdmValues, props: props }), user = _a.user, rerender = _a.rerender;
                        updatedModifiedEntities = __assign(__assign({}, modifiedEntities), { 'entities/uri$$ks0PsMA': {
                                type: 'configuration/entityTypes/Location',
                                uri: 'entities/uri$$ks0PsMA',
                                attributes: {
                                    Address: [
                                        {
                                            refEntity: [
                                                {
                                                    objectURI: 'entities/uri$$8jKsBssA3'
                                                }
                                            ],
                                            refRelation: null,
                                            uri: 'entities/uri$$ks0PsMA/attributes/Address/uri$$o23NbsDA',
                                            value: {},
                                            relationshipLabel: '',
                                            startObjectCrosswalks: []
                                        }
                                    ]
                                }
                            }, 'entities/uri$$8jKsBssA3': {
                                uri: 'entities/uri$$8jKsBssA3',
                                type: 'configuration/entityTypes/Location'
                            }, 'entities/uri$$IS2bSa92': {
                                uri: 'entities/uri$$IS2bSa92',
                                type: 'configuration/entityTypes/HCP'
                            } });
                        rerender({ mdmValues: __assign(__assign({}, mdmValues), { modifiedEntities: updatedModifiedEntities }) });
                        return [4 /*yield*/, user.click(react_2.screen.getByText('Cancel'))];
                    case 1:
                        _d.sent();
                        expect(mdmActions.entityCreated).toHaveBeenCalledWith(modifiedEntities['entities/uri$$kLnBs782']);
                        expect(mdmActions.entityCreated).toHaveBeenCalledWith(modifiedEntities['entities/uri$$ks0PsMA']);
                        expect(mdmActions.entityDeleted).toHaveBeenCalledWith('entities/uri$$8jKsBssA3');
                        expect(mdmActions.entityDeleted).not.toHaveBeenCalledWith('entities/uri$$IS2bSa92');
                        expect(mdmActions.errorsSet).toHaveBeenCalledWith([]);
                        expect(mdmActions.closeRelationEditor).toHaveBeenCalledWith(props.config.id, connection.relation.relationUri);
                        expect(mdmAction).toHaveBeenCalledTimes(5);
                        return [2 /*return*/];
                }
            });
        }); });
    });
    describe('entity selector', function () {
        describe('creating', function () {
            it('should create new entity and call events for saving it in relation and in modified entities store slice', function () { return __awaiter(void 0, void 0, void 0, function () {
                var user;
                return __generator(this, function (_a) {
                    switch (_a.label) {
                        case 0:
                            user = setUp().user;
                            return [4 /*yield*/, user.click(react_2.screen.getByTestId('select-dropdown-indicator'))];
                        case 1:
                            _a.sent();
                            return [4 /*yield*/, user.click(react_2.screen.getByText('Create new Address'))];
                        case 2:
                            _a.sent();
                            expect(mdmActions.setRelationEntity).toHaveBeenCalledWith(defaultProps.config.id, defaultProps.connection.relation.relationUri, {
                                attributes: {},
                                timestamp: expect.any(Number),
                                type: 'configuration/entityTypes/Location',
                                uri: expect.any(String)
                            });
                            expect(mdmActions.entityCreated).toHaveBeenCalledWith({
                                attributes: {},
                                timestamp: expect.any(Number),
                                type: 'configuration/entityTypes/Location',
                                uri: expect.any(String)
                            });
                            expect(mdmAction).toHaveBeenCalledTimes(2);
                            return [2 /*return*/];
                    }
                });
            }); });
            it('should delete previous temp (modified) entity before creating new one', function () { return __awaiter(void 0, void 0, void 0, function () {
                var entityUri, modifiedEntity, connection, mdmValues, props, user;
                var _a;
                return __generator(this, function (_b) {
                    switch (_b.label) {
                        case 0:
                            entityUri = 'entities/uri$$kAp2KJM8';
                            modifiedEntity = { type: 'configuration/entityTypes/Location', uri: entityUri, attributes: {} };
                            connection = __assign(__assign({}, defaultProps.connection), { entity: { entityUri: entityUri, entityType: 'configuration/entityTypes/Location' } });
                            mdmValues = __assign(__assign({}, defaultMdmValues), { modifiedEntities: (_a = {}, _a[entityUri] = modifiedEntity, _a) });
                            props = __assign(__assign({}, defaultProps), { connection: connection });
                            user = setUp({ mdmValues: mdmValues, props: props }).user;
                            return [4 /*yield*/, user.click(react_2.screen.getByTestId('select-dropdown-indicator'))];
                        case 1:
                            _b.sent();
                            return [4 /*yield*/, user.click(react_2.screen.getByText('Create new Address'))];
                        case 2:
                            _b.sent();
                            expect(mdmActions.setInitialInfo).toHaveBeenCalledWith(props.config.id, props.connection.relation.relationUri, modifiedEntity);
                            expect(mdmActions.entityDeleted).toHaveBeenCalledWith(entityUri);
                            expect(mdmActions.setRelationEntity).toHaveBeenCalledWith(defaultProps.config.id, defaultProps.connection.relation.relationUri, {
                                attributes: {},
                                timestamp: expect.any(Number),
                                type: 'configuration/entityTypes/Location',
                                uri: expect.any(String)
                            });
                            expect(mdmActions.entityCreated).toHaveBeenCalledWith({
                                attributes: {},
                                timestamp: expect.any(Number),
                                type: 'configuration/entityTypes/Location',
                                uri: expect.any(String)
                            });
                            expect(mdmAction).toHaveBeenCalledTimes(4);
                            return [2 /*return*/];
                    }
                });
            }); });
            it('should create new entity with init value and call events when onCreate prop was called with initValue argument', function () { return __awaiter(void 0, void 0, void 0, function () {
                var user;
                return __generator(this, function (_a) {
                    switch (_a.label) {
                        case 0:
                            user = setUp().user;
                            return [4 /*yield*/, user.click(react_2.screen.getByTestId('select-dropdown-indicator'))];
                        case 1:
                            _a.sent();
                            return [4 /*yield*/, user.type(react_2.screen.getByRole('combobox'), 'init value')];
                        case 2:
                            _a.sent();
                            return [4 /*yield*/, user.click(react_2.screen.getByText('Create "init value" as new Address'))];
                        case 3:
                            _a.sent();
                            expect(mdmActions.setRelationEntity).toHaveBeenCalledWith(defaultProps.config.id, defaultProps.connection.relation.relationUri, {
                                attributes: {
                                    FirstName: [
                                        {
                                            type: 'configuration/entityTypes/Location/attributes/FirstName',
                                            uri: expect.any(String),
                                            value: 'init value'
                                        }
                                    ]
                                },
                                timestamp: expect.any(Number),
                                type: 'configuration/entityTypes/Location',
                                uri: expect.any(String)
                            });
                            expect(mdmActions.entityCreated).toHaveBeenCalledWith({
                                attributes: {
                                    FirstName: [
                                        {
                                            type: 'configuration/entityTypes/Location/attributes/FirstName',
                                            uri: expect.any(String),
                                            value: 'init value'
                                        }
                                    ]
                                },
                                timestamp: expect.any(Number),
                                type: 'configuration/entityTypes/Location',
                                uri: expect.any(String)
                            });
                            expect(mdmAction).toHaveBeenCalledTimes(2);
                            return [2 /*return*/];
                    }
                });
            }); });
        });
        describe('changing', function () {
            beforeEach(function () {
                mdm_sdk_1.typeAheadSearch.mockResolvedValue([
                    { type: 'configuration/entityTypes/Location', label: 'location entity 1', uri: 'entities/0C32GxR' },
                    { type: 'configuration/entityTypes/Location', label: 'location entity 2', uri: 'entities/0G49Cnu' }
                ]);
            });
            afterEach(function () {
                jest.clearAllMocks();
            });
            it('should set connection entity', function () { return __awaiter(void 0, void 0, void 0, function () {
                var user;
                return __generator(this, function (_a) {
                    switch (_a.label) {
                        case 0:
                            user = setUp().user;
                            return [4 /*yield*/, user.click(react_2.screen.getByTestId('select-dropdown-indicator'))];
                        case 1:
                            _a.sent();
                            return [4 /*yield*/, user.click(react_2.screen.getByText('location entity 1'))];
                        case 2:
                            _a.sent();
                            expect(mdmActions.setRelationEntity).toHaveBeenCalledWith(defaultProps.config.id, defaultProps.connection.relation.relationUri, {
                                entityType: defaultProps.metadata.entityTypes[1],
                                label: 'location entity 1',
                                type: 'configuration/entityTypes/Location',
                                uri: 'entities/0C32GxR'
                            });
                            expect(mdmAction).toHaveBeenCalledTimes(1);
                            return [2 /*return*/];
                    }
                });
            }); });
            it('should deactivate error if it was set', function () { return __awaiter(void 0, void 0, void 0, function () {
                var error, mdmValues, user;
                return __generator(this, function (_a) {
                    switch (_a.label) {
                        case 0:
                            error = {
                                parentUri: defaultRelation.relationUri,
                                uri: 'uri',
                                attributeTypeUri: defaultRelation.relationType,
                                message: 'Entity is required',
                                type: mdm_sdk_1.ErrorType.missedRefEntity
                            };
                            mdmValues = __assign(__assign({}, defaultMdmValues), { profileErrors: [error] });
                            setUp({ mdmValues: mdmValues });
                            user = setUp().user;
                            return [4 /*yield*/, user.click(react_2.screen.getAllByTestId('select-dropdown-indicator')[0])];
                        case 1:
                            _a.sent();
                            return [4 /*yield*/, user.click(react_2.screen.getByText('location entity 1'))];
                        case 2:
                            _a.sent();
                            expect(mdmActions.setRelationEntity).toHaveBeenCalledWith(defaultProps.config.id, defaultProps.connection.relation.relationUri, {
                                entityType: defaultProps.metadata.entityTypes[1],
                                label: 'location entity 1',
                                type: 'configuration/entityTypes/Location',
                                uri: 'entities/0C32GxR'
                            });
                            expect(mdmActions.errorDeactivated).toHaveBeenCalledWith("".concat(error.attributeTypeUri, "-").concat(error.uri, "-").concat(error.parentUri));
                            expect(mdmAction).toHaveBeenCalledTimes(2);
                            return [2 /*return*/];
                    }
                });
            }); });
            it('should clear connection entity and modified entity if it set', function () { return __awaiter(void 0, void 0, void 0, function () {
                var entityUri, modifiedEntity, connection, mdmValues, props, user;
                var _a;
                return __generator(this, function (_b) {
                    switch (_b.label) {
                        case 0:
                            entityUri = 'entities/uri$$kAp2KJM8';
                            modifiedEntity = { type: 'configuration/entityTypes/Location', uri: entityUri, attributes: {} };
                            connection = __assign(__assign({}, defaultProps.connection), { entity: { entityUri: entityUri, entityType: 'configuration/entityTypes/Location' } });
                            mdmValues = __assign(__assign({}, defaultMdmValues), { modifiedEntities: (_a = {}, _a[entityUri] = modifiedEntity, _a) });
                            props = __assign(__assign({}, defaultProps), { connection: connection });
                            user = setUp({ mdmValues: mdmValues, props: props }).user;
                            mdmAction.mockClear();
                            return [4 /*yield*/, user.click(react_2.screen.getByTestId('select-dropdown-indicator'))];
                        case 1:
                            _b.sent();
                            return [4 /*yield*/, user.click(react_2.screen.getByText('location entity 1'))];
                        case 2:
                            _b.sent();
                            expect(mdmActions.entityDeleted).toHaveBeenCalledWith(entityUri);
                            expect(mdmActions.setRelationEntity).toHaveBeenCalledWith(defaultProps.config.id, defaultProps.connection.relation.relationUri, {
                                entityType: defaultProps.metadata.entityTypes[1],
                                label: 'location entity 1',
                                type: 'configuration/entityTypes/Location',
                                uri: 'entities/0C32GxR'
                            });
                            expect(mdmAction).toHaveBeenCalledTimes(2);
                            return [2 /*return*/];
                    }
                });
            }); });
        });
    });
    describe('errors highlighting', function () {
        var fullError = {
            type: mdm_sdk_1.ErrorType.invalid,
            attributeTypeUri: defaultProps.connection.relation.relationType,
            parentUri: defaultProps.connection.relation.relationUri,
            uri: 'someUrl',
            source: mdm_sdk_1.ErrorSource.validationService,
            severity: mdm_sdk_1.ErrorSeverity.ERROR
        };
        it('should not highlight error if it have uri', function () { return __awaiter(void 0, void 0, void 0, function () {
            return __generator(this, function (_a) {
                switch (_a.label) {
                    case 0:
                        setUp({ error: fullError });
                        return [4 /*yield*/, react_2.screen.findByText('Select Address profile')];
                    case 1:
                        _a.sent();
                        expect(scrollIntoRef).not.toHaveBeenCalledWith();
                        return [2 /*return*/];
                }
            });
        }); });
        it('should highlight error if it have same parent uri, empty uri, and attribute type uri', function () { return __awaiter(void 0, void 0, void 0, function () {
            var error;
            return __generator(this, function (_a) {
                switch (_a.label) {
                    case 0:
                        error = __assign(__assign({}, fullError), { uri: '' });
                        setUp({ error: error });
                        return [4 /*yield*/, react_2.screen.findByText('Select Address profile')];
                    case 1:
                        _a.sent();
                        expect(scrollIntoRef).toHaveBeenCalled();
                        return [2 /*return*/];
                }
            });
        }); });
    });
});
