Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Tags cleanup from codebase #2299

Merged
merged 7 commits into from
Jan 16, 2023
Merged
Show file tree
Hide file tree
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: 7 additions & 15 deletions src/components/UI/ListIcon/ListIcon.test.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@ import { MemoryRouter } from 'react-router';
import { render } from '@testing-library/react';

import chatIcon from 'assets/images/icons/Chat/Unselected.svg';
import tagIcon from 'assets/images/icons/Tags/Unselected.svg';
import broadcastIcon from 'assets/images/icons/Broadcast/Unselected.svg';
import flowIcon from 'assets/images/icons/Flow/Unselected.svg';
import searchIcon from 'assets/images/icons/Search/Unselected.svg';
Expand All @@ -13,35 +12,28 @@ import { ListIcon } from './ListIcon';
describe('list icon tests', () => {
const iconList: { [iconName: string]: string } = {
chat: chatIcon,
tag: tagIcon,
broadcast: broadcastIcon,
flow: flowIcon,
search: searchIcon,
goal: goalsIcon,
analytics: analyticsIcon,
};
const createIcon = (type: string, selected: boolean) => {
return (
<MemoryRouter>
<ListIcon icon={type} />
</MemoryRouter>
);
};

const capitalize = (str: string) => {
return str.charAt(0).toUpperCase() + str.slice(1);
};
const createIcon = (type: string) => (
<MemoryRouter>
<ListIcon icon={type} />
</MemoryRouter>
);

it('renders an object', () => {
const { getByTestId } = render(createIcon('chat', false));
const { getByTestId } = render(createIcon('chat'));
expect(getByTestId('listIcon')).toBeInTheDocument();
});

it('renders appropriate icons', () => {
const keys = Object.keys(iconList);

for (let i = 0; i < keys.length; i++) {
const { container } = render(createIcon(keys[i], false));
const { container } = render(createIcon(keys[i]));
expect(container.querySelector('img')?.src).toContain('Unselected.svg');
}
});
Expand Down
6 changes: 0 additions & 6 deletions src/components/UI/ListIcon/ListIcon.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@ import { useLocation } from 'react-router-dom';
import Badge from '@material-ui/core/Badge';

import chatIcon from 'assets/images/icons/Chat/Unselected.svg';
import tagIcon from 'assets/images/icons/Tags/Unselected.svg';
import broadcastIcon from 'assets/images/icons/Broadcast/Unselected.svg';
import flowIcon from 'assets/images/icons/Flow/Unselected.svg';
import searchIcon from 'assets/images/icons/Search/Unselected.svg';
Expand All @@ -12,11 +11,9 @@ import analyticsIcon from 'assets/images/icons/Analytics/Unselected.svg';
import speedSendIcon from 'assets/images/icons/SpeedSend/Unselected.svg';
import templateIcon from 'assets/images/icons/Template/Unselected.svg';
import chatSelectedIcon from 'assets/images/icons/Chat/Selected.svg';
import tagSelectedIcon from 'assets/images/icons/Tags/Selected.svg';
import broadcastSelectedIcon from 'assets/images/icons/Broadcast/Selected.svg';
import flowSelectedIcon from 'assets/images/icons/Flow/Selected.svg';
import searchSelectedIcon from 'assets/images/icons/Search/Selected.svg';
// import goalsSelectedIcon from 'assets/images/icons/Goals/Selected.svg';
import analyticsSelectedIcon from 'assets/images/icons/Analytics/Selected.svg';
import interactiveMessageIcon from 'assets/images/icons/InteractiveMessage/Unselected.svg';
import interactiveMessageSelectedIcon from 'assets/images/icons/InteractiveMessage/Selected.svg';
Expand All @@ -39,7 +36,6 @@ export const ListIcon = ({ icon, count, showBadge }: ListIconProps) => {
const location = useLocation();
const stringsToIcons: { [iconName: string]: string } = {
chat: chatIcon,
tag: tagIcon,
broadcast: broadcastIcon,
flow: flowIcon,
search: searchIcon,
Expand All @@ -55,11 +51,9 @@ export const ListIcon = ({ icon, count, showBadge }: ListIconProps) => {

const stringsToSelectedIcons: { [iconName: string]: string } = {
chat: chatSelectedIcon,
tag: tagSelectedIcon,
broadcast: broadcastSelectedIcon,
flow: flowSelectedIcon,
search: searchSelectedIcon,
// goal: goalsSelectedIcon,
analytics: analyticsSelectedIcon,
'speed-send': speedSendSelectedIcon,
template: templateSelectedIcon,
Expand Down
7 changes: 0 additions & 7 deletions src/components/simulator/Simulator.test.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -135,13 +135,6 @@ const body = {
sender: {
id: '2',
},
tags: [
{
id: '1',
label: 'important',
colorCode: '#00d084',
},
],
type: 'TEXT',
media: null,
errors: '{}',
Expand Down
7 changes: 0 additions & 7 deletions src/config/menu.ts
Original file line number Diff line number Diff line change
Expand Up @@ -9,13 +9,6 @@ const menus = [
type: 'sideDrawer',
roles: ['Staff', 'Manager', 'Admin', 'Dynamic'],
},
// {
// title: 'Tags',
// path: '/tag',
// icon: 'tag',
// type: 'sideDrawer',
// roles: ['Manager', 'Admin'],
// },
{
title: 'Speed Sends',
path: '/speed-send',
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -41,12 +41,6 @@ const defaultProps = {
body: 'Hello there!',
insertedAt,
type: 'TEXT',
tags: [
{
id: 1,
label: 'Unread',
},
],
},
};

Expand Down Expand Up @@ -78,10 +72,3 @@ test('it should call the callback function on click action', () => {
fireEvent.click(getAllByTestId('list')[0]);
expect(mockCallback).toHaveBeenCalled();
});

test('check the condition with empty tags', () => {
const propswithEmptyTags = { ...defaultProps };
propswithEmptyTags.lastMessage.tags = [];
const { container } = render(wrapperContainer(propswithEmptyTags));
expect(container.querySelector('.ChatInfoRead')).toBeInTheDocument();
});
Original file line number Diff line number Diff line change
Expand Up @@ -30,10 +30,6 @@ export interface ChatConversationProps {
insertedAt: string;
type: string;
media: any;
tags: Array<{
id: number;
label: string;
}>;
};
messageNumber?: number;
highlightSearch?: string | null;
Expand Down Expand Up @@ -152,7 +148,6 @@ const ChatConversation = ({

// Need to handle following cases:
// a. there might be some cases when there are no conversations against the contact
// b. handle unread formatting only if tags array is set
if (!contactIsOrgRead) {
chatInfoClass = [styles.ChatInfo, styles.ChatInfoUnread];
chatBubble = [styles.ChatBubble, styles.ChatBubbleUnread];
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -29,14 +29,6 @@ const withResult = {
sender: {
id: '6',
},
tags: [
{
id: '8',
label: 'Not working',
colorCode: '#00d084',
parent: null,
},
],
type: 'TEXT',
media: null,
errors: '{}',
Expand Down Expand Up @@ -127,15 +119,13 @@ export const searchMultiQuery = (
phone: '9876543210',
maskedPhone: '9876543210',
status: 'VALID',
tags: [],
},
{
bspStatus: 'SESSION',
id: '3',
lastMessageAt: '2020-11-18T04:37:57Z',
name: 'Adelle Cavin',
status: 'VALID',
tags: [],
},
],
messages: [
Expand All @@ -161,49 +151,10 @@ export const searchMultiQuery = (
sender: {
id: '8',
},
tags: [
{
colorCode: '#0C976D',
id: '4',
label: 'Greeting',
},
],
type: 'TEXT',
flowLabel: null,
},
],
tags: [
{
body: 'Hi',
contact: {
bspStatus: 'HSM',
id: '8',
lastMessageAt: '2020-10-15T07:15:33Z',
name: 'Dignesh',
phone: '9876543210',
maskedPhone: '9876543210',
status: 'VALID',
},
id: '12',
insertedAt: '2020-10-15T06:58:34.432894Z',
media: null,
messageNumber: 54,
receiver: {
id: '1',
},
sender: {
id: '8',
},
tags: [
{
colorCode: '#0C976D',
id: '4',
label: 'Greeting',
},
],
type: 'TEXT',
},
],
},
},
},
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -43,13 +43,6 @@ cache.writeQuery({
sender: {
id: '2',
},
tags: [
{
id: '1',
label: 'important',
colorCode: '#00d084',
},
],
type: 'TEXT',
media: null,
errors: null,
Expand Down Expand Up @@ -132,7 +125,7 @@ test('it should reset input on clicking cross icon', async () => {
});

test('it should load all contacts with unread tag', async () => {
const { getAllByTestId, getByText, getAllByText } = render(chatConversation);
const { getAllByTestId, getAllByText } = render(chatConversation);
// loading is show initially
expect(getAllByText('Loading...')).toHaveLength(2);
await waitFor(() => {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -118,8 +118,6 @@ export const ConversationList = ({
}
const params = searchParam;
if (params) {
// if (params.includeTags && params.includeTags.length > 0)
// filter.includeTags = params.includeTags.map((obj: any) => obj.id);
if (params.includeGroups && params.includeGroups.length > 0)
filter.includeGroups = params.includeGroups.map((obj: any) => obj.id);
if (params.includeUsers && params.includeUsers.length > 0)
Expand Down Expand Up @@ -321,7 +319,7 @@ export const ConversationList = ({
if (searchVal && searchMultiData && Object.keys(searchParam).length === 0) {
conversations = searchMultiData.searchMulti;
// to set search response sequence
const searchArray = { contacts: [], tags: [], messages: [], labels: [] };
const searchArray = { contacts: [], messages: [], labels: [] };
let conversationsData;
Object.keys(searchArray).forEach((dataArray: any) => {
const header = (
Expand Down
14 changes: 0 additions & 14 deletions src/containers/Chat/ChatInterface/ChatInterface.test.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -44,13 +44,6 @@ cache.writeQuery({
sender: {
id: '2',
},
tags: [
{
id: '1',
label: 'important',
colorCode: '#00d084',
},
],
type: 'TEXT',
media: null,
errors: '{}',
Expand Down Expand Up @@ -111,13 +104,6 @@ describe('<ChatInterface />', () => {
// check if chat conversations are displayed
const ChatConversation = await findByTestId('beneficiaryName');
expect(ChatConversation).toHaveTextContent('Effie Cormier');

// check if tags are displayed in the ChatMessages
/**
* commenting tags for now
*/
// const ConversationTag = await findAllByText('important');
// expect(ConversationTag[0]).toBeInTheDocument();
});

test('check condition when no subscription data provided', async () => {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -145,38 +145,6 @@
display: flex;
}

.TagContainerSender {
justify-content: flex-end;
}

.TagContainer {
display: flex;
line-height: 12px;
margin-bottom: 11px;
flex-wrap: wrap;
}

.TagMargin {
margin-right: 0px !important;
margin-left: 8px;
}

.Tag {
font-size: 12px;
font-weight: 500;
color: #073f24;
display: flex;
align-items: center;
margin-right: 13px;
}

.TagIcon {
margin-right: 4.27px;
font-weight: bold;
width: 11px;
vertical-align: text-top;
}

.MessageDetailsSender {
margin-left: 32px;
margin-top: 6px;
Expand Down
Loading