Skip to content

Commit

Permalink
sync with master
Browse files Browse the repository at this point in the history
  • Loading branch information
mdshamoon committed Mar 31, 2021
2 parents 60ac47a + cc613cf commit 8dab583
Show file tree
Hide file tree
Showing 17 changed files with 351 additions and 86 deletions.
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "glific-frontend",
"version": "1.2.1",
"version": "1.3.0",
"private": true,
"dependencies": {
"@absinthe/socket": "^0.2.1",
Expand Down
7 changes: 7 additions & 0 deletions src/common/utils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -60,3 +60,10 @@ export const copyToClipboardMethod = (client: any, text: string) => {
};

export { copyToClipboardMethod as copyToClipboard };

export const addLogsMethod = (event: string, logData: any) => {
setLogs(event, 'info');
setLogs(`variables-${logData}`, 'info');
};

export { addLogsMethod as addLogs };
17 changes: 11 additions & 6 deletions src/containers/BlockContact/BlockContactList/BlockContactList.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ import { SEARCH_QUERY_VARIABLES } from '../../../common/constants';
import { CONTACT_SEARCH_QUERY, GET_CONTACT_COUNT } from '../../../graphql/queries/Contact';
import { DELETE_CONTACT, UPDATE_CONTACT } from '../../../graphql/mutations/Contact';
import { SEARCH_QUERY } from '../../../graphql/queries/Search';
import { addLogs } from '../../../common/utils';

export interface BlockContactListProps {}

Expand Down Expand Up @@ -76,13 +77,17 @@ export const BlockContactList: React.SFC<BlockContactListProps> = () => {
};

const handleUnblock = () => {
unblockContact({
variables: {
id: contactId,
input: {
status: 'VALID',
},
const variables = {
id: contactId,
input: {
status: 'VALID',
},
};

addLogs(`Unblock contact-${contactId}`, variables);

unblockContact({
variables,
});
};

Expand Down
4 changes: 3 additions & 1 deletion src/containers/Chat/Chat.test.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -109,7 +109,9 @@ describe('<Chat />', () => {
});

test('check condition when no subscription data provided', async () => {
const { findByTestId } = render(wrapper);
const { getByText, findByTestId } = render(wrapper);

expect(getByText('Loading...')).toBeInTheDocument();

const ChatConversation = await findByTestId('beneficiaryName');
expect(ChatConversation).toHaveTextContent('Effie Cormier');
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@ import {
} from '../../../../common/constants';
import { updateConversations } from '../../../../services/ChatService';
import { showMessages } from '../../../../common/responsive';
import { addLogs } from '../../../../common/utils';

interface ConversationListProps {
searchVal: string;
Expand Down Expand Up @@ -214,12 +215,14 @@ export const ConversationList: React.SFC<ConversationListProps> = (props) => {
useEffect(() => {
// Use multi search when has search value and when there is no collection id
if (searchVal && Object.keys(searchParam).length === 0 && !selectedCollectionId) {
addLogs(`Use multi search when has search value`, filterSearch());
getFilterSearch({
variables: filterSearch(),
});
} else {
// This is used for filtering the searches, when you click on it, so only call it
// when user clicks and savedSearchCriteriaId is set.
addLogs(`filtering the searches`, filterVariables());
getFilterConvos({
variables: filterVariables(),
});
Expand Down
65 changes: 65 additions & 0 deletions src/containers/Chat/ChatMessages/ChatMessages.test.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -295,3 +295,68 @@ test('Collection: if cache', async () => {
fireEvent.click(getByTestId('jumpToLatest'));
});
});

test('click on Clear conversation', async () => {
const chatMessages = (
<ApolloProvider client={client}>
<ChatMessages contactId="2" />
</ApolloProvider>
);
const { getByTestId } = render(chatMessages);
await waitFor(() => {
fireEvent.click(getByTestId('dropdownIcon'));
fireEvent.click(getByTestId('clearChatButton'));
// need to check this
// fireEvent.click(getByTestId('ok-button'));
// expect(getByTestId('app')).toHaveTextContent('Conversation cleared for this contact');
});
});

test('Load more messages', async () => {
const searchQuery = {
query: SEARCH_QUERY,
variables: {
filter: {},
contactOpts: { limit: DEFAULT_CONTACT_LIMIT },
messageOpts: { limit: DEFAULT_MESSAGE_LIMIT },
},
data: {
search: [
{
group: null,
contact: {
id: '2',
name: 'Effie Cormier',
phone: '987654321',
maskedPhone: '98****321',
lastMessageAt: '2020-06-29T09:31:47Z',
status: 'VALID',
bspStatus: 'SESSION_AND_HSM',
isOrgRead: true,
},
messages: new Array(20).fill(body),
},
],
},
};

cache.writeQuery(searchQuery);
const client = new ApolloClient({
cache: cache,
assumeImmutableResults: true,
});

const chatMessages = (
<ApolloProvider client={client}>
<ChatMessages contactId="2" />
</ApolloProvider>
);

const { getByTestId } = render(chatMessages);

await waitFor(() => {
const container: any = document.querySelector('.messageContainer');
fireEvent.scroll(container, { target: { scrollY: 0 } });
fireEvent.click(getByTestId('loadMoreMessages'));
});
});
Loading

0 comments on commit 8dab583

Please sign in to comment.