"use strict";
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 CollapsibleItemsContext_1 = require("../contexts/CollapsibleItemsContext");
var types_1 = require("../types");
var ActivitiesFactory_1 = require("./ActivitiesFactory");
var defaultMdmValues = {
    metadata: {
        entityTypes: [],
        groupTypes: []
    }
};
var setUp = function (_a) {
    var props = _a.props, _b = _a.mdmValues, mdmValues = _b === void 0 ? defaultMdmValues : _b;
    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)(ActivitiesFactory_1.ActivitiesFactory.getComponent(props), { wrapper: Providers });
};
describe('Activities factory tests', function () {
    describe('comment activity', function () {
        it('should render comment activity for COMMENT_ADDED activity type', function () {
            var props = { type: types_1.ActivityTypes.COMMENT_ADDED };
            setUp({ props: props });
            react_2.screen.getByTestId('comment-activity');
        });
        it('should render comment activity for COMMENT_DELETED activity type', function () {
            var props = { type: types_1.ActivityTypes.COMMENT_DELETED };
            setUp({ props: props });
            react_2.screen.getByTestId('comment-activity');
        });
        it('should render comment activity for COMMENT_UPDATED activity type', function () {
            var props = { type: types_1.ActivityTypes.COMMENT_UPDATED };
            setUp({ props: props });
            react_2.screen.getByTestId('comment-activity');
        });
    });
    describe('merge activity', function () {
        var defaultData = {
            uri: 'activities/156a1eda-4c2c-46e3-8550-118c500fb453',
            user: 'marat.ahmetzyanov',
            timestamp: 1620711408828,
            items: [],
            itemsTotal: 0
        };
        it('should render merge activity for ENTITIES_MERGED_MANUALLY activity type', function () {
            var props = { data: defaultData, type: types_1.ActivityTypes.ENTITIES_MERGED_MANUALLY };
            setUp({ props: props });
            react_2.screen.getByTestId('merge-activity');
        });
        it('should render merge activity for ENTITIES_MERGED activity type', function () {
            var props = { data: defaultData, type: types_1.ActivityTypes.ENTITIES_MERGED };
            setUp({ props: props });
            react_2.screen.getByTestId('merge-activity');
        });
        it('should render merge activity for ENTITIES_MERGED_ON_THE_FLY activity type', function () {
            var props = { data: defaultData, type: types_1.ActivityTypes.ENTITIES_MERGED_ON_THE_FLY };
            setUp({ props: props });
            react_2.screen.getByTestId('merge-activity');
        });
        it('should render merge activity for ENTITIES_SPLITTED activity type', function () {
            var props = { data: defaultData, type: types_1.ActivityTypes.ENTITIES_SPLITTED };
            setUp({ props: props });
            react_2.screen.getByTestId('merge-activity');
        });
        it('should render merge activity for ENTITY_LOST_MERGE activity type', function () {
            var props = { data: defaultData, type: types_1.ActivityTypes.ENTITY_LOST_MERGE };
            setUp({ props: props });
            react_2.screen.getByTestId('merge-activity');
        });
    });
    describe('potential match activity', function () {
        var defaultData = {
            uri: 'activities/156a1eda-4c2c-46e3-8550-118c500fb453',
            user: 'marat.ahmetzyanov',
            timestamp: 1620711408828,
            items: [],
            itemsTotal: 0
        };
        it('should render potential match activity for POTENTIAL_MATCHES_FOUND activity type', function () {
            var props = { data: defaultData, type: types_1.ActivityTypes.POTENTIAL_MATCHES_FOUND };
            setUp({ props: props });
            react_2.screen.getByTestId('potential-match-activity');
        });
        it('should render potential match activity for POTENTIAL_MATCHES_REMOVED activity type', function () {
            var props = { data: defaultData, type: types_1.ActivityTypes.POTENTIAL_MATCHES_REMOVED };
            setUp({ props: props });
            react_2.screen.getByTestId('potential-match-activity');
        });
        it('should render potential match activity for NOT_MATCHES_SET activity type', function () {
            var props = { data: defaultData, type: types_1.ActivityTypes.NOT_MATCHES_SET };
            setUp({ props: props });
            react_2.screen.getByTestId('potential-match-activity');
        });
        it('should render potential match activity for NOT_MATCHES_RESET activity type', function () {
            var props = { data: defaultData, type: types_1.ActivityTypes.NOT_MATCHES_RESET };
            setUp({ props: props });
            react_2.screen.getByTestId('potential-match-activity');
        });
    });
    describe('profile activity', function () {
        var defaultData = {
            uri: 'activities/156a1eda-4c2c-46e3-8550-118c500fb453',
            user: 'marat.ahmetzyanov',
            timestamp: 1620711408828,
            items: [],
            itemsTotal: 0
        };
        it('should render profile activity for ENTITY_CHANGED activity type', function () {
            var props = { data: defaultData, type: types_1.ActivityTypes.ENTITY_CHANGED };
            setUp({ props: props });
            react_2.screen.getByTestId('profile-activity');
        });
        it('should render profile activity for ENTITY_CREATED activity type', function () {
            var props = { data: defaultData, type: types_1.ActivityTypes.ENTITY_CREATED };
            setUp({ props: props });
            react_2.screen.getByTestId('profile-activity');
        });
        it('should render profile activity for ENTITY_REMOVED activity type', function () {
            var props = { data: defaultData, type: types_1.ActivityTypes.ENTITY_REMOVED };
            setUp({ props: props });
            react_2.screen.getByTestId('profile-activity');
        });
        it('should render profile activity for ANALYTICS_ATTRIBUTES_CHANGED activity type', function () {
            var props = { data: defaultData, type: types_1.ActivityTypes.ANALYTICS_ATTRIBUTES_CHANGED };
            setUp({ props: props });
            react_2.screen.getByTestId('profile-activity');
        });
    });
    describe('relation activity', function () {
        var defaultData = {
            uri: 'activities/156a1eda-4c2c-46e3-8550-118c500fb453',
            user: 'marat.ahmetzyanov',
            timestamp: 1620711408828,
            items: [],
            itemsTotal: 0
        };
        it('should render relation activity for RELATIONSHIP_CHANGED activity type', function () {
            var props = { data: defaultData, type: types_1.ActivityTypes.RELATIONSHIP_CHANGED };
            setUp({ props: props });
            react_2.screen.getByTestId('relation-activity');
        });
        it('should render relation activity for RELATIONSHIP_CREATED activity type', function () {
            var props = { data: defaultData, type: types_1.ActivityTypes.RELATIONSHIP_CREATED };
            setUp({ props: props });
            react_2.screen.getByTestId('relation-activity');
        });
        it('should render relation activity for RELATIONSHIP_REMOVED activity type', function () {
            var props = { data: defaultData, type: types_1.ActivityTypes.RELATIONSHIP_REMOVED };
            setUp({ props: props });
            react_2.screen.getByTestId('relation-activity');
        });
    });
    describe('search activity', function () {
        it('should render search activity for USER_SEARCH activity type', function () {
            var props = {
                data: {
                    uri: 'activities/504c-9876-79bc2a96',
                    user: 'polina.arsenteva',
                    label: 'USER_SEARCH',
                    description: '{"activity":{"query":null,"uiState":{"view":{"searchResultsMode":"table","entityTypeTab":null,"previewPanelMode":null},"facets":{},"advanced":[],"searchOptions":{"searchByOv":true,"ovOnly":true},"keyword":null,"map":null,"version":"2.0"}},"version":"2.0"}',
                    timestamp: 1626952820539
                },
                type: types_1.ActivityTypes.USER_SEARCH
            };
            setUp({ props: props });
            react_2.screen.getByTestId('search-activity');
        });
    });
    describe('group activity', function () {
        var defaultData = {
            uri: 'activities/156a1eda-4c2c-46e3-8550-118c500fb453',
            user: 'marat.ahmetzyanov',
            timestamp: 1620711408828,
            items: [],
            itemsTotal: 0
        };
        it('should render group activity for GROUP_CHANGED activity type', function () {
            var props = { data: defaultData, type: types_1.ActivityTypes.GROUP_CHANGED };
            setUp({ props: props });
            react_2.screen.getByTestId('group-activity');
        });
        it('should render group activity for GROUP_CREATED activity type', function () {
            var props = { data: defaultData, type: types_1.ActivityTypes.GROUP_CREATED };
            setUp({ props: props });
            react_2.screen.getByTestId('group-activity');
        });
        it('should render group activity for GROUP_REMOVED activity type', function () {
            var props = { data: defaultData, type: types_1.ActivityTypes.GROUP_REMOVED };
            setUp({ props: props });
            react_2.screen.getByTestId('group-activity');
        });
    });
    describe('simple activity', function () {
        var defaultData = {
            uri: 'activities/156a1eda-4c2c-46e3-8550-118c500fb453',
            user: 'marat.ahmetzyanov',
            timestamp: 1620711408828,
            description: '{}',
            itemsTotal: 0
        };
        it('should render simple activity for USER_LOGIN activity type', function () {
            var props = { data: defaultData, type: types_1.ActivityTypes.USER_LOGIN };
            setUp({ props: props });
            react_2.screen.getByTestId('simple-activity');
        });
        it('should render simple activity for USER_LOGOUT activity type', function () {
            var props = { data: defaultData, type: types_1.ActivityTypes.USER_LOGOUT };
            setUp({ props: props });
            react_2.screen.getByTestId('simple-activity');
        });
        it('should render simple activity for MODEL_UPDATED activity type', function () {
            var props = { data: defaultData, type: types_1.ActivityTypes.MODEL_UPDATED };
            setUp({ props: props });
            react_2.screen.getByTestId('simple-activity');
        });
        it('should render simple activity for PERIODIC_TASK_SCHEDULED activity type', function () {
            var props = { data: defaultData, type: types_1.ActivityTypes.PERIODIC_TASK_SCHEDULED };
            setUp({ props: props });
            react_2.screen.getByTestId('simple-activity');
        });
        it('should render simple activity for USER_PROFILE_VIEW activity type', function () {
            var props = { data: defaultData, type: types_1.ActivityTypes.USER_PROFILE_VIEW };
            setUp({ props: props });
            react_2.screen.getByTestId('simple-activity');
        });
        it('should render simple activity for ATTRIBUTE_UNMASKED activity type', function () {
            var props = { data: defaultData, type: types_1.ActivityTypes.ATTRIBUTE_UNMASKED };
            setUp({ props: props });
            react_2.screen.getByTestId('simple-activity');
        });
    });
    describe('synchronization issues activity', function () {
        it('should render synchronization issues activity for SFDC_CONNECTOR_SYNCHRONIZATION_ISSUE activity type', function () {
            var props = {
                data: {
                    uri: 'activities/0dcf97d0-5006-46d6-b82f-07579922e2f6',
                    user: 'sfdc.connector.admin',
                    label: 'label',
                    timestamp: 1652374313724,
                    items: [
                        {
                            id: '42uxv5X2',
                            timestamp: 1652374313724,
                            objectUri: 'entities/15T9kNFk',
                            objectType: 'configuration/entityTypes/HCP',
                            objectLabel: 'Andy Andy'
                        }
                    ],
                    itemsTotal: 1
                },
                type: types_1.ActivityTypes.SFDC_CONNECTOR_SYNCHRONIZATION_ISSUE
            };
            setUp({ props: props });
            react_2.screen.getByTestId('synchronization-issues-activity');
        });
    });
    describe('not implemented', function () {
        it('should render not implemented text for unexpected types', function () {
            var props = { type: 'UNEXPECTED_ACTIVITY' };
            setUp({ props: props });
            react_2.screen.getByText('UNEXPECTED_ACTIVITY NOT IMPLEMENTED');
        });
    });
});
