Skip to content
Open
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
3 changes: 1 addition & 2 deletions .buildpacks
Original file line number Diff line number Diff line change
@@ -1,3 +1,2 @@
https://github.com/heroku/heroku-buildpack-nodejs.git#v183
https://github.com/mars/create-react-app-inner-buildpack.git#v9.0.0
https://github.com/heroku/heroku-buildpack-static.git#v5
https://github.com/heroku/heroku-buildpack-nginx.git
1 change: 1 addition & 0 deletions Procfile
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
web: bin/start-nginx
35 changes: 35 additions & 0 deletions config/nginx.conf.erb
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
daemon off;

worker_processes <%= ENV['NGINX_WORKERS'] || 4 %>;

events {
use epoll;
accept_mutex on;
worker_connections 1024;
}

http {
include mime.types;
gzip on;
gzip_types text/plain text/css application/json application/javascript text/xml application/xml application/xml+rss text/javascript;

server {
listen <%= ENV['PORT'] %>;
root /app/build;
index index.html;

add_header X-Content-Type-Options "nosniff" always;
add_header X-XSS-Protection "1; mode=block" always;
add_header X-Frame-Options "deny" always;
add_header Strict-Transport-Security "max-age=63072000; includeSubdomains; preload" always;
add_header Content-Security-Policy "default-src * data:; script-src 'self' 'unsafe-inline' 'unsafe-eval' blob:; script-src-elem 'self' 'unsafe-inline' https://www.google.com https://www.gstatic.com https://js.stripe.com; frame-src 'self' https://js.stripe.com https://www.canva.com https://www.google.com https://www.gstatic.com data:; style-src 'self' 'unsafe-inline' https://fonts.googleapis.com; font-src 'self' data: https://fonts.gstatic.com; connect-src *;" always;

if ($http_x_forwarded_proto != "https") {
return 301 https://$host$request_uri;
}

location / {
try_files $uri $uri/ /index.html;
}
}
}
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": "6.9.0",
"version": "6.9.1",
"private": true,
"type": "module",
"license": {
Expand Down
4 changes: 0 additions & 4 deletions src/containers/Auth/Auth.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -15,8 +15,6 @@ import setLogs from 'config/logs';
import { checkOrgStatus } from 'services/AuthService';
import { TERMS_OF_USE_LINK } from 'common/constants';

import { Promotion } from './Promotion/Promotion';

export interface AuthProps {
pageTitle: string;
buttonText: string;
Expand Down Expand Up @@ -302,8 +300,6 @@ export const Auth = ({
</>
) : null}
</div>

{mode === 'login' && <Promotion />}
</div>
);
};
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
import { MockedProvider } from '@apollo/client/testing';
import { fireEvent, render } from '@testing-library/react';
import dayjs from 'dayjs';
import { MockedProvider } from '@apollo/client/testing';
import { MemoryRouter } from 'react-router';

import { MARK_AS_READ } from 'graphql/mutations/Chat';
import { SHORT_DATE_FORMAT } from 'common/constants';
import { MARK_AS_READ } from 'graphql/mutations/Chat';
import ChatConversation from './ChatConversation';

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

test('it should not throw when lastMessage body is null', () => {
const props = {
...defaultProps,
highlightSearch: 'test',
lastMessage: { body: null, insertedAt, type: 'TEXT' },
};
expect(() => render(wrapperContainer(props))).not.toThrow();
});

test('it should not throw when lastMessage body is undefined', () => {
const props = {
...defaultProps,
highlightSearch: 'test',
lastMessage: { body: undefined, insertedAt, type: 'TEXT' },
};
expect(() => render(wrapperContainer(props))).not.toThrow();
});

test('it should truncate message body longer than 35 characters', () => {
const longBody = 'This is a very long message that exceeds the limit';
const props = {
...defaultProps,
lastMessage: { body: longBody, insertedAt, type: 'TEXT' },
};
const { getByTestId } = render(wrapperContainer(props));
expect(getByTestId('content').textContent).toContain('...');
});

test('it should not truncate message body within 35 characters', () => {
const shortBody = 'Short message';
const props = {
...defaultProps,
lastMessage: { body: shortBody, insertedAt, type: 'TEXT' },
};
const { getByTestId } = render(wrapperContainer(props));
expect(getByTestId('content').textContent).not.toContain('...');
});

test('it should replace newlines with spaces in TEXT messages', () => {
const props = {
...defaultProps,
lastMessage: { body: 'Hello\nWorld', insertedAt, type: 'TEXT' },
};
const { getByTestId } = render(wrapperContainer(props));
expect(getByTestId('content').textContent).not.toContain('\n');
});
Original file line number Diff line number Diff line change
@@ -1,18 +1,18 @@
import { useApolloClient, useMutation } from '@apollo/client';
import { ListItemButton } from '@mui/material';
import { Link, useLocation } from 'react-router';
import dayjs from 'dayjs';
import { useApolloClient, useMutation } from '@apollo/client';
import { Link, useLocation } from 'react-router';

import { COMPACT_MESSAGE_LENGTH, SHORT_DATE_FORMAT } from 'common/constants';
import { MARK_AS_READ } from 'graphql/mutations/Chat';
import { SEARCH_OFFSET } from 'graphql/queries/Search';
import { WhatsAppToJsx } from 'common/RichEditor';
import { MessageType } from '../MessageType/MessageType';
import styles from './ChatConversation.module.css';
import Track from 'services/TrackService';
import { slicedString, updateContactCache } from 'common/utils';
import { AvatarDisplay } from 'components/UI/AvatarDisplay/AvatarDisplay';
import { Timer } from 'components/UI/Timer/Timer';
import { MARK_AS_READ } from 'graphql/mutations/Chat';
import { SEARCH_OFFSET } from 'graphql/queries/Search';
import Track from 'services/TrackService';
import { MessageType } from '../MessageType/MessageType';
import styles from './ChatConversation.module.css';

export interface ChatConversationProps {
entityId: number;
Expand All @@ -24,7 +24,7 @@ export interface ChatConversationProps {
index: number;
lastMessage: {
id: number;
body: string;
body: string | null | undefined;
insertedAt: string;
type: string;
media: any;
Expand Down Expand Up @@ -130,13 +130,11 @@ const ChatConversation = ({
}

const name = slicedString(contactName, 20);

const { type, body } = lastMessage;
const isTextType = type === 'TEXT';
let originalText = body ?? '';
let displayMSG: any = <MessageType type={type} body={originalText} />;

let displayMSG: any = <MessageType type={type} body={body} />;

let originalText = body;
if (isTextType) {
// let's shorten the text message to display correctly
if (originalText.length > COMPACT_MESSAGE_LENGTH) {
Expand Down Expand Up @@ -203,7 +201,7 @@ const ChatConversation = ({
{name}
</div>
<div className={styles.MessageContent} data-testid="content">
{isTextType && highlightSearch ? BoldedText(body, highlightSearch) : displayMSG}
{isTextType && highlightSearch ? BoldedText(originalText, highlightSearch) : displayMSG}
</div>
</div>
<div>
Expand Down
16 changes: 0 additions & 16 deletions static.json

This file was deleted.

Loading