Skip to content

Commit 08b25ca

Browse files
Merge pull request #3525 from OneCommunityGlobal/development
Frontend Release to Main [4.17]
2 parents ab9b01a + 59ec2b2 commit 08b25ca

68 files changed

Lines changed: 10148 additions & 10773 deletions

File tree

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

.eslintignore

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -19,8 +19,8 @@ src/components/Badge/**
1919
src/components/Dashboard/**
2020
src/components/Projects/**
2121
src/components/SummaryManagement/**
22-
src/components/TaskEditSuggestions/**
2322
src/components/TeamMemberTasks/**
2423
src/components/Teams/TeamMembersPopup.jsx
2524
src/components/UserManagement/**
26-
src/components/UserProfile/**
25+
src/components/UserProfile/**
26+
src/components/Announcements/index.jsx

.prettierignore

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,6 @@ src/components/Memberships/**
1919
src/components/Projects/**
2020
src/components/Reports/**
2121
src/components/SummaryManagement/**
22-
src/components/TaskEditSuggestions/**
2322
src/components/TeamMemberTasks/**
2423
src/components/Timelog/**
2524
src/components/UserManagement/**

package-lock.json

Lines changed: 7195 additions & 10170 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

package.json

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,9 @@
2929
"history": "^4.10.1",
3030
"html-react-parser": "^1.4.14",
3131
"html-to-pdfmake": "^2.0.6",
32+
"html2canvas": "^1.4.1",
3233
"joi": "^14.0.6",
34+
"jspdf": "^3.0.1",
3335
"jwt-decode": "^2.2.0",
3436
"leaflet": "1.7.1",
3537
"leaflet.heat": "^0.2.0",
@@ -84,7 +86,7 @@
8486
"prestart": "npm run test",
8587
"postinstall": "node ./postinstall.js",
8688
"start": "react-scripts start",
87-
"build": "npm run postinstall && set CI=false && react-scripts build",
89+
"build": "npm run postinstall && cross-env GENERATE_SOURCEMAP=false CI=false react-scripts build",
8890
"test": "cross-env CI=true react-scripts test --env=jest-environment-jsdom-sixteen",
8991
"test:watch": " react-scripts test --env=jest-environment-jsdom-sixteen",
9092
"test:coverage": "cross-env CI=true react-scripts test --env=jest-environment-jsdom-sixteen --coverage",
Lines changed: 207 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,207 @@
1+
import axios from 'axios';
2+
import * as actions from '../../constants/weeklySummaries';
3+
import { ENDPOINTS } from '../../utils/URL';
4+
import { fetchWeeklySummariesBegin, fetchWeeklySummariesSuccess, fetchWeeklySummariesError, getWeeklySummaries, updateWeeklySummaries } from '../weeklySummaries'
5+
import { getUserProfileActionCreator } from "../userProfile";
6+
7+
8+
jest.mock('axios');
9+
10+
11+
describe('Weekly Summaries Action',() => {
12+
13+
it('Should return action FETCH_WEEKLY_SUMMARIES_BEGIN', () => {
14+
15+
const data = fetchWeeklySummariesBegin();
16+
17+
expect(data).toEqual( {type: actions.FETCH_WEEKLY_SUMMARIES_BEGIN });
18+
19+
});
20+
21+
it('Should fetch weekly summaries success', () => {
22+
23+
const weeklySummariesData = {
24+
id: 1,
25+
dueDate: "2024-12-29",
26+
summary: "Weekly Summary"
27+
};
28+
29+
const result = fetchWeeklySummariesSuccess(weeklySummariesData);
30+
31+
const expecteResult = {
32+
type: actions.FETCH_WEEKLY_SUMMARIES_SUCCESS,
33+
payload : {weeklySummariesData}
34+
}
35+
36+
expect(result).toEqual(expecteResult);
37+
38+
});
39+
40+
it('Should return action FETCH_WEEKLY_SUMMARIES_ERROR ', () => {
41+
42+
const error = {};
43+
const result = fetchWeeklySummariesError(error);
44+
45+
expect(result).toEqual({
46+
type: actions.FETCH_WEEKLY_SUMMARIES_ERROR,
47+
payload: {error}
48+
});
49+
})
50+
51+
});
52+
53+
describe('Weekly Summaries', () => {
54+
55+
jest.mock('axios');
56+
const dispatch = jest.fn();
57+
58+
beforeEach(() => {
59+
jest.clearAllMocks();
60+
});
61+
62+
describe('Get Weekly Summaries', () => {
63+
64+
it('Should dispatch actions and return status 200 on successful API call', async() => {
65+
66+
const mockData = {
67+
weeklySummariesCount : 1,
68+
weeklySummaries: [
69+
{
70+
id: "1",
71+
dueDate: "2024-12-29",
72+
summary: "Weekly Summary"
73+
}
74+
],
75+
mediaUrl: 'http://media.com',
76+
adminLinks: [{ Name: 'Media Folder', Link: 'http://newmedia.com' }]
77+
}
78+
79+
axios.get.mockResolvedValue({ data: mockData, status:200 });
80+
81+
const result = await getWeeklySummaries(1)(dispatch);
82+
83+
expect(dispatch).toHaveBeenCalledWith(fetchWeeklySummariesBegin());
84+
expect(dispatch).toHaveBeenCalledWith(fetchWeeklySummariesSuccess({
85+
weeklySummariesCount:1,
86+
weeklySummaries:[
87+
{
88+
id: "1",
89+
dueDate: "2024-12-29",
90+
summary: "Weekly Summary"
91+
}
92+
],
93+
mediaUrl: 'http://newmedia.com'
94+
}));
95+
96+
expect(dispatch).toHaveBeenCalledWith(getUserProfileActionCreator(mockData));
97+
expect(result).toBe(200);
98+
99+
});
100+
101+
it('Should dispatch an error action when GET request fails', async() => {
102+
103+
const mockError = { response : { status: 500 } };
104+
axios.get.mockRejectedValueOnce(mockError);
105+
106+
const result = await getWeeklySummaries(1)(dispatch);
107+
108+
expect(dispatch).toHaveBeenCalledWith(fetchWeeklySummariesBegin());
109+
expect(dispatch).toHaveBeenCalledWith(fetchWeeklySummariesError(mockError));
110+
expect(result).toBe(500);
111+
})
112+
113+
});
114+
115+
describe('Update Weekly Summaries', () => {
116+
117+
it('Should successfully update weekly summaries and return status 200', async() => {
118+
119+
const mockUserProfile = {
120+
firstName: 'User First Name',
121+
lastName: 'User Last Name',
122+
weeklySummariesCount : 0,
123+
weeklySummaries:[]
124+
}
125+
126+
const weeklySummariesData = {
127+
weeklySummariesCount : 1,
128+
weeklySummaries: [
129+
{
130+
id: "1",
131+
dueDate: "2025-01-05",
132+
summary: "Weekly Summary Week1"
133+
},
134+
],
135+
mediaUrl: 'http://media.com'
136+
}
137+
138+
axios.get.mockResolvedValue({ data: mockUserProfile });
139+
axios.put.mockResolvedValue({ status: 200 });
140+
141+
const result = await updateWeeklySummaries(1, weeklySummariesData )(dispatch);
142+
expect(result).toBe(200);
143+
expect(axios.get).toHaveBeenCalledWith(ENDPOINTS.USER_PROFILE(1));
144+
expect(axios.put).toHaveBeenCalled();
145+
expect(dispatch).toHaveBeenCalledWith(getUserProfileActionCreator({
146+
...mockUserProfile,
147+
'adminLinks' : [{ Name: 'Media Folder', Link: 'http://media.com' }] ,
148+
...weeklySummariesData
149+
}));
150+
151+
});
152+
153+
it('Ensure that if the "Media Folder" link already exists, it should be updated correctly.', async() => {
154+
155+
const mockUserProfile = {
156+
firstName: 'User First Name',
157+
lastName: 'User Last Name',
158+
weeklySummariesCount : 0,
159+
weeklySummaries:[],
160+
'adminLinks' : [{ Name: 'Media Folder', Link: 'http://media.com' }]
161+
}
162+
163+
const weeklySummariesData = {
164+
weeklySummariesCount : 1,
165+
weeklySummaries: [
166+
{
167+
id: "1",
168+
dueDate: "2025-01-05",
169+
summary: "Weekly Summary Week1"
170+
},
171+
],
172+
mediaUrl: 'http://newmedia.com'
173+
}
174+
175+
axios.get.mockResolvedValue({ data: mockUserProfile });
176+
axios.put.mockResolvedValue({ status: 200 });
177+
178+
const result = await updateWeeklySummaries(1, weeklySummariesData )(dispatch);
179+
expect(result).toBe(200);
180+
expect(axios.get).toHaveBeenCalledWith(ENDPOINTS.USER_PROFILE(1));
181+
expect(axios.put).toHaveBeenCalled();
182+
expect(dispatch).toHaveBeenCalledWith(getUserProfileActionCreator({
183+
...mockUserProfile,
184+
'adminLinks' : [{ Name: 'Media Folder', Link: 'http://newmedia.com' }] ,
185+
...weeklySummariesData
186+
}));
187+
188+
});
189+
190+
it('Should throw error when API request fails', async() => {
191+
192+
const mockError = { response : { status: 500 } };
193+
axios.get.mockRejectedValueOnce(mockError);
194+
195+
const result = await updateWeeklySummaries(1, {
196+
mediaUrl: 'http://newmedia.com',
197+
weeklySummaries: [],
198+
weeklySummariesCount: 2 })(dispatch);
199+
200+
expect(dispatch).not.toHaveBeenCalled();
201+
expect(result).toBe(500);
202+
203+
});
204+
205+
});
206+
207+
});

0 commit comments

Comments
 (0)