Skip to content

Commit 512b53b

Browse files
authored
Merge branch 'development' into venkataramanan_fix_team_member_task_time_center_alignment
2 parents 5c9c6c8 + 48ad605 commit 512b53b

87 files changed

Lines changed: 8675 additions & 5600 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.

package.json

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -55,7 +55,7 @@
5555
"date-fns-tz": "^2.0.1",
5656
"dayjs": "^1.11.13",
5757
"diff": "^8.0.3",
58-
"dompurify": "^3.2.5",
58+
"dompurify": "^3.3.2",
5959
"elliptic": "^6.6.1",
6060
"font-awesome": "^4.7.0",
6161
"fs-extra": "^11.3.0",
@@ -129,7 +129,9 @@
129129
},
130130
"resolutions": {
131131
"react": "18.3.1",
132-
"react-dom": "18.3.1"
132+
"react-dom": "18.3.1",
133+
"mdn-data": "2.12.2",
134+
"ansi-escapes": "7.1.1"
133135
},
134136
"packageManager": "yarn@1.22.22",
135137
"scripts": {
Lines changed: 67 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,67 @@
1+
import axios from 'axios';
2+
import configureMockStore from 'redux-mock-store';
3+
import thunk from 'redux-thunk';
4+
5+
import * as types from '../../constants/WeeklySummaryEmailBccConstants';
6+
import { updateWeeklySummaryEmailAssignment } from '../weeklySummaryEmailBCCAction';
7+
8+
vi.mock('axios');
9+
10+
const mockStore = configureMockStore([thunk]);
11+
12+
describe('updateWeeklySummaryEmailAssignment action creator', () => {
13+
it('dispatches updated assignment when API returns wrapped assignment payload', async () => {
14+
const store = mockStore({});
15+
const updatedAssignment = {
16+
_id: 'assignment-id',
17+
email: 'updated@example.com',
18+
assignedTo: { _id: 'user-id', firstName: 'Updated', lastName: 'User' },
19+
};
20+
21+
axios.put.mockResolvedValue({
22+
status: 200,
23+
data: { assignment: updatedAssignment },
24+
});
25+
26+
await store.dispatch(updateWeeklySummaryEmailAssignment('assignment-id', 'updated@example.com'));
27+
28+
expect(store.getActions()).toContainEqual({
29+
type: types.UPDATE_WEEKLY_SUMMARY_EMAIL_ASSIGNMENT,
30+
payload: updatedAssignment,
31+
});
32+
});
33+
34+
it('dispatches updated assignment when API returns assignment directly', async () => {
35+
const store = mockStore({});
36+
const updatedAssignment = {
37+
_id: 'assignment-id',
38+
email: 'updated@example.com',
39+
};
40+
41+
axios.put.mockResolvedValue({
42+
status: 200,
43+
data: updatedAssignment,
44+
});
45+
46+
await store.dispatch(updateWeeklySummaryEmailAssignment('assignment-id', 'updated@example.com'));
47+
48+
expect(store.getActions()).toContainEqual({
49+
type: types.UPDATE_WEEKLY_SUMMARY_EMAIL_ASSIGNMENT,
50+
payload: updatedAssignment,
51+
});
52+
});
53+
54+
it('dispatches error action when update fails', async () => {
55+
const store = mockStore({});
56+
const error = new Error('Network Error');
57+
58+
axios.put.mockRejectedValue(error);
59+
60+
await store.dispatch(updateWeeklySummaryEmailAssignment('assignment-id', 'updated@example.com'));
61+
62+
expect(store.getActions()).toContainEqual({
63+
type: types.WEEKLY_SUMMARY_EMAIL_ASSIGNMENT_ERROR,
64+
payload: error,
65+
});
66+
});
67+
});

src/actions/weeklySummaryEmailBCCAction.js

Lines changed: 12 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,11 @@ const weeklySummaryEmailBccError = error => ({
2424
payload: error,
2525
});
2626

27+
const updateWeeklySummaryEmailBcc = assignment => ({
28+
type: types.UPDATE_WEEKLY_SUMMARY_EMAIL_ASSIGNMENT,
29+
payload: assignment,
30+
});
31+
2732
// fetch all assignments
2833
export const getAllWeeklySummaryEmailAssignments = () => {
2934
const url = ENDPOINTS.WEEKLY_SUMMARY_EMAIL_BCC();
@@ -79,11 +84,17 @@ export const updateWeeklySummaryEmailAssignment = (id, email) => async dispatch
7984
try {
8085
const response = await axios.put(ENDPOINTS.UPDATE_WEEKLY_SUMMARY_EMAIL_BCC(id), { email });
8186
if (response.status === 200) {
82-
dispatch(getAllWeeklySummaryEmailAssignments());
87+
const updated = response?.data?.assignment || response?.data || { _id: id, email };
88+
if (updated && updated._id) {
89+
dispatch(updateWeeklySummaryEmailBcc(updated));
90+
} else {
91+
dispatch(getAllWeeklySummaryEmailAssignments());
92+
}
8393
} else {
8494
dispatch(weeklySummaryEmailBccError(response.data));
8595
}
8696
} catch (error) {
8797
dispatch(weeklySummaryEmailBccError(error));
8898
}
8999
};
100+

0 commit comments

Comments
 (0)