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

[Bug Fix] - Issue-699/bug fix contacts message #700

Merged
merged 3 commits into from
Dec 13, 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
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
Loading