-
Notifications
You must be signed in to change notification settings - Fork 18
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
fix: Remove retry button in LTI Proctorio exams
- Loading branch information
Showing
2 changed files
with
101 additions
and
11 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
85 changes: 85 additions & 0 deletions
85
src/instructions/practice_exam/SubmittedPracticeExamInstructions.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,85 @@ | ||
import React from 'react'; | ||
import { SubmittedPracticeExamInstructions } from './index'; | ||
import { | ||
render, screen, initializeTestStore, fireEvent, | ||
} from '../../setupTest'; | ||
|
||
const mockresetReturn = {}; | ||
const mockDispatch = jest.fn(); | ||
|
||
jest.mock('react-redux', () => ({ | ||
...jest.requireActual('react-redux'), | ||
useDispatch: () => mockDispatch, | ||
})); | ||
|
||
jest.mock('../../data', () => ({ | ||
...jest.requireActual('../../data'), | ||
resetExam: () => mockresetReturn, | ||
})); | ||
|
||
describe('ExamTimerBlock', () => { | ||
afterEach(() => { | ||
jest.resetAllMocks(); | ||
}); | ||
|
||
describe('when no LTI provider is used', () => { | ||
beforeEach(() => { | ||
const preloadedState = { | ||
specialExams: { | ||
exam: { | ||
attempt: { | ||
use_legacy_attempt_api: true, | ||
}, | ||
}, | ||
}, | ||
}; | ||
initializeTestStore(preloadedState); | ||
|
||
render( | ||
<SubmittedPracticeExamInstructions />, | ||
); | ||
}); | ||
|
||
it('renders the component correctly', async () => { | ||
expect(screen.getByText('You have submitted this practice proctored exam')).toBeInTheDocument(); | ||
expect(screen.getByText( | ||
'Practice exams do not affect your grade. You have ' | ||
+ 'completed this practice exam and can continue with your course work.', | ||
)).toBeInTheDocument(); | ||
expect(screen.queryByTestId('retry-exam-button')).toBeInTheDocument(); | ||
}); | ||
|
||
it('calls resetExam() when clicking the retry button', () => { | ||
expect(mockDispatch).not.toHaveBeenCalled(); | ||
|
||
fireEvent.click(screen.getByTestId('retry-exam-button')); | ||
|
||
expect(mockDispatch).toHaveBeenCalledTimes(1); | ||
expect(mockDispatch).toHaveBeenCalledWith(mockresetReturn); | ||
}); | ||
}); | ||
|
||
describe('when an LTI provider is used', () => { | ||
beforeEach(() => { | ||
const preloadedState = { | ||
specialExams: { | ||
exam: {}, | ||
}, | ||
}; | ||
initializeTestStore(preloadedState); | ||
|
||
render( | ||
<SubmittedPracticeExamInstructions />, | ||
); | ||
}); | ||
|
||
it('doesn\'t show the button if it has an LTI provider', async () => { | ||
expect(screen.getByText('You have submitted this practice proctored exam')).toBeInTheDocument(); | ||
expect(screen.getByText( | ||
'Practice exams do not affect your grade. You have ' | ||
+ 'completed this practice exam and can continue with your course work.', | ||
)).toBeInTheDocument(); | ||
expect(screen.queryByTestId('retry-exam-button')).not.toBeInTheDocument(); | ||
}); | ||
}); | ||
}); |