Skip to content

Commit

Permalink
fixed all test cases
Browse files Browse the repository at this point in the history
  • Loading branch information
mdshamoon committed Jan 10, 2023
1 parent 1b84aee commit 5bf5344
Show file tree
Hide file tree
Showing 23 changed files with 149 additions and 580 deletions.
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 @@ -148,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 @@ -119,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 @@ -153,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
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 @@ -24,12 +24,6 @@ const Props: any = (link: any) => {
popup: 1,
open: true,
insertedAt,
tags: [
{
id: 1,
label: 'important',
},
],
type: link,
media: { url: 'http://glific.com' },
errors: '{}',
Expand Down Expand Up @@ -243,7 +237,6 @@ describe('<ChatMessage />', () => {
},
insertedAt: '2021-05-25T14:09:43.623251Z',
location: null,
tags: [],
errors: '{}',
contextMessage: null,
popup: true,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,6 @@ export interface ChatMessageProps {
media: any;
insertedAt: string;
onClick?: any;
tags: Array<any>;
popup: any;
setDialog?: any;
focus?: boolean;
Expand Down
52 changes: 3 additions & 49 deletions src/containers/Chat/ChatMessages/ChatMessages.test.json
Original file line number Diff line number Diff line change
Expand Up @@ -16,17 +16,7 @@
},
"sender": {
"id": "194"
},
"tags": [
{
"id": "20",
"label": "Participant"
},
{
"id": "15",
"label": "Help"
}
]
}
},
{
"body": "Rich gifts wax poor when givers prove unkind.",
Expand All @@ -37,8 +27,7 @@
},
"sender": {
"id": "1"
},
"tags": []
}
},
{
"body": "What's in a name? That which we call a rose by any other name would smell as sweet.",
Expand All @@ -49,21 +38,7 @@
},
"sender": {
"id": "194"
},
"tags": [
{
"id": "2",
"label": "Contacts"
},
{
"id": "8",
"label": "Important"
},
{
"id": "6",
"label": "Thank You"
}
]
}
}
]
},
Expand All @@ -83,7 +58,6 @@
"sender": {
"id": "1"
},
"tags": [],
"errors": "{}"
},
{
Expand All @@ -96,16 +70,6 @@
"sender": {
"id": "36"
},
"tags": [
{
"id": "17",
"label": "Sequence"
},
{
"id": "8",
"label": "Important"
}
],
"errors": "{}"
},
{
Expand All @@ -118,16 +82,6 @@
"sender": {
"id": "36"
},
"tags": [
{
"id": "16",
"label": "Numeric"
},
{
"id": "1",
"label": "Messages"
}
],
"errors": "{}"
}
]
Expand Down
8 changes: 0 additions & 8 deletions src/containers/Chat/ChatMessages/ChatMessages.test.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -30,13 +30,6 @@ const body = {
sender: {
id: '2',
},
tags: [
{
id: '1',
label: 'important',
colorCode: '#00d084',
},
],
type: 'TEXT',
media: null,
errors: '{}',
Expand Down Expand Up @@ -176,7 +169,6 @@ export const collection = {
sender: {
id: '1',
},
tags: null,
type: 'TEXT',
media: null,
errors: '{}',
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -45,13 +45,6 @@ const body = {
sender: {
id: '2',
},
tags: [
{
id: '1',
label: 'important',
colorCode: '#00d084',
},
],
type: 'TEXT',
media: null,
errors: '{}',
Expand Down Expand Up @@ -136,7 +129,6 @@ cache.writeQuery({
sender: {
id: '1',
},
tags: null,
type: 'TEXT',
media: null,
errors: '{}',
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -36,13 +36,6 @@ cache.writeQuery({
sender: {
id: '2',
},
tags: [
{
id: '1',
label: 'important',
colorCode: '#00d084',
},
],
type: 'TEXT',
media: null,
errors: null,
Expand Down
15 changes: 11 additions & 4 deletions src/containers/Form/FormLayout.test.helper.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,10 +6,12 @@ import { getOrganizationLanguagesQuery, getOrganizationQuery } from 'mocks/Organ
import { CREATE_FLOW, DELETE_FLOW, UPDATE_FLOW } from 'graphql/mutations/Flow';
import { Checkbox } from 'components/UI/Form/Checkbox/Checkbox';
import { GET_FLOW } from 'graphql/queries/Flow';
import { filterFlowQuery, getFlowCountQuery, getFlowQuery } from 'mocks/Flow';
import { FormLayoutProps } from './FormLayout';

const FormSchema = Yup.object();

export const listItemProps = {
export const listItemProps: FormLayoutProps = {
deleteItemQuery: DELETE_FLOW,
states: {
isActive: true,
Expand All @@ -21,7 +23,6 @@ export const listItemProps = {
roles: [],
},
setStates: jest.fn(),
setValidation: jest.fn(),
listItemName: 'flow',
dialogMessage: "You won't be able to use this flow again.",
formFields: [
Expand Down Expand Up @@ -74,8 +75,14 @@ export const listItemProps = {
createItemQuery: CREATE_FLOW,
updateItemQuery: UPDATE_FLOW,
validationSchema: FormSchema,
languageSupport: false,
icon: null,
getLanguageId: Function,
};

export const LIST_ITEM_MOCKS = [...getOrganizationQuery, getOrganizationLanguagesQuery];
export const LIST_ITEM_MOCKS = [
...getOrganizationQuery,
getOrganizationLanguagesQuery,
getFlowQuery,
filterFlowQuery,
getFlowCountQuery,
];
Loading

0 comments on commit 5bf5344

Please sign in to comment.