generated from openedx/frontend-template-application
-
Notifications
You must be signed in to change notification settings - Fork 1
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 #9 from edx/zhancock/review-dash
feat: add lti launch view
- Loading branch information
Showing
9 changed files
with
58 additions
and
58 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
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
19 changes: 17 additions & 2 deletions
19
src/pages/ExamsPage/components/ExternalReviewDashboard.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 |
---|---|---|
@@ -1,9 +1,24 @@ | ||
import React from 'react'; | ||
import PropTypes from 'prop-types'; | ||
|
||
const ExternalReviewDashboard = () => ( | ||
import { getExamsBaseUrl } from '../data/api'; | ||
|
||
const getLaunchUrlByExamId = (id) => `${getExamsBaseUrl()}/lti/exam/${id}/instructor_tool`; | ||
|
||
const ExternalReviewDashboard = ({ exam }) => ( | ||
<div data-testid="review_dash"> | ||
Placeholder for external review app | ||
{exam && <iframe title="lti_tool" src={getLaunchUrlByExamId(exam.id)} width="100%" height="1100" style={{ border: 'none' }} />} | ||
</div> | ||
); | ||
|
||
ExternalReviewDashboard.propTypes = { | ||
exam: PropTypes.shape({ | ||
id: PropTypes.number.isRequired, | ||
}), | ||
}; | ||
|
||
ExternalReviewDashboard.defaultProps = { | ||
exam: null, | ||
}; | ||
|
||
export default ExternalReviewDashboard; |
26 changes: 26 additions & 0 deletions
26
src/pages/ExamsPage/components/ExternalReviewDashboard.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,26 @@ | ||
import { render, screen } from '@testing-library/react'; | ||
|
||
import ExternalReviewDashboard from './ExternalReviewDashboard'; | ||
|
||
// nomally mocked for unit tests but required for rendering/snapshots | ||
jest.unmock('react'); | ||
|
||
jest.mock('../data/api', () => ({ | ||
getExamsBaseUrl: jest.fn().mockReturnValue('http://test.org'), | ||
})); | ||
|
||
const testExam = { | ||
id: 3, | ||
name: 'Test Proctored Exam', | ||
}; | ||
|
||
describe('ExternalReviewDashboard', () => { | ||
it('does not include iframe if no exam provided', () => { | ||
render(<ExternalReviewDashboard exam={null} />); | ||
expect(screen.queryByTitle('lti_tool')).not.toBeInTheDocument(); | ||
}); | ||
it('includes an iframe with the correct url for the current exam', () => { | ||
render(<ExternalReviewDashboard exam={testExam} />); | ||
expect(screen.getByTitle('lti_tool')).toHaveAttribute('src', 'http://test.org/lti/exam/3/instructor_tool'); | ||
}); | ||
}); |
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
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
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