Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
22 changes: 21 additions & 1 deletion plugin-hrm-form/src/___tests__/maskIdentifiers/index.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@

/* eslint-disable camelcase */

import { Manager } from '@twilio/flex-ui';
import { Manager, Notifications } from '@twilio/flex-ui';
import each from 'jest-each';

import { maskConversationServiceUserNames, maskChannelStringsWithIdentifiers } from '../../maskIdentifiers';
Expand All @@ -36,8 +36,12 @@ jest.mock('@twilio/flex-ui', () => ({
Manager: {
getInstance: jest.fn(),
},
Notifications: {
registeredNotifications: new Map(),
},
NotificationIds: {
NewChatMessage: 'NewChatMessage',
IncomingTask: 'IncomingTask',
},
DefaultTaskChannels: {
ChatSms: { name: 'ChatSms' },
Expand All @@ -47,6 +51,8 @@ jest.mock('@twilio/flex-ui', () => ({
},
}));

const mockRegisteredNotifications = Notifications.registeredNotifications as Map<string, any>;

const mockLookupTranslation = lookupTranslation as jest.MockedFunction<typeof lookupTranslation>;

const mockGetInitializedCan = getInitializedCan as jest.MockedFunction<typeof getInitializedCan>;
Expand Down Expand Up @@ -441,6 +447,8 @@ describe('maskChannelStringsWithIdentifiers', () => {
mockGetInitializedCan.mockReturnValue(mockCan);
mockManagerGetInstance.mockReturnValue({ strings: { MaskIdentifiers: 'MASKED' } } as any);
mockLookupTranslation.mockReturnValue('Masked Title');
mockRegisteredNotifications.clear();
mockRegisteredNotifications.set('IncomingTask', {});
});

afterEach(() => {
Expand Down Expand Up @@ -468,6 +476,12 @@ describe('maskChannelStringsWithIdentifiers', () => {
expect(mockLookupTranslation).toHaveBeenCalledWith('BrowserNotification-ChatMessage-MaskedTitle');
expect(notification.options.browser.title).toBe('Masked Title');
});

test('deletes IncomingTask notification', () => {
const channelType = createChannelType();
maskChannelStringsWithIdentifiers(channelType as any);
expect(mockRegisteredNotifications.has('IncomingTask')).toBe(false);
});
});

describe('when VIEW_IDENTIFIERS permission is granted', () => {
Expand All @@ -480,5 +494,11 @@ describe('maskChannelStringsWithIdentifiers', () => {
maskChannelStringsWithIdentifiers(channelType as any);
expect(channelType.notifications.override.NewChatMessage).toBeUndefined();
});

test('does not delete IncomingTask notification', () => {
const channelType = createChannelType();
maskChannelStringsWithIdentifiers(channelType as any);
expect(mockRegisteredNotifications.has('IncomingTask')).toBe(true);
});
});
});
Loading