"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 __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 MdmModuleContext_1 = require("../../../../../contexts/MdmModuleContext");
var types_1 = require("../../../types");
var CollapsibleItemsContext_1 = require("../../../contexts/CollapsibleItemsContext");
var MergeActivity_1 = require("./MergeActivity");
var defaultItem = {
    id: '5C94p4Yp',
    objectUri: 'entities/1PN94HrW',
    objectLabel: 'object label',
    timestamp: 1620711408828,
    data: { type: types_1.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: types_1.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_1.default.createElement(MdmModuleContext_1.MdmModuleProvider, { values: mdmValues },
            react_1.default.createElement(CollapsibleItemsContext_1.CollapsibleItemsProvider, null, children)));
    };
    return (0, react_2.render)(react_1.default.createElement(MergeActivity_1.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 = react_2.screen.getByTestId('merge-activity-title');
        (0, react_2.within)(title).getByText('object label');
        (0, react_2.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: types_1.ActivityTypes.POTENTIAL_MATCHES_FOUND,
                            potentialMatches: 'entities/sOoSQYm',
                            'entities/sOoSQYm': 'entity label 1'
                        } })
                ] }) });
        setUp({ props: props });
        var title = react_2.screen.getByTestId('merge-activity-title');
        (0, react_2.within)(title).getByText('Profile merged on the fly');
        expect((0, react_2.within)(title).queryByText('object label')).not.toBeInTheDocument();
        var record = react_2.screen.getByTestId('reltio-activity-log-record');
        (0, react_2.within)(record).getByText('object label');
        expect(react_2.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: types_1.ActivityTypes.ENTITIES_SPLITTED,
                            newUri: 'entities/sOoSQYm',
                            'entities/sOoSQYm': 'entity label 1'
                        } })
                ] }) });
        setUp({ props: props });
        var title = react_2.screen.getByTestId('merge-activity-title');
        (0, react_2.within)(title).getByText('Profile merged on the fly');
        expect((0, react_2.within)(title).queryByText('object label')).not.toBeInTheDocument();
        var record = react_2.screen.getByTestId('reltio-activity-log-record');
        (0, react_2.within)(record).getByText('object label');
        expect(react_2.screen.getByTestId('potential-matches-field')).toHaveTextContent('Un-merged with:entity label 1');
    });
});
