Skip to content
Snippets Groups Projects
Commit 829ec4f9 authored by Jessie Keck's avatar Jessie Keck
Browse files

Render ManifestListItemError when the manifest error is sent in as a prop.

parent 24de5151
Branches
Tags
No related merge requests found
<html>
<title>Error</title>
<body>
<p>Something went wrong</p>
</body>
</html>
describe('Mirador Invalid API Response Handler Test', () => { describe('Mirador Invalid API Response Handler Test', () => {
beforeAll(async () => { beforeEach(async () => {
await page.goto('http://127.0.0.1:4488/__tests__/integration/mirador/'); await page.goto('http://127.0.0.1:4488/__tests__/integration/mirador/');
}); });
it('breaks Mirador', async () => { it('breaks Mirador', async () => {
...@@ -14,4 +14,25 @@ describe('Mirador Invalid API Response Handler Test', () => { ...@@ -14,4 +14,25 @@ describe('Mirador Invalid API Response Handler Test', () => {
expect(e.name).toMatch('TimeoutError'); expect(e.name).toMatch('TimeoutError');
} }
}); });
it('renders an error message when a manifest cannot be loaded (and allows it to be dismissed)', async () => {
await expect(page).toClick('#addBtn');
await expect(page).toFill('#manifestURL', 'http://localhost:5000/api/broken');
await expect(page).toClick('#fetchBtn');
await page.waitFor(1000);
await expect(page).toMatchElement(
'p', { text: 'The resource cannot be added:' },
);
await expect(page).toMatchElement(
'p', { text: 'http://localhost:5000/api/broken' },
);
await expect(page).toClick('button', { text: 'Dismiss' });
await expect(page).not.toMatchElement(
'p',
{ text: 'The resource http://localhost:5000/api/broken cannot be added.' },
);
});
}); });
import React from 'react'; import React from 'react';
import { shallow } from 'enzyme'; import { shallow } from 'enzyme';
import ManifestListItem from '../../../src/components/ManifestListItem'; import ManifestListItem from '../../../src/components/ManifestListItem';
import ManifestListItemError from '../../../src/containers/ManifestListItemError';
/** */ /** */
function createWrapper(props) { function createWrapper(props) {
...@@ -34,7 +35,7 @@ describe('ManifestListItem', () => { ...@@ -34,7 +35,7 @@ describe('ManifestListItem', () => {
const wrapper = createWrapper({ error: 'This is an error message' }); const wrapper = createWrapper({ error: 'This is an error message' });
expect(wrapper.find('WithStyles(Paper)').length).toBe(1); expect(wrapper.find('WithStyles(Paper)').length).toBe(1);
expect(wrapper.find('WithStyles(Paper)').children().text()).toEqual('This is an error message'); expect(wrapper.find(ManifestListItemError).length).toBe(1);
}); });
it('updates and adds window when button clicked', () => { it('updates and adds window when button clicked', () => {
const addWindow = jest.fn(); const addWindow = jest.fn();
......
...@@ -7,6 +7,7 @@ import Grid from '@material-ui/core/Grid'; ...@@ -7,6 +7,7 @@ import Grid from '@material-ui/core/Grid';
import Typography from '@material-ui/core/Typography'; import Typography from '@material-ui/core/Typography';
import ReactPlaceholder from 'react-placeholder'; import ReactPlaceholder from 'react-placeholder';
import { TextBlock, TextRow, RectShape } from 'react-placeholder/lib/placeholders'; import { TextBlock, TextRow, RectShape } from 'react-placeholder/lib/placeholders';
import ManifestListItemError from '../containers/ManifestListItemError';
import WindowIcon from './WindowIcon'; import WindowIcon from './WindowIcon';
import ns from '../config/css-ns'; import ns from '../config/css-ns';
import 'react-placeholder/lib/reactPlaceholder.css'; import 'react-placeholder/lib/reactPlaceholder.css';
...@@ -71,7 +72,7 @@ class ManifestListItem extends React.Component { ...@@ -71,7 +72,7 @@ class ManifestListItem extends React.Component {
if (error) { if (error) {
return ( return (
<Paper elevation={1} className={classes.root} data-manifestid={manifestId}> <Paper elevation={1} className={classes.root} data-manifestid={manifestId}>
{error} <ManifestListItemError manifestId={manifestId} />
</Paper> </Paper>
); );
} }
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment