Show error message when configured default tool is not installed

Closes PLAT-4804


Test Plan:
- configure a default tool that is not installed
- verify an error is dispalyed when creating an assignment

Change-Id: I90b395c441cd07e884d1b71244a95bf72dc03020
Reviewed-on: https://gerrit.instructure.com/205866
Tested-by: Jenkins
Reviewed-by: Xander Moffatt <xmoffatt@instructure.com>
QA-Review: Xander Moffatt <xmoffatt@instructure.com>
Product-Review: Weston Dransfield <wdransfield@instructure.com>
This commit is contained in:
wdransfield 2019-08-20 12:30:46 -06:00 committed by Weston Dransfield
parent 68ddb0f000
commit c8261d1476
2 changed files with 40 additions and 0 deletions

View File

@ -68,6 +68,17 @@ const DefaultToolForm = props => {
SelectContentDialog.Events.onContextExternalToolSelect(event, $('#default-tool'))
}
if(!defaultToolData && launchDefinitions.length > 0) {
return(
<View display="block" padding="medium none small small">
<Alert variant="error" margin="small small 0 0">
<Text weight="bold">{I18n.t('Tool Not Found')}</Text><br/>
<Text>{I18n.t('The tool is not installed in the course or account')}</Text>
</Alert>
</View>
)
}
return (
<View display="block" padding="medium none small small">
<Button id="default-tool-launch-button" name="default-tool-launch-button" onClick={handleLaunchButton}>

View File

@ -16,6 +16,7 @@
* with this program. If not, see <http://www.gnu.org/licenses/>.
*/
import axios from 'axios'
import React from 'react'
import {mount} from 'enzyme'
import DefaultToolForm, { toolSubmissionType } from '../DefaultToolForm'
@ -31,6 +32,17 @@ const newProps = (overrides = {}) => ({
...overrides
})
beforeAll(() => {
axios.get = jest.fn()
axios.get.mockImplementation(async () => {
return {data: []};
})
})
afterEach(() => {
axios.get.mockRestore()
})
describe('DefaultToolForm', () => {
let wrapper = 'empty wrapper'
@ -65,6 +77,23 @@ describe('DefaultToolForm', () => {
wrapper = mount(<DefaultToolForm {...newProps({previouslySelected: true})} />)
expect(wrapper.find('Alert').html()).toContain('Successfully Added')
})
describe('when the configured tool is not installed', () => {
beforeAll(() => {
axios.get.mockImplementation(async () => {
return {data: [{
placements: [{
url: 'foo'
}]
}]};
})
})
it('renders an error message', async () => {
wrapper = mount(<DefaultToolForm {...newProps({previouslySelected: true})} />)
expect(wrapper.find('Alert').exists()).toEqual(true)
})
})
})
describe('toolSubmissionType', () => {