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

Fix Misplaced Screen Title & Fix Layout Structure #2412

Merged
merged 32 commits into from
Nov 8, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
32 commits
Select commit Hold shift + click to select a range
b4a147c
solved posts title spacing issues
VanshikaSabharwal Oct 26, 2024
f09e77d
updated Posts.tsx
VanshikaSabharwal Oct 26, 2024
a58b4ec
updated Posts.tsx
VanshikaSabharwal Oct 26, 2024
e46ca48
Merge branch 'develop' into postTitle
VanshikaSabharwal Oct 30, 2024
cafdc71
Merge branch 'develop' into postTitle
VanshikaSabharwal Oct 30, 2024
3d91a36
tried to fix test errors
VanshikaSabharwal Oct 30, 2024
aae4495
tried to fix test errors
VanshikaSabharwal Oct 30, 2024
2eaa442
fixing recommended tests
VanshikaSabharwal Oct 30, 2024
4e37d03
Merge branch 'develop' into postTitle
varshith257 Nov 2, 2024
307c432
Merge branch 'develop' into postTitle
VanshikaSabharwal Nov 5, 2024
b3e2296
passed all tests
VanshikaSabharwal Nov 5, 2024
864cb77
all tests passed
VanshikaSabharwal Nov 5, 2024
3cc7e7d
testing schema.graphql
VanshikaSabharwal Nov 6, 2024
6894029
added test coverage in Post
VanshikaSabharwal Nov 6, 2024
e75745f
did mentioned changes
VanshikaSabharwal Nov 6, 2024
b942e30
Merge branch 'develop' into postTitle
VanshikaSabharwal Nov 6, 2024
006a6c7
did recommended changes
VanshikaSabharwal Nov 6, 2024
31f3d00
changes added
VanshikaSabharwal Nov 7, 2024
efbf6d3
Merge branch 'develop' into postTitle
VanshikaSabharwal Nov 7, 2024
255a6e1
added changes to schema.graphql
VanshikaSabharwal Nov 7, 2024
9715b32
commiting pulled requests
VanshikaSabharwal Nov 7, 2024
250beb0
reverted changes from schema.graphql file
VanshikaSabharwal Nov 7, 2024
e4e72c1
Update schema.graphql
VanshikaSabharwal Nov 7, 2024
98eb4eb
Update schema.graphql
VanshikaSabharwal Nov 7, 2024
d9d93fc
Updated schema.graphql
VanshikaSabharwal Nov 7, 2024
6ed678d
Update schema.graphql
VanshikaSabharwal Nov 7, 2024
393874f
Updates schema.graphql
VanshikaSabharwal Nov 7, 2024
e0f8376
Update schema.graphql
VanshikaSabharwal Nov 7, 2024
e072b0d
Update schema.graphql
VanshikaSabharwal Nov 7, 2024
df8a5cc
updated schema.graphql
VanshikaSabharwal Nov 7, 2024
a5d0e28
updated schema.graphql
VanshikaSabharwal Nov 7, 2024
3da8ce2
adding more code coverage
VanshikaSabharwal Nov 7, 2024
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
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ import {
waitFor,
} from '@testing-library/react';
import { MockedProvider } from '@apollo/react-testing';
import { I18nextProvider, useTranslation } from 'react-i18next';
import { I18nextProvider } from 'react-i18next';
import { USERS_CONNECTION_LIST } from 'GraphQl/Queries/Queries';
import { BrowserRouter } from 'react-router-dom';
import { Provider } from 'react-redux';
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,6 @@ import type { InterfaceQueryUserListItem } from 'utils/interfaces';
import { USERS_CONNECTION_LIST } from 'GraphQl/Queries/Queries';
import Loader from 'components/Loader/Loader';
import { Search } from '@mui/icons-material';
import { useTranslation } from 'react-i18next';
import { useParams } from 'react-router-dom';

interface InterfaceCreateDirectChatProps {
Expand All @@ -25,10 +24,10 @@ interface InterfaceCreateDirectChatProps {
chatsListRefetch: (
variables?:
| Partial<{
id: any;
id: string;
}>
| undefined,
) => Promise<ApolloQueryResult<any>>;
) => Promise<ApolloQueryResult<string>>;
}

/**
Expand Down Expand Up @@ -62,10 +61,6 @@ export default function createDirectChatModal({
createDirectChatModalisOpen,
chatsListRefetch,
}: InterfaceCreateDirectChatProps): JSX.Element {
const { t } = useTranslation('translation', {
keyPrefix: 'userChat',
});

const { orgId: organizationId } = useParams();

const userId: string | null = getItem('userId');
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,6 @@ import type { InterfaceQueryUserListItem } from 'utils/interfaces';
import { USERS_CONNECTION_LIST } from 'GraphQl/Queries/Queries';
import Loader from 'components/Loader/Loader';
import { Search } from '@mui/icons-material';
import { useTranslation } from 'react-i18next';

interface InterfaceCreateGroupChatProps {
toggleCreateGroupChatModal: () => void;
Expand All @@ -36,7 +35,7 @@ interface InterfaceCreateGroupChatProps {
id: string;
}>
| undefined,
) => Promise<ApolloQueryResult<any>>;
) => Promise<ApolloQueryResult<string>>;
}

interface InterfaceOrganization {
Expand Down Expand Up @@ -94,10 +93,6 @@ export default function CreateGroupChat({
createGroupChatModalisOpen,
chatsListRefetch,
}: InterfaceCreateGroupChatProps): JSX.Element {
const { t } = useTranslation('translation', {
keyPrefix: 'userChat',
});

const userId: string | null = getItem('userId');

const [createChat] = useMutation(CREATE_CHAT);
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import React from 'react';
import { act } from '@testing-library/react';
import { fireEvent, render, screen } from '@testing-library/react';
import { act, fireEvent, render, screen } from '@testing-library/react';

import { MockedProvider } from '@apollo/react-testing';
import { I18nextProvider } from 'react-i18next';

Expand Down
3 changes: 1 addition & 2 deletions src/components/UserPortal/UserSidebar/UserSidebar.test.tsx
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import React, { act } from 'react';
import type { RenderResult } from '@testing-library/react';
import { fireEvent, render, screen, waitFor } from '@testing-library/react';
import { fireEvent, render, screen } from '@testing-library/react';
import { MockedProvider } from '@apollo/react-testing';
import { I18nextProvider } from 'react-i18next';
import styles from './UserSidebar.module.css';
Expand All @@ -15,7 +15,6 @@ import i18nForTest from 'utils/i18nForTest';
import { StaticMockLink } from 'utils/StaticMockLink';
import UserSidebar from './UserSidebar';
import useLocalStorage from 'utils/useLocalstorage';
import userEvent from '@testing-library/user-event';

const { setItem } = useLocalStorage();

Expand Down
4 changes: 2 additions & 2 deletions src/screens/UserPortal/Chat/Chat.test.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -1545,7 +1545,7 @@ describe('Testing Chat Screen [User Portal]', () => {
).toBeInTheDocument();
});

test('Test create new direct chat', async () => {
test('create new direct chat', async () => {
const mock = [
...USER_JOINED_ORG_MOCK,
...GROUP_CHAT_BY_ID_QUERY_MOCK,
Expand Down Expand Up @@ -1585,7 +1585,7 @@ describe('Testing Chat Screen [User Portal]', () => {
fireEvent.click(closeButton);
});

test('Test create new group chat', async () => {
test('create new group chat', async () => {
const mock = [
...USER_JOINED_ORG_MOCK,
...GROUP_CHAT_BY_ID_QUERY_MOCK,
Expand Down
79 changes: 21 additions & 58 deletions src/screens/UserPortal/Posts/Posts.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -52,34 +52,16 @@ type Ad = {
endDate: string; // Assuming it's a string in the format 'yyyy-MM-dd'
startDate: string; // Assuming it's a string in the format 'yyyy-MM-dd'
};
interface InterfaceAdContent {
_id: string;
name: string;
type: string;
organization: {
_id: string;
};
mediaUrl: string;
endDate: string;
startDate: string;

comments: InterfacePostComments;
likes: InterfacePostLikes;
}

type AdvertisementsConnection = {
edges: {
node: InterfaceAdContent;
}[];
};

type InterfacePostComments = {
id: string;
creator: {
_id: string;
id: string;
firstName: string;
lastName: string;
email: string;
};

likeCount: number;
likedBy: {
id: string;
Expand Down Expand Up @@ -226,42 +208,24 @@ export default function home(): JSX.Element {
comments,
} = node;

const allLikes: any = [];

likedBy.forEach((value: any) => {
const singleLike = {
firstName: value.firstName,
lastName: value.lastName,
id: value._id,
};
allLikes.push(singleLike);
});

const postComments: any = [];

comments.forEach((value: any) => {
const commentLikes: any = [];
value.likedBy.forEach((commentLike: any) => {
const singleLike = {
id: commentLike._id,
};
commentLikes.push(singleLike);
});

const comment = {
id: value._id,
creator: {
firstName: value.creator.firstName,
lastName: value.creator.lastName,
id: value.creator._id,
email: value.creator.email,
},
likeCount: value.likeCount,
likedBy: commentLikes,
text: value.text,
};
postComments.push(comment);
});
const allLikes: InterfacePostLikes = likedBy.map((value) => ({
firstName: value.firstName,
lastName: value.lastName,
id: value._id,
}));

const postComments: InterfacePostComments = comments?.map((value) => ({
id: value.id,
creator: {
firstName: value.creator?.firstName ?? '',
lastName: value.creator?.lastName ?? '',
id: value.creator?.id ?? '',
email: value.creator?.email ?? '',
},
likeCount: value.likeCount,
likedBy: value.likedBy?.map((like) => ({ id: like?.id ?? '' })) ?? [],
text: value.text,
}));

const date = new Date(node.createdAt);
const formattedDate = new Intl.DateTimeFormat('en-US', {
Expand Down Expand Up @@ -311,7 +275,6 @@ export default function home(): JSX.Element {
<>
<div className={`d-flex flex-row ${styles.containerHeight}`}>
<div className={`${styles.colorLight} ${styles.mainContainer}`}>
<h1>{t('posts')}</h1>
<div className={`${styles.postContainer}`}>
<div className={`${styles.heading}`}>{t('startPost')}</div>
<div className={styles.postInputContainer}>
Expand Down
10 changes: 6 additions & 4 deletions src/screens/UserPortal/UserScreen/UserScreen.test.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ import { fireEvent, render, screen } from '@testing-library/react';
import { I18nextProvider } from 'react-i18next';
import 'jest-location-mock';
import { Provider } from 'react-redux';
import { BrowserRouter } from 'react-router-dom';
import { BrowserRouter, useNavigate } from 'react-router-dom';
import { store } from 'state/store';
import i18nForTest from 'utils/i18nForTest';
import UserScreen from './UserScreen';
Expand Down Expand Up @@ -87,7 +87,7 @@ describe('Testing LeftDrawer in OrganizationScreen', () => {
);

const titleElement = screen.getByRole('heading', { level: 1 });
expect(titleElement).toHaveTextContent('');
expect(titleElement).toHaveTextContent('Posts');
});

test('renders the correct title based on the titleKey', () => {
Expand All @@ -109,7 +109,7 @@ describe('Testing LeftDrawer in OrganizationScreen', () => {
expect(titleElement).toHaveTextContent('People');
});

test('Testing LeftDrawer in page functionality', async () => {
test('LeftDrawer should toggle correctly based on window size and user interaction', async () => {
render(
<MockedProvider addTypename={false} link={link}>
<BrowserRouter>
Expand Down Expand Up @@ -138,8 +138,10 @@ describe('Testing LeftDrawer in OrganizationScreen', () => {
expect(icon).toHaveClass('fa fa-angle-double-left');
});

test('should be redirected to / if orgId is undefined', async () => {
test('should be redirected to root when orgId is undefined', async () => {
mockID = undefined;
const navigate = jest.fn();
jest.spyOn({ useNavigate }, 'useNavigate').mockReturnValue(navigate);
render(
<MockedProvider addTypename={false} link={link}>
<BrowserRouter>
Expand Down
2 changes: 1 addition & 1 deletion src/screens/UserPortal/UserScreen/UserScreen.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -131,7 +131,7 @@ const UserScreen = (): JSX.Element => {
>
<div className="d-flex justify-content-between align-items-center">
<div style={{ flex: 1 }}>
<h1>{titleKey !== 'home' ? t('title') : ''}</h1>
<h1>{t('title')}</h1>
</div>
<ProfileDropdown />
</div>
Expand Down
Loading