Skip to content

Commit

Permalink
feat: single tab lti flow
Browse files Browse the repository at this point in the history
  • Loading branch information
zacharis278 committed Sep 12, 2023
1 parent 8bd3627 commit 674c0dc
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 4 deletions.
13 changes: 10 additions & 3 deletions src/instructions/proctored_exam/ProctoredExamInstructions.test.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -197,8 +197,12 @@ describe('SequenceExamWrapper', () => {
});

it('Initiates an LTI launch in a new window when the user clicks the submit button', async () => {
const windowSpy = jest.spyOn(window, 'open');
windowSpy.mockImplementation(() => ({}));
const { location } = window;
delete window.location;
const mockAssign = jest.fn();
window.location = {
assign: mockAssign,
};
const attempt = Factory.build('attempt', {
attempt_status: ExamStatus.READY_TO_SUBMIT,
use_legacy_attempt_api: false,
Expand Down Expand Up @@ -226,7 +230,10 @@ describe('SequenceExamWrapper', () => {

expect(queryByTestId('proctored-exam-instructions-title')).toHaveTextContent('Are you sure you want to end your proctored exam?');
fireEvent.click(queryByTestId('end-exam-button'));
await waitFor(() => { expect(windowSpy).toHaveBeenCalledWith('http://localhost:18740/lti/end_assessment/1', '_blank'); });
await waitFor(() => { expect(mockAssign).toHaveBeenCalledWith('http://localhost:18740/lti/end_assessment/1'); });

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

it('Instructions are shown when attempt status is verified', () => {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ const SubmitProctoredExamInstructions = () => {

const handleSubmitClick = () => {
if (examHasLtiProvider) {
window.open(submitLtiAttemptUrl, '_blank');
window.location.assign(submitLtiAttemptUrl);
}
submitExam();
};
Expand Down

0 comments on commit 674c0dc

Please sign in to comment.