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
No related branches found
No related tags found
No related merge requests found
<html>
<title>Error</title>
<body>
<p>Something went wrong</p>
</body>
</html>
describe('Mirador Invalid API Response Handler Test', () => {
beforeAll(async () => {
beforeEach(async () => {
await page.goto('http://127.0.0.1:4488/__tests__/integration/mirador/');
});
it('breaks Mirador', async () => {
......@@ -14,4 +14,25 @@ describe('Mirador Invalid API Response Handler Test', () => {
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 { shallow } from 'enzyme';
import ManifestListItem from '../../../src/components/ManifestListItem';
import ManifestListItemError from '../../../src/containers/ManifestListItemError';
/** */
function createWrapper(props) {
......@@ -34,7 +35,7 @@ describe('ManifestListItem', () => {
const wrapper = createWrapper({ error: 'This is an error message' });
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', () => {
const addWindow = jest.fn();
......
......@@ -7,6 +7,7 @@ import Grid from '@material-ui/core/Grid';
import Typography from '@material-ui/core/Typography';
import ReactPlaceholder from 'react-placeholder';
import { TextBlock, TextRow, RectShape } from 'react-placeholder/lib/placeholders';
import ManifestListItemError from '../containers/ManifestListItemError';
import WindowIcon from './WindowIcon';
import ns from '../config/css-ns';
import 'react-placeholder/lib/reactPlaceholder.css';
......@@ -71,7 +72,7 @@ class ManifestListItem extends React.Component {
if (error) {
return (
<Paper elevation={1} className={classes.root} data-manifestid={manifestId}>
{error}
<ManifestListItemError manifestId={manifestId} />
</Paper>
);
}
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment