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);
};
import React from 'react';
import { render, screen, within } from '@testing-library/react';
import { MdmModuleProvider } from '../../../../../contexts/MdmModuleContext';
import { ActivityTypes } from '../../../types';
import { CollapsibleItemsProvider } from '../../../contexts/CollapsibleItemsContext';
import { MergeActivity } from './MergeActivity';
var defaultItem = {
    id: '5C94p4Yp',
    objectUri: 'entities/1PN94HrW',
    objectLabel: 'object label',
    timestamp: 1620711408828,
    data: { type: ActivityTypes.ENTITIES_MERGED_ON_THE_FLY }
};
var defaultData = {
    uri: 'activities/156a1eda-4c2c-46e3-8550-118c500fb453',
    user: 'marat.ahmetzyanov',
    timestamp: 1620711408828,
    items: [defaultItem],
    itemsTotal: 1
};
var defaultProps = {
    data: defaultData,
    type: ActivityTypes.ENTITIES_MERGED_ON_THE_FLY
};
var defaultMdmValues = {
    uiPath: 'https://reltio.com/nui'
};
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;
    var Providers = function (_a) {
        var children = _a.children;
        return (React.createElement(MdmModuleProvider, { values: mdmValues },
            React.createElement(CollapsibleItemsProvider, null, children)));
    };
    return render(React.createElement(MergeActivity, __assign({}, props)), { wrapper: Providers });
};
describe('Merge activity tests', function () {
    it('should render minimized if itemsTotal is 1 and there are not potentialMatches or newUri fields', function () {
        setUp();
        var title = screen.getByTestId('merge-activity-title');
        within(title).getByText('object label');
        within(title).getByText('Profile merged on the fly');
    });
    it('should render maximized if itemsTotal is 1 but there is potentialMatches field', function () {
        var props = __assign(__assign({}, defaultProps), { data: __assign(__assign({}, defaultData), { items: [
                    __assign(__assign({}, defaultItem), { data: {
                            type: ActivityTypes.POTENTIAL_MATCHES_FOUND,
                            potentialMatches: 'entities/sOoSQYm',
                            'entities/sOoSQYm': 'entity label 1'
                        } })
                ] }) });
        setUp({ props: props });
        var title = screen.getByTestId('merge-activity-title');
        within(title).getByText('Profile merged on the fly');
        expect(within(title).queryByText('object label')).not.toBeInTheDocument();
        var record = screen.getByTestId('reltio-activity-log-record');
        within(record).getByText('object label');
        expect(screen.getByTestId('potential-matches-field')).toHaveTextContent('Matches found:entity label 1');
    });
    it('should render maximized if itemsTotal is 1 but there is newUri field', function () {
        var props = __assign(__assign({}, defaultProps), { data: __assign(__assign({}, defaultData), { items: [
                    __assign(__assign({}, defaultItem), { data: {
                            type: ActivityTypes.ENTITIES_SPLITTED,
                            newUri: 'entities/sOoSQYm',
                            'entities/sOoSQYm': 'entity label 1'
                        } })
                ] }) });
        setUp({ props: props });
        var title = screen.getByTestId('merge-activity-title');
        within(title).getByText('Profile merged on the fly');
        expect(within(title).queryByText('object label')).not.toBeInTheDocument();
        var record = screen.getByTestId('reltio-activity-log-record');
        within(record).getByText('object label');
        expect(screen.getByTestId('potential-matches-field')).toHaveTextContent('Un-merged with:entity label 1');
    });
});
