generated from openedx/frontend-template-application
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: Add instructor assignment section
- Loading branch information
Showing
25 changed files
with
421 additions
and
91 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -3,3 +3,4 @@ dist/ | |
node_modules/ | ||
jest.config.js | ||
.eslintrc.js | ||
test-utils.jsx |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
56 changes: 41 additions & 15 deletions
56
src/features/Dashboard/DashboardPage/_test_/index.test.jsx
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,34 +1,60 @@ | ||
import React from 'react'; | ||
import { render } from '@testing-library/react'; | ||
import DashboardPage from 'features/Dashboard/DashboardPage'; | ||
import '@testing-library/jest-dom/extend-expect'; | ||
import { Provider } from 'react-redux'; | ||
import { initializeStore } from 'store'; | ||
|
||
let store; | ||
|
||
jest.mock('axios'); | ||
import { renderWithProviders } from 'test-utils'; | ||
|
||
jest.mock('@edx/frontend-platform/logging', () => ({ | ||
logError: jest.fn(), | ||
})); | ||
|
||
describe('DashboardPage component', () => { | ||
beforeEach(() => { | ||
store = initializeStore(); | ||
}); | ||
const mockStore = { | ||
dashboard: { | ||
tableLicense: { | ||
data: [ | ||
{ | ||
licenseName: 'License Name 1', | ||
purchasedSeats: 20, | ||
numberOfStudents: 6, | ||
numberOfPendingStudents: 11, | ||
}, | ||
], | ||
}, | ||
classes: { | ||
data: [ | ||
{ | ||
classId: 'ccx-v1:demo+demo1+2020+ccx1', | ||
className: 'ccx 1', | ||
masterCourseName: 'Demo Course 1', | ||
instructors: [], | ||
numberOfStudents: 0, | ||
numberOfPendingStudents: 0, | ||
maxStudents: 20, | ||
startDate: '2024-01-23T21:50:51Z', | ||
endDate: null, | ||
}, | ||
], | ||
}, | ||
}, | ||
}; | ||
|
||
const component = renderWithProviders( | ||
<DashboardPage />, | ||
{ preloadedState: mockStore }, | ||
); | ||
|
||
test('renders components', () => { | ||
const { getByText } = render( | ||
<Provider store={store}> | ||
<DashboardPage /> | ||
</Provider>, | ||
); | ||
const { getByText } = component; | ||
|
||
expect(getByText('This week')).toBeInTheDocument(); | ||
expect(getByText('Next week')).toBeInTheDocument(); | ||
expect(getByText('Next month')).toBeInTheDocument(); | ||
expect(getByText('New students registered')).toBeInTheDocument(); | ||
expect(getByText('Classes scheduled')).toBeInTheDocument(); | ||
expect(getByText('License inventory')).toBeInTheDocument(); | ||
expect(getByText('Instructor assignment')).toBeInTheDocument(); | ||
expect(getByText('ccx 1')).toBeInTheDocument(); | ||
expect(getByText('Demo Course 1')).toBeInTheDocument(); | ||
expect(getByText('License Name 1')).toBeInTheDocument(); | ||
}); | ||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
33 changes: 33 additions & 0 deletions
33
src/features/Dashboard/InstructorAssignSection/ClassCard.jsx
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,33 @@ | ||
import React from 'react'; | ||
import { format } from 'date-fns'; | ||
import PropTypes from 'prop-types'; | ||
|
||
import { Button } from 'react-paragon-topaz'; | ||
|
||
import 'features/Dashboard/InstructorAssignSection/index.scss'; | ||
|
||
const ClassCard = ({ data }) => { | ||
const fullDate = format(new Date(data.startDate), 'PP'); | ||
|
||
return ( | ||
<div className="class-card-container"> | ||
<h4>{data?.className}</h4> | ||
<p className="course-name">{data?.masterCourseName}</p> | ||
<p className="date"><i className="fa-sharp fa-regular fa-calendar-day" />{fullDate}</p> | ||
<Button variant="outline-primary" size="sm"> | ||
<i className="fa-regular fa-chalkboard-user" /> | ||
Assign instructor | ||
</Button> | ||
</div> | ||
); | ||
}; | ||
|
||
ClassCard.propTypes = { | ||
data: PropTypes.arrayOf(PropTypes.shape([])), | ||
}; | ||
|
||
ClassCard.defaultProps = { | ||
data: [], | ||
}; | ||
|
||
export default ClassCard; |
44 changes: 44 additions & 0 deletions
44
src/features/Dashboard/InstructorAssignSection/_test_/index.test.jsx
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,44 @@ | ||
import React from 'react'; | ||
import InstructorAssignSection from 'features/Dashboard/InstructorAssignSection'; | ||
import '@testing-library/jest-dom/extend-expect'; | ||
import { renderWithProviders } from 'test-utils'; | ||
|
||
jest.mock('@edx/frontend-platform/logging', () => ({ | ||
logError: jest.fn(), | ||
})); | ||
|
||
describe('Instructor Assign component', () => { | ||
const mockStore = { | ||
dashboard: { | ||
classes: { | ||
data: [ | ||
{ | ||
classId: 'ccx-v1:demo+demo1+2020+ccx1', | ||
className: 'ccx 1', | ||
masterCourseName: 'Demo Course 1', | ||
instructors: [], | ||
numberOfStudents: 0, | ||
numberOfPendingStudents: 0, | ||
maxStudents: 20, | ||
startDate: '2024-01-23T21:50:51Z', | ||
endDate: null, | ||
}, | ||
], | ||
}, | ||
}, | ||
}; | ||
const component = renderWithProviders( | ||
<InstructorAssignSection />, | ||
{ preloadedState: mockStore }, | ||
); | ||
|
||
test('renders components', () => { | ||
const { getByText } = component; | ||
|
||
expect(getByText('Instructor assignment')).toBeInTheDocument(); | ||
expect(getByText('ccx 1')).toBeInTheDocument(); | ||
expect(getByText('Demo Course 1')).toBeInTheDocument(); | ||
expect(getByText('Jan 23, 2024')).toBeInTheDocument(); | ||
expect(getByText('Assign instructor')).toBeInTheDocument(); | ||
}); | ||
}); |
Oops, something went wrong.