Skip to content

Commit

Permalink
Fixed-Issue-PalisadoesFoundation#1266 Bug Report When a new post is a…
Browse files Browse the repository at this point in the history
…dded, the latest post section in the organization's dashboard becomes distorted Updated
  • Loading branch information
gauravsingh94 committed Jan 10, 2024
1 parent e9f9b12 commit c470cfb
Show file tree
Hide file tree
Showing 2 changed files with 57 additions and 1 deletion.
27 changes: 26 additions & 1 deletion src/screens/OrganizationDashboard/OrganizationDashboard.test.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,12 @@ import { BrowserRouter } from 'react-router-dom';
import { store } from 'state/store';
import { StaticMockLink } from 'utils/StaticMockLink';
import OrganizationDashboard from './OrganizationDashboard';
import { EMPTY_MOCKS, ERROR_MOCKS, MOCKS } from './OrganizationDashboardMocks';
import {
EMPTY_MOCKS,
ERROR_MOCKS,
MOCKS,
EVENT_MOCK,
} from './OrganizationDashboardMocks';
import i18nForTest from 'utils/i18nForTest';
import { toast } from 'react-toastify';
import userEvent from '@testing-library/user-event';
Expand All @@ -24,6 +29,7 @@ async function wait(ms = 100): Promise<void> {
const link1 = new StaticMockLink(MOCKS, true);
const link2 = new StaticMockLink(EMPTY_MOCKS, true);
const link3 = new StaticMockLink(ERROR_MOCKS, true);
const link4 = new StaticMockLink(EVENT_MOCK, true);

jest.mock('react-toastify', () => ({
toast: {
Expand Down Expand Up @@ -219,4 +225,23 @@ describe('Organisation Dashboard Page', () => {
// Ensure that toast.success is called with 'Coming soon!'
expect(toast.success).toBeCalledWith('Coming soon!');
});

test('Checking for Upcoming Event is getting rendered or not.', async () => {
await act(async () => {
render(
<MockedProvider addTypename={false} link={link4}>
<BrowserRouter>
<Provider store={store}>
<I18nextProvider i18n={i18nForTest}>
<OrganizationDashboard />
</I18nextProvider>
</Provider>
</BrowserRouter>
</MockedProvider>
);
});

await wait();
expect(screen.getByText('Sample Event')).toBeInTheDocument();
});
});
31 changes: 31 additions & 0 deletions src/screens/OrganizationDashboard/OrganizationDashboardMocks.ts
Original file line number Diff line number Diff line change
Expand Up @@ -260,6 +260,37 @@ export const EMPTY_MOCKS = [
},
];

export const EVENT_MOCK = [
{
request: {
query: ORGANIZATION_EVENT_CONNECTION_LIST,
variables: {
organization_id: '6437904485008f171cf29924',
},
},
result: {
data: {
eventsByOrganizationConnection: [
{
_id: '1',
title: 'Sample Event',
description: 'Sample Description',
startDate: '2023-10-29T00:00:00.000Z',
endDate: '2023-10-29T23:59:59.000Z',
location: 'Sample Location',
startTime: '08:00:00',
endTime: '17:00:00',
allDay: false,
recurring: false,
isPublic: true,
isRegisterable: true,
},
],
},
},
},
];

export const ERROR_MOCKS = [
{
request: {
Expand Down

0 comments on commit c470cfb

Please sign in to comment.