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

update outbox recipient text #695

Merged
merged 5 commits into from
Nov 20, 2024
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
6 changes: 4 additions & 2 deletions src/components/Messages/MessagePreview.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -74,10 +74,12 @@ const MessagePreview = ({ message, folderType }) => {
return 2;
};

const isInbox = folderType === 'Inbox';

const messageInfo = [
{
title: 'Sender: ',
text: message?.sender,
title: isInbox ? 'Sender: ' : 'Recipient: ',
text: isInbox ? message?.sender : message?.recipient,
xs_value: isSmallScreen ? 12 : renderMediumGridLeft()
},
{
Expand Down
24 changes: 21 additions & 3 deletions test/components/Messages/MessagePreview.test.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -7,10 +7,15 @@ import createMatchMedia from '../../helpers/createMatchMedia';

const queryClient = new QueryClient();

const mockMessageInfo = { sender: 'test', title: 'test title', uploadDate: new Date('1-1-2000') };
const MockMessagePreview = () => (
const mockMessageInfo = {
sender: 'test',
recipient: 'testrecipient',
title: 'test title',
uploadDate: new Date('1-1-2000')
};
const MockMessagePreview = ({ folderType = 'Inbox' }) => (
<QueryClientProvider client={queryClient}>
<MessagePreview message={mockMessageInfo} />
<MessagePreview message={mockMessageInfo} folderType={folderType} />
</QueryClientProvider>
);

Expand Down Expand Up @@ -54,3 +59,16 @@ describe('Grid sizes', () => {
expect(dateCell.classList.contains('MuiGrid-grid-xs-12')).toBe(true);
});
});

describe('Outbox shows Recipient instead of Sender', () => {
afterEach(() => {
cleanup();
});

it('renders Recipient text', () => {
const { getByText } = render(<MockMessagePreview folderType="Outbox" />);
const recipientCell = getByText('Recipient:').parentElement;

expect(recipientCell.classList.contains('MuiGrid-grid-xs-5')).toBe(true);
});
});
Loading