Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
48 commits
Select commit Hold shift + click to select a range
8a1fe7a
Added preliminary dmdView
Apr 14, 2025
9925c53
Added additional interfaces & updated React scaffolding page
Apr 15, 2025
1655361
Merge pull request #16 from delaneydow/DMD-dev
delaneydow Apr 16, 2025
4909a5d
Update AssignReviewer.tsx
elnaz-72 Apr 17, 2025
501df87
Update AssignReviewer.tsx
elnaz-72 Apr 17, 2025
49ea16c
Update AssignReviewer.tsx add button and dummy
elnaz-72 Apr 18, 2025
3583650
Create DummyTopics.json
elnaz-72 Apr 18, 2025
34b0a4a
Delete src/pages/Assignments/DummyTopics.json
elnaz-72 Apr 18, 2025
9e7c779
Update AssignReviewer.tsx
elnaz-72 Apr 18, 2025
6150555
Create DummyTopics.json
elnaz-72 Apr 18, 2025
bfb0542
fixed compilation errors
MGuron Apr 19, 2025
3752fe7
Create DummyTopics.json
elnaz-72 Apr 19, 2025
861c630
Update AssignReviewer.tsx
elnaz-72 Apr 19, 2025
19c0f8f
Update AssignReviewer.tsx
elnaz-72 Apr 19, 2025
054d185
Update AssignReviewer.tsx(updat the dummy inside the main code)
elnaz-72 Apr 19, 2025
e9c5ae9
Fixed up some formatting, moved buttons to correct columns
MGuron Apr 19, 2025
4076321
Removing dmdView
Apr 19, 2025
76efae2
Merge pull request #18 from delaneydow/main
delaneydow Apr 19, 2025
5df10b1
Updated table style
MGuron Apr 19, 2025
0a8d12c
Updated table UI
MGuron Apr 20, 2025
c742b46
updated color in table
MGuron Apr 20, 2025
f7288e4
Deleted dmdview
MGuron Apr 20, 2025
132ed29
Merge pull request #21 from delaneydow/assign-reviewer-buttons
MGuron Apr 20, 2025
ce4b16b
Merge pull request #22 from delaneydow/main
delaneydow Apr 20, 2025
61b8f16
Merge remote-tracking branch 'origin/main' into TableUI
MGuron Apr 20, 2025
14f1526
Updated UI, background is still not the right color
MGuron Apr 20, 2025
c8335ae
updated to use DummyTopics.json
MGuron Apr 20, 2025
4821368
Cleaned up reviewer card
MGuron Apr 20, 2025
508e4a7
Added "Add Reviewer" Page & shared context logic
Apr 20, 2025
cfec8db
Use H2 but left align it to match assignment
MGuron Apr 20, 2025
46a6d52
Merge pull request #23 from delaneydow/TableUI
elnaz-72 Apr 20, 2025
169acd6
Modifying Context path in add reviewer to satisfy compilation errors
Apr 20, 2025
2f44cf7
Merge pull request #24 from delaneydow/DMD-dev
delaneydow Apr 20, 2025
01a0613
Fixes compilation errors, adjusted topic selection logic, updated rev…
Apr 21, 2025
40da10a
Merge branch 'main' into add-reviewer-page-logic
MGuron Apr 21, 2025
e2f5a83
Updated container to be a nicer
MGuron Apr 21, 2025
dbe76d9
Fixed unsubmit reviewers
MGuron Apr 22, 2025
1f4e3c1
Adding persistent memory & updated AddReviewer UI
Apr 22, 2025
68ca0dd
Fixed double addition of reviewers
MGuron Apr 22, 2025
903b88f
Merge pull request #25 from delaneydow/add-reviewer-page-logic
delaneydow Apr 22, 2025
f7b7ab5
Create UnitTestPlan.md(Add Unit Test Plan documentation)
elnaz-72 Apr 22, 2025
7405bfd
Update README.md(add unit test)
elnaz-72 Apr 22, 2025
2f9900a
Render the Unsubmit button only if the status is submitted
MGuron Apr 22, 2025
728f71a
Updated to use buttons, indentation
MGuron Apr 22, 2025
1729beb
Update UnitTestPlan.md
elnaz-72 Apr 22, 2025
d85c653
Added unit tests
MGuron Apr 23, 2025
98c183e
Deleted local files, reverted table changes
MGuron Apr 23, 2025
55b8880
reverted more changes to global files
MGuron Apr 23, 2025
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
4 changes: 4 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -44,3 +44,7 @@ You don’t have to ever use `eject`. The curated feature set is suitable for sm
You can learn more in the [Create React App documentation](https://facebook.github.io/create-react-app/docs/getting-started).

To learn React, check out the [React documentation](https://reactjs.org/).

## 📋 Documentation
- [Unit Test Plan](./UnitTestPlan.md)

10 changes: 10 additions & 0 deletions UnitTestPlan.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
# Unit Tests

Unit testing for TS/front end projects is most applicable for logic-heavy components, which in the case of our project includes the button functionality. The following test cases were included:

- Validating that the "Add Reviewer" button adds a new reviewer with a status of "Pending".
- Validating that the "Delete outstanding Reviewers" button removes the reviewer's association from the topic.
- Ensure that all table columns — "Topic Selected," "Contributor," and "Reviewed By" — display accurate and consistent data for each assignment.
- Verify that any modifications to reviewers (adding, deleting, or unassigning) are properly reflected in the user interface.
- Confirm that unsubmitting a review does not remove the reviewer, only changes their status to (Pending).
-Validate that the "Add Reviewer" button is not rendered once the maximum number of reviewers (3) has been reached for a topic.
68 changes: 53 additions & 15 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

6 changes: 3 additions & 3 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -13,14 +13,13 @@
"@testing-library/user-event": "^13.5.0",
"@types/jest": "^27.5.2",
"@types/node": "^16.18.29",
"@types/react": "^18.2.6",
"@types/react-dom": "^18.2.4",
"@types/react": "^18.3.20",
"@types/react-dom": "^18.3.6",
"@types/react-redux": "^7.1.25",
"@types/react-router-dom": "^5.3.3",
"axios": "^1.4.0",
"bootstrap": "^5.3.3",
"chart.js": "^4.1.1",
"recharts": "^2.0.0",
"formik": "^2.2.9",
"jquery": "^3.7.1",
"jwt-decode": "^3.1.2",
Expand All @@ -34,6 +33,7 @@
"react-redux": "^8.0.5",
"react-router-dom": "^6.11.1",
"react-scripts": "^5.0.1",
"recharts": "^2.0.0",
"redux-persist": "^6.0.0",
"sass": "^1.62.1",
"save": "^2.9.0",
Expand Down
115 changes: 115 additions & 0 deletions src/AddReviewer.test.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,115 @@
import React from 'react';
import '@testing-library/jest-dom';
import { render, screen, fireEvent } from '@testing-library/react';
import AddReviewer from 'pages/Assignments/AddReviewer';
import { MemoryRouter, Route, Routes } from 'react-router-dom';
import { TopicWithReviewers } from 'utils/interfaces';

// Mock useNavigate and useReviewerContext
const mockNavigate = jest.fn();
const mockAddReviewerToTopic = jest.fn();

const mockTopics: TopicWithReviewers[] = [
{
topic_identifier: 'topic-123',
topic_name: 'Cool Topic',
contributors: [{
name: 'Alice',
id: 0,
type: 'AssignmentTeam',
users: [],
reviewMappings: []
}],
reviewers: [],
},
];

// Mock the ReviewerContext
jest.mock('context/ReviewerContext', () => ({
useReviewerContext: () => ({
topics: mockTopics,
addReviewerToTopic: mockAddReviewerToTopic,
}),
}));

// Mock react-router-dom
jest.mock('react-router-dom', () => {
const actual = jest.requireActual('react-router-dom');
return {
...actual,
useNavigate: () => mockNavigate,
useParams: () => ({ id: '999' }),
};
});

// Utility to render component with query params
const renderWithSearchParams = (params: Record<string, string>) => {
const queryString = new URLSearchParams(params).toString();
const path = `/assignments/edit/999/add-reviewer?${queryString}`;

return render(
<MemoryRouter initialEntries={[path]}>
<Routes>
<Route path="/assignments/edit/:id/add-reviewer" element={<AddReviewer />} />
</Routes>
</MemoryRouter>
);
};

describe('AddReviewer Component', () => {
beforeEach(() => {
jest.clearAllMocks();
});

test('renders contributor and assignment from query params', () => {
renderWithSearchParams({
contributor: 'Alice',
assignment: 'Math Assignment',
topic: 'Cool Topic',
contributor_id: '42',
});

expect(screen.getByText('Contributor: Alice')).toBeInTheDocument();
expect(screen.getByText('Assignment: Math Assignment')).toBeInTheDocument();
});

test('adds a reviewer and calls context + navigation', () => {
renderWithSearchParams({
contributor: 'Alice',
assignment: 'Math Assignment',
topic: 'Cool Topic',
contributor_id: '42',
});

fireEvent.change(screen.getByLabelText(/user login/i), {
target: { value: 'newuser' },
});

fireEvent.click(screen.getByRole('button', { name: /add reviewer/i }));

expect(mockAddReviewerToTopic).toHaveBeenCalledWith('Cool Topic', expect.objectContaining({
reviewer: expect.objectContaining({ name: 'newuser' }),
review_status: 'Pending',
}));

expect(mockNavigate).toHaveBeenCalledWith('/assignments/edit/999/assignreviewer');
});

test('does not submit if topic is missing', () => {
renderWithSearchParams({
contributor: 'Alice',
assignment: 'Math Assignment',
contributor_id: '42',
// topic is intentionally missing
});

fireEvent.change(screen.getByLabelText(/user login/i), {
target: { value: 'userX' },
});

fireEvent.click(screen.getByRole('button', { name: /add reviewer/i }));

expect(mockAddReviewerToTopic).not.toHaveBeenCalled();
expect(mockNavigate).not.toHaveBeenCalled();
});
});
24 changes: 21 additions & 3 deletions src/App.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -36,10 +36,14 @@ import Reviews from "pages/Reviews/reviews";
import Email_the_author from "./pages/Email_the_author/email_the_author";
import CreateTeams from "pages/Assignments/CreateTeams";
import AssignReviewer from "pages/Assignments/AssignReviewer";
import AddReviewer from "pages/Assignments/AddReviewer";
import ReviewerContextWrapper from "./context/ReviewerContextWrapper";
import ViewSubmissions from "pages/Assignments/ViewSubmissions";
import ViewScores from "pages/Assignments/ViewScores";
import ViewReports from "pages/Assignments/ViewReports";
import ViewDelayedJobs from "pages/Assignments/ViewDelayedJobs";
import { ReviewerProvider } from './context/ReviewerContext';

function App() {
const router = createBrowserRouter([
{
Expand Down Expand Up @@ -67,9 +71,19 @@ function App() {

{
path: "assignments/edit/:id/assignreviewer",
element: <AssignReviewer />,
loader: loadAssignment,
element: (
<AssignReviewer />
),
loader: loadAssignment,
},

{
path:"assignments/edit/:id/add-reviewer",
element: (
<AddReviewer />
),
},

{
path: "assignments/edit/:id/viewsubmissions",
element: <ViewSubmissions />,
Expand Down Expand Up @@ -294,7 +308,11 @@ function App() {
},
]);

return <RouterProvider router={router} />;
return (
<ReviewerProvider>
<RouterProvider router={router} />
</ReviewerProvider>
);
}

export default App;
Loading