Skip to content

Commit

Permalink
Merge pull request #700 from codeforpdx/issue-699/bug-fix-contacts-me…
Browse files Browse the repository at this point in the history
…ssage

[Bug Fix] - Issue-699/bug fix contacts message
  • Loading branch information
leekahung authored Dec 13, 2024
2 parents 9e11756 + ac515af commit abc9c3b
Show file tree
Hide file tree
Showing 4 changed files with 25 additions and 3 deletions.
2 changes: 1 addition & 1 deletion env.template
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
VITE_SOLID_IDENTITY_PROVIDER="http://localhost:3000/"
VITE_SOLID_POD_SERVER="http://localhost:3000/"
VITE_SUGGESTED_OIDC_OPTIONS="http://localhost:3000/, https://opencommons.net/, https://solidcommunity.net/, https://login.inrupt.com/, https://inrupt.net/"
VITE_OIDC_WEBIDS = '{"http://localhost:3000/": "http://localhost:3000/user/profile/card#me", "https://opencommons.net/": "http://opencommons.net/user/profile/card#me", "https://solidcommunity.net/": "https://user.solidcommunity.net/profile/card#me", "https://login.inrupt.com/": "https://id.inrupt.com/user", "https://inrupt.net/": "https://id.inrupt.com/user"}'
VITE_OIDC_WEBIDS = '{"http://localhost:3000/": "http://localhost:3000/user/profile/card#me", "https://opencommons.net/": "https://opencommons.net/user/profile/card#me", "https://solidcommunity.net/": "https://user.solidcommunity.net/profile/card#me", "https://login.inrupt.com/": "https://id.inrupt.com/user", "https://inrupt.net/": "https://id.inrupt.com/user"}'
VITE_CLIENT_ID_DOC="http://localhost:3000/clientAppId.json"
4 changes: 3 additions & 1 deletion src/components/Modals/NewMessageModal.jsx
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
// React Imports
import React, { useContext, useEffect, useState } from 'react';
import { useLocation } from 'react-router-dom';
// Inrupt Library Imports
import { useMessageList, useNotification, useSession, useContactsList } from '@hooks';
// Material UI Imports
Expand Down Expand Up @@ -46,6 +47,7 @@ const NewMessageModal = ({ showModal, setShowModal, oldMessage = '', toField = '
const { podUrl } = useContext(SignedInUserContext);
const { addNotification } = useNotification();
const [originalMessage, setOriginalMessage] = useState(oldMessage.message);
const location = useLocation();

const [message, setMessage] = useState({
recipientPodUrl:
Expand Down Expand Up @@ -111,7 +113,7 @@ const NewMessageModal = ({ showModal, setShowModal, oldMessage = '', toField = '
await sendMessageTTL(session, messageWithTrimmedInputs, podUrl);

setMessage({
recipientPodUrl: '',
recipientPodUrl: location.pathname === '/contacts' ? toField : '',
title: '',
message: ''
});
Expand Down
12 changes: 11 additions & 1 deletion test/components/Messages/MessagePreview.test.jsx
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import React from 'react';
import { render, cleanup } from '@testing-library/react';
import { describe, expect, it, afterEach } from 'vitest';
import { describe, expect, it, afterEach, vi } from 'vitest';
import { MessagePreview } from '@components/Messages';
import { QueryClient, QueryClientProvider } from '@tanstack/react-query';
import createMatchMedia from '../../helpers/createMatchMedia';
Expand All @@ -19,6 +19,16 @@ const MockMessagePreview = ({ folderType = 'Inbox' }) => (
</QueryClientProvider>
);

vi.mock('react-router-dom', async () => {
const actual = vi.importActual('react-router-dom');
return {
...actual,
useLocation: vi.fn().mockReturnValue({
pathname: '/contacts'
})
};
});

describe('Grid sizes', () => {
afterEach(() => {
cleanup();
Expand Down
10 changes: 10 additions & 0 deletions test/components/Modals/NewMessageModal.test.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,16 @@ const MockNewMessageModal = () => (
</QueryClientProvider>
);

vi.mock('react-router-dom', async () => {
const actual = vi.importActual('react-router-dom');
return {
...actual,
useLocation: vi.fn().mockReturnValue({
pathname: '/contacts'
})
};
});

it('renders button group flex-direction as row default', () => {
const { getByRole } = render(<MockNewMessageModal />);
const cancelButton = getByRole('button', { name: 'Cancel' });
Expand Down

0 comments on commit abc9c3b

Please sign in to comment.