diff --git a/src/pages/ExamsPage/__snapshots__/index.test.jsx.snap b/src/pages/ExamsPage/__snapshots__/index.test.jsx.snap index 9f06fc2..d00be79 100644 --- a/src/pages/ExamsPage/__snapshots__/index.test.jsx.snap +++ b/src/pages/ExamsPage/__snapshots__/index.test.jsx.snap @@ -138,26 +138,73 @@ Object { class="pgn__data-table-status-bar" >
- FormattedMessage +
+
+ + +
+
+
-
+
+
+
+ FormattedMessage +
+
+
+
- - - - Exam Name - - - - - - Status + + + - - Exam 1 -
- FormattedMessage +
+
+ + +
+
+
-
+
+
+
+ FormattedMessage +
+
+
+
- - - - Exam Name - - - - - - Status + + + - - Exam 1 - ( { initialState={{ pageSize: 20, }} + isFilterable + defaultColumnValues={{ Filter: TextFilter }} isSortable itemCount={attempts.length} additionalColumns={[ @@ -73,10 +127,6 @@ const AttemptList = ({ attempts }) => { ]} data={attempts} columns={[ - { - Header: formatMessage(messages.examAttemptsTableHeaderExamName), - accessor: 'exam_name', - }, { Header: formatMessage(messages.examAttemptsTableHeaderUsername), accessor: 'username', @@ -84,6 +134,7 @@ const AttemptList = ({ attempts }) => { { Header: formatMessage(messages.examAttemptsTableHeaderTimeLimit), accessor: 'time_limit', + disableFilters: true, }, { Header: formatMessage(messages.examAttemptsTableHeaderExamType), @@ -111,7 +162,11 @@ const AttemptList = ({ attempts }) => { }, { Header: formatMessage(messages.examAttemptsTableHeaderStatus), + accessor: 'status', Cell: ({ row }) => ExamAttemptStatusUILabels[row.original.status], + Filter: CheckboxFilter, + filter: 'includesValue', + filterChoices: StatusFilterChoices, }, ]} > diff --git a/src/pages/ExamsPage/components/AttemptList.test.jsx b/src/pages/ExamsPage/components/AttemptList.test.jsx index cfe8d4c..0b93371 100644 --- a/src/pages/ExamsPage/components/AttemptList.test.jsx +++ b/src/pages/ExamsPage/components/AttemptList.test.jsx @@ -1,4 +1,6 @@ -import { render, screen } from '@testing-library/react'; +import { + fireEvent, render, screen, +} from '@testing-library/react'; import AttemptList from './AttemptList'; @@ -20,7 +22,7 @@ describe('AttemptList', () => { const defaultAttemptsData = [ { exam_name: 'Exam 1', - username: 'username', + username: 'username1', time_limit: 60, exam_type: 'timed', started_at: '2023-04-05T19:27:16.000000Z', @@ -32,12 +34,12 @@ describe('AttemptList', () => { }, { exam_name: 'Exam 2', - username: 'username', + username: 'username2', time_limit: 60, exam_type: 'proctored', started_at: '2023-04-05T19:37:16.000000Z', completed_at: '2023-04-05T19:37:17.000000Z', - status: 'second_review_required', + status: 'submitted', attempt_id: 1, }, ]; @@ -75,4 +77,25 @@ describe('AttemptList', () => { } }); }); + it('filtering by status displays the correct entry', () => { + render(); + // Get the 2nd row of data which has the values of defaultAttemptsData[1] + const secondRow = screen.getAllByRole('row')[2]; + screen.getByText('Filters').click(); + screen.getByLabelText('Second Review Required').click(); + // Expect the first data entry, but not the second from defaultAttemptsData + // NOTE: row with index '0' in 'screen' is the header row. + expect(screen.getAllByRole('row')[1]).toBeInTheDocument(); + expect(secondRow).not.toBeInTheDocument(); + }); + it('filtering by username displays the correct entry', () => { + render(); + // Get the 2nd row of data which has the values of defaultAttemptsData[1] + const secondRow = screen.getAllByRole('row')[2]; + const searchInput = screen.getByLabelText('Search username'); + fireEvent.change(searchInput, { target: { value: 'username1' } }); + // Expect the first data entry, but not the second from defaultAttemptsData + expect(screen.getAllByRole('row')[1]).toBeInTheDocument(); + expect(secondRow).not.toBeInTheDocument(); + }); }); diff --git a/src/pages/ExamsPage/components/__snapshots__/AttemptList.test.jsx.snap b/src/pages/ExamsPage/components/__snapshots__/AttemptList.test.jsx.snap index d4a6057..3087675 100644 --- a/src/pages/ExamsPage/components/__snapshots__/AttemptList.test.jsx.snap +++ b/src/pages/ExamsPage/components/__snapshots__/AttemptList.test.jsx.snap @@ -21,26 +21,73 @@ Object { class="pgn__data-table-status-bar" >
- FormattedMessage +
+
+ + +
+
+
-
+
+
+
+ FormattedMessage +
+
+
+
- - - - Exam Name - - - - - - Status + + + - Exam 1 - - - username + username1 - Exam 2 - - - username + username2 - Second Review Required + Submitted -
- -
- + /> @@ -530,26 +530,73 @@ Object { class="pgn__data-table-status-bar" >
- FormattedMessage +
+
+ + +
+
+
-
+
+
+
+ FormattedMessage +
+
+
+
- - - - Exam Name - - - - - - Status + + + - Exam 1 - - - username + username1 - Exam 2 - - - username + username2 - Second Review Required + Submitted -
- -
- + />