Skip to content

Commit

Permalink
test: fix lti launch test
Browse files Browse the repository at this point in the history
  • Loading branch information
zacharis278 committed Sep 7, 2023
1 parent 28c28e3 commit c95698a
Showing 1 changed file with 10 additions and 3 deletions.
13 changes: 10 additions & 3 deletions src/instructions/Instructions.test.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -793,8 +793,12 @@ describe('SequenceExamWrapper', () => {
});

it('Initiates an LTI launch in a new window when the user clicks the System Check button', async () => {
const windowSpy = jest.spyOn(window, 'open');
windowSpy.mockImplementation(() => ({}));
const { location } = window;
delete window.location;
const mockAssign = jest.fn();
window.location = {
assign: mockAssign,
};
store.getState = () => ({
examState: Factory.build('examState', {
activeAttempt: {},
Expand Down Expand Up @@ -825,13 +829,16 @@ describe('SequenceExamWrapper', () => {
{ store },
);
fireEvent.click(screen.getByText('Start System Check'));
await waitFor(() => { expect(windowSpy).toHaveBeenCalledWith('http://localhost:18740/lti/start_proctoring/4321', '_blank'); });
await waitFor(() => { expect(mockAssign).toHaveBeenCalledWith('http://localhost:18740/lti/start_proctoring/4321'); });
expect(softwareDownloadAttempt).toHaveBeenCalledWith(4321, false);

// also validate start button works
pollExamAttempt.mockReturnValue(Promise.resolve({ status: ExamStatus.READY_TO_START }));
fireEvent.click(screen.getByText('Start Exam'));
await waitFor(() => { expect(getExamAttemptsData).toHaveBeenCalled(); });

// restore window.location
window.location = location;
});

it('Shows correct download instructions for legacy rest provider if attempt status is created', () => {
Expand Down

0 comments on commit c95698a

Please sign in to comment.