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.
Merge pull request #15 from Pearson-Advance/vue/PADV-802
PADV-802 Change students table according to new wireframe
- Loading branch information
Showing
14 changed files
with
626 additions
and
185 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 |
---|---|---|
@@ -0,0 +1 @@ | ||
module.exports = 'test-file-stub'; |
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 @@ | ||
module.exports = {}; |
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
Large diffs are not rendered by default.
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
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -3,8 +3,6 @@ import axios from 'axios'; | |
import StudentsPage from 'features/Students/StudentsPage'; | ||
import { | ||
render, | ||
screen, | ||
fireEvent, | ||
waitFor, | ||
} from '@testing-library/react'; | ||
import '@testing-library/jest-dom/extend-expect'; | ||
|
@@ -21,16 +19,30 @@ const mockResponse = { | |
{ | ||
learnerName: 'Student 1', | ||
learnerEmail: '[email protected]', | ||
ccxName: 'CCX 1', | ||
courseId: '1', | ||
courseName: 'course 1', | ||
classId: '1', | ||
className: 'class 1', | ||
instructors: ['Instructor 1'], | ||
created: 'Fri, 25 Aug 2023 19:01:22 GMT', | ||
firstAccess: 'Fri, 25 Aug 2023 19:01:23 GMT', | ||
lastAccess: 'Fri, 25 Aug 2023 20:20:22 GMT', | ||
status: 'Active', | ||
examReady: true, | ||
}, | ||
{ | ||
learnerName: 'Student 2', | ||
learnerEmail: '[email protected]', | ||
ccxName: 'CCX 2', | ||
courseId: '2', | ||
courseName: 'course 2', | ||
classId: '2', | ||
className: 'class 2', | ||
instructors: ['Instructor 2'], | ||
created: 'Sat, 26 Aug 2023 19:01:22 GMT', | ||
firstAccess: 'Sat, 26 Aug 2023 19:01:24 GMT', | ||
lastAccess: 'Sat, 26 Aug 2023 21:22:22 GMT', | ||
status: 'Pending', | ||
examReady: null, | ||
}, | ||
], | ||
count: 2, | ||
|
@@ -48,34 +60,14 @@ describe('StudentsPage', () => { | |
waitFor(() => { | ||
expect(component.container).toHaveTextContent('Student 1'); | ||
expect(component.container).toHaveTextContent('Student 2'); | ||
expect(component.container).toHaveTextContent('[email protected]'); | ||
expect(component.container).toHaveTextContent('[email protected]'); | ||
expect(component.container).toHaveTextContent('CCX 1'); | ||
expect(component.container).toHaveTextContent('CCX 2'); | ||
expect(component.container).toHaveTextContent('course 1'); | ||
expect(component.container).toHaveTextContent('course 2'); | ||
expect(component.container).toHaveTextContent('class 1'); | ||
expect(component.container).toHaveTextContent('class 2'); | ||
expect(component.container).toHaveTextContent('Instructor 1'); | ||
expect(component.container).toHaveTextContent('Instructor 2'); | ||
expect(component.container).toHaveTextContent('Fri, 25 Aug 2023 19:01:22 GMT'); | ||
expect(component.container).toHaveTextContent('Sat, 26 Aug 2023 19:01:22 GMT'); | ||
}); | ||
}); | ||
|
||
it('filters students data', async () => { | ||
axios.get.mockResolvedValue(mockResponse); | ||
|
||
const component = render(<StudentsPage />); | ||
|
||
fireEvent.click(screen.getByRole('button', { name: /Filters/i })); | ||
|
||
const nameInput = screen.getByPlaceholderText('Enter Student Name'); | ||
const emailInput = screen.getByPlaceholderText('Enter Student Email'); | ||
fireEvent.change(nameInput, { target: { value: 'Student 1' } }); | ||
fireEvent.change(emailInput, { target: { value: '[email protected]' } }); | ||
|
||
fireEvent.click(screen.getByText('Apply Filters')); | ||
|
||
waitFor(() => { | ||
expect(component.container).toHaveTextContent('Student 1'); | ||
expect(screen.queryByText('Student 2')).toBeNull(); | ||
expect(component.container).toHaveTextContent('active'); | ||
expect(component.container).toHaveTextContent('pending'); | ||
}); | ||
}); | ||
}); |
99 changes: 99 additions & 0 deletions
99
src/features/Students/StudentsPage/_test_/reducer.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,99 @@ | ||
import { | ||
FETCH_STUDENTS_DATA_REQUEST, | ||
FETCH_STUDENTS_DATA_SUCCESS, | ||
FETCH_STUDENTS_DATA_FAILURE, | ||
UPDATE_CURRENT_PAGE, | ||
OPEN_MODAL, | ||
CLOSE_MODAL, | ||
} from 'features/Students/actionTypes'; | ||
import { RequestStatus } from 'features/constants'; | ||
import reducer from 'features/Instructors/InstructorsPage/reducer'; | ||
|
||
describe('Instructor page reducers', () => { | ||
const initialState = { | ||
data: [], | ||
error: null, | ||
currentPage: 1, | ||
numPages: 0, | ||
}; | ||
|
||
test('should handle FETCH_STUDENTS_DATA_REQUEST', () => { | ||
const state = { | ||
...initialState, | ||
status: RequestStatus.LOADING, | ||
}; | ||
const action = { | ||
type: FETCH_STUDENTS_DATA_REQUEST, | ||
}; | ||
expect(reducer(state, action)).toEqual(state); | ||
}); | ||
|
||
test('should handle FETCH_STUDENTS_DATA_SUCCESS', () => { | ||
const state = { | ||
...initialState, | ||
status: RequestStatus.SUCCESS, | ||
count: 0, | ||
}; | ||
const action = { | ||
type: FETCH_STUDENTS_DATA_SUCCESS, | ||
payload: { | ||
results: [], | ||
count: 0, | ||
numPages: 0, | ||
}, | ||
}; | ||
expect(reducer(state, action)).toEqual(state); | ||
}); | ||
|
||
test('should handle FETCH_STUDENTS_DATA_FAILURE', () => { | ||
const state = { | ||
...initialState, | ||
status: RequestStatus.ERROR, | ||
error: '', | ||
}; | ||
const action = { | ||
type: FETCH_STUDENTS_DATA_FAILURE, | ||
payload: '', | ||
}; | ||
expect(reducer(state, action)).toEqual(state); | ||
}); | ||
|
||
test('should handle UPDATE_CURRENT_PAGE', () => { | ||
const state = { | ||
...initialState, | ||
currentPage: 1, | ||
}; | ||
const action = { | ||
type: UPDATE_CURRENT_PAGE, | ||
payload: 1, | ||
}; | ||
expect(reducer(state, action)).toEqual(state); | ||
}); | ||
|
||
test('should handle OPEN_MODAL', () => { | ||
const state = { | ||
...initialState, | ||
filters: { | ||
isOpenFilters: true, | ||
}, | ||
}; | ||
const action = { | ||
type: OPEN_MODAL, | ||
}; | ||
expect(reducer(state, action)).toEqual(state); | ||
}); | ||
|
||
test('should handle CLOSE_MODAL', () => { | ||
const state = { | ||
...initialState, | ||
filters: { | ||
isOpenFilters: false, | ||
errors: {}, | ||
}, | ||
}; | ||
const action = { | ||
type: CLOSE_MODAL, | ||
}; | ||
expect(reducer(state, action)).toEqual(state); | ||
}); | ||
}); |
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,58 @@ | ||
import { | ||
FETCH_STUDENTS_DATA_REQUEST, | ||
FETCH_STUDENTS_DATA_SUCCESS, | ||
FETCH_STUDENTS_DATA_FAILURE, | ||
UPDATE_CURRENT_PAGE, | ||
OPEN_MODAL, | ||
CLOSE_MODAL, | ||
} from 'features/Students/actionTypes'; | ||
import { RequestStatus } from 'features/constants'; | ||
|
||
const reducer = (state, action) => { | ||
switch (action.type) { | ||
case FETCH_STUDENTS_DATA_REQUEST: | ||
return { ...state, status: RequestStatus.LOADING }; | ||
case FETCH_STUDENTS_DATA_SUCCESS: { | ||
const { results, count, numPages } = action.payload; | ||
return { | ||
...state, | ||
status: RequestStatus.SUCCESS, | ||
data: results, | ||
numPages, | ||
count, | ||
}; | ||
} | ||
case FETCH_STUDENTS_DATA_FAILURE: | ||
return { | ||
...state, | ||
status: RequestStatus.ERROR, | ||
error: action.payload, | ||
}; | ||
case UPDATE_CURRENT_PAGE: | ||
return { | ||
...state, | ||
currentPage: action.payload, | ||
}; | ||
case OPEN_MODAL: | ||
return { | ||
...state, | ||
filters: { | ||
...state.filters, | ||
isOpenFilters: true, | ||
}, | ||
}; | ||
case CLOSE_MODAL: | ||
return { | ||
...state, | ||
filters: { | ||
...state.filters, | ||
isOpenFilters: false, | ||
errors: {}, | ||
}, | ||
}; | ||
default: | ||
return state; | ||
} | ||
}; | ||
|
||
export default reducer; |
Oops, something went wrong.