Skip to content
Snippets Groups Projects
Commit 8d142157 authored by David Beniamine's avatar David Beniamine
Browse files

Merge branch '9-videoviewer-tests' into 'annotation-on-video'

Fix VideoViewer component tests

Closes #9

See merge request iiif/mirador-video-annotation!7
parents de20164d c15d3156
No related branches found
No related tags found
1 merge request!7Fix VideoViewer component tests
Pipeline #1232 failed
{
"@context": "http://iiif.io/api/presentation/3/context.json",
"id": "https://preview.iiif.io/cookbook/master/recipe/0003-mvm-video/manifest.json",
"type": "Manifest",
"label": {
"en": [
"Video Example 3"
]
},
"items": [
{
"id": "https://preview.iiif.io/cookbook/master/recipe/0003-mvm-video/canvas",
"type": "Canvas",
"height": 360,
"width": 640,
"duration": 1801.055,
"items": [
{
"id": "https://preview.iiif.io/cookbook/master/recipe/0003-mvm-video/canvas/page",
"type": "AnnotationPage",
"items": [
{
"id": "https://preview.iiif.io/cookbook/master/recipe/0003-mvm-video/canvas/page/annotation",
"type": "Annotation",
"motivation": "painting",
"body": {
"id": "https://fixtures.iiif.io/video/indiana/30-minute-clock/medium/30-minute-clock.mp4",
"type": "Video",
"height": 360,
"width": 640,
"duration": 1801.055,
"format": "video/mp4"
},
"target": "https://preview.iiif.io/cookbook/master/recipe/0003-mvm-video/canvas"
}
]
}
]
}
]
}
\ No newline at end of file
describe('Basic end to end Mirador with video content', () => {
beforeAll(async () => {
await page.goto('http://localhost:4488/__tests__/integration/mirador/blank.html');
});
it('loads a manifest and displays it', async () => {
await page.waitForSelector('#addBtn');
await expect(page).toClick('#addBtn');
await expect(page).toClick('.mirador-add-resource-button');
await expect(page).toFill('#manifestURL', 'http://localhost:4488/__tests__/fixtures/version-3/video.json');
await expect(page).toClick('#fetchBtn');
await expect(page).toMatchElement('[data-manifestid="http://localhost:4488/__tests__/fixtures/version-3/video.json"] button');
await expect(page).toClick('[data-manifestid="http://localhost:4488/__tests__/fixtures/version-3/video.json"] button');
await expect(page).toMatchElement(
'h2',
{ text: /Video Example 3/ },
);
});
it('render subtitles', async () => {
await page.waitForSelector('#addBtn');
await expect(page).toClick('#addBtn');
await expect(page).toClick('.mirador-add-resource-button');
await expect(page).toFill('#manifestURL', 'https://preview.iiif.io/cookbook/0219-using-caption-file/recipe/0219-using-caption-file/manifest.json');
await expect(page).toClick('#fetchBtn');
await expect(page).toMatchElement('[data-manifestid="https://preview.iiif.io/cookbook/0219-using-caption-file/recipe/0219-using-caption-file/manifest.json"] button');
await expect(page).toClick('[data-manifestid="https://preview.iiif.io/cookbook/0219-using-caption-file/recipe/0219-using-caption-file/manifest.json"] button');
await expect(page).toMatchElement('track[src="https://fixtures.iiif.io/video/indiana/lunchroom_manners/lunchroom_manners.vtt"]');
});
});
describe('Basic end to end Mirador with preloaded video content', () => {
beforeAll(async () => {
await page.goto('http://localhost:4488/__tests__/integration/mirador/video.html');
});
it('load multiples audio/video manifests', async () => {
await page.waitForSelector('h2');
await page.waitForSelector('audio');
await page.waitForSelector('video');
await expect(page).toMatchElement('h2', { text: /Video Example 3/ });
await expect(page).toMatchElement('h2', { text: /Partial audio recording of Gustav Mahler's _Symphony No. 3_/ });
await expect(page).toMatchElement('h2', { text: /L'Elisir D'Amore/ });
await expect(page).toMatchElement('h2', { text: /Lunchroom Manners/ });
});
it('can add an image manifest', async () => {
await page.waitForSelector('#addBtn');
await expect(page).toClick('#addBtn');
await expect(page).toClick('.mirador-add-resource-button');
await expect(page).toFill('#manifestURL', 'https://iiif.harvardartmuseums.org/manifests/object/299843');
await expect(page).toClick('#fetchBtn');
await page.waitForSelector('[data-manifestid="https://iiif.harvardartmuseums.org/manifests/object/299843"] button');
await expect(page).toMatchElement('[data-manifestid="https://iiif.harvardartmuseums.org/manifests/object/299843"] button');
await expect(page).toClick('[data-manifestid="https://iiif.harvardartmuseums.org/manifests/object/299843"] button');
await page.waitForSelector('.mirador-osd-container');
await expect(page).toMatchElement('.mirador-osd-container');
});
});
import React from 'react'; import React from 'react';
import { shallow } from 'enzyme'; import { shallow } from 'enzyme';
import { Utils } from 'manifesto.js';
import { VideoViewer } from '../../../src/components/VideoViewer'; import { VideoViewer } from '../../../src/components/VideoViewer';
import videoSimple from '../../fixtures/version-3/video.json';
/** create wrapper */ /** create wrapper */
function createWrapper(props, suspenseFallback) { function createWrapper(props, suspenseFallback) {
...@@ -16,36 +18,18 @@ function createWrapper(props, suspenseFallback) { ...@@ -16,36 +18,18 @@ function createWrapper(props, suspenseFallback) {
describe('VideoViewer', () => { describe('VideoViewer', () => {
let wrapper; let wrapper;
describe('render', () => { describe('render', () => {
const canvasSimple = Utils.parseManifest(videoSimple).getSequences()[0].getCanvases()[0];
it('videoResources', () => { it('videoResources', () => {
wrapper = createWrapper({ wrapper = createWrapper({
videoResources: [ canvas: canvasSimple,
{ getFormat: () => 'video/mp4', id: 1 },
{ getFormat: () => 'video/mp4', id: 2 },
],
}, true); }, true);
expect(wrapper.contains(<source src={1} type="video/mp4" />)).toBe(true); expect(wrapper.contains(<source src="https://fixtures.iiif.io/video/indiana/30-minute-clock/medium/30-minute-clock.mp4" type="video/mp4" />)).toBe(true);
expect(wrapper.contains(<source src={2} type="video/mp4" />)).toBe(true);
}); });
it('passes through configurable options', () => { it('passes through configurable options', () => {
wrapper = createWrapper({ wrapper = createWrapper({
videoResources: [ canvas: canvasSimple,
{ getFormat: () => 'video/mp4', id: 1 },
],
}, true); }, true);
expect(wrapper.exists('video[crossOrigin="anonymous"]')).toBe(true); // eslint-disable-line jsx-a11y/media-has-caption expect(wrapper.exists('video[crossOrigin="anonymous"]')).toBe(true); // eslint-disable-line jsx-a11y/media-has-caption
}); });
it('captions', () => {
wrapper = createWrapper({
captions: [
{ getDefaultLabel: () => 'English', getProperty: () => 'en', id: 1 },
{ getDefaultLabel: () => 'French', getProperty: () => 'fr', id: 2 },
],
videoResources: [
{ getFormat: () => 'video/mp4', id: 1 },
],
}, true);
expect(wrapper.contains(<track src={1} label="English" srcLang="en" />)).toBe(true);
expect(wrapper.contains(<track src={2} label="French" srcLang="fr" />)).toBe(true);
});
}); });
}); });
...@@ -13,6 +13,9 @@ ...@@ -13,6 +13,9 @@
"setupFiles": [ "setupFiles": [
"<rootDir>/setupJest.js" "<rootDir>/setupJest.js"
], ],
"setupFilesAfterEnv": [
"<rootDir>/setup-expect-timeout.js"
],
"testMatch": [ "testMatch": [
"<rootDir>/**/__tests__/**/*.{js,jsx}", "<rootDir>/**/__tests__/**/*.{js,jsx}",
"<rootDir>/src/**/?(*.)(spec|test|unit).{js,jsx}" "<rootDir>/src/**/?(*.)(spec|test|unit).{js,jsx}"
......
This diff is collapsed.
const { setDefaultOptions } = require('expect-puppeteer');
setDefaultOptions({ timeout: 2000 });
...@@ -5,6 +5,7 @@ import SyncDisabledIcon from '@material-ui/icons/SyncDisabled'; ...@@ -5,6 +5,7 @@ import SyncDisabledIcon from '@material-ui/icons/SyncDisabled';
import VisibilityIcon from '@material-ui/icons/VisibilitySharp'; import VisibilityIcon from '@material-ui/icons/VisibilitySharp';
import VisibilityOffIcon from '@material-ui/icons/VisibilityOffSharp'; import VisibilityOffIcon from '@material-ui/icons/VisibilityOffSharp';
import MiradorMenuButton from '../containers/MiradorMenuButton'; import MiradorMenuButton from '../containers/MiradorMenuButton';
import { VideoViewersReferences } from '../plugins/VideoViewersReferences';
/** /**
* AnnotationSettings is a component to handle various annotation * AnnotationSettings is a component to handle various annotation
...@@ -16,10 +17,12 @@ export class AnnotationSettings extends Component { ...@@ -16,10 +17,12 @@ export class AnnotationSettings extends Component {
*/ */
render() { render() {
const { const {
autoScroll, autoScrollDisabled, windowId, autoScroll, autoScrollDisabled,
displayAll, displayAllDisabled, t, toggleAnnotationAutoScroll, toggleAnnotationDisplay, displayAll, displayAllDisabled, t, toggleAnnotationAutoScroll, toggleAnnotationDisplay,
} = this.props; } = this.props;
const mediaIsVideo = typeof VideoViewersReferences.get(windowId) !== 'undefined';
return ( return (
<> <>
<MiradorMenuButton <MiradorMenuButton
...@@ -30,6 +33,7 @@ export class AnnotationSettings extends Component { ...@@ -30,6 +33,7 @@ export class AnnotationSettings extends Component {
> >
{ displayAll ? <VisibilityIcon /> : <VisibilityOffIcon /> } { displayAll ? <VisibilityIcon /> : <VisibilityOffIcon /> }
</MiradorMenuButton> </MiradorMenuButton>
{ mediaIsVideo && (
<MiradorMenuButton <MiradorMenuButton
aria-label={autoScroll ? 'Disable auto scroll' : 'Enable auto scroll'} aria-label={autoScroll ? 'Disable auto scroll' : 'Enable auto scroll'}
onClick={toggleAnnotationAutoScroll} onClick={toggleAnnotationAutoScroll}
...@@ -38,6 +42,7 @@ export class AnnotationSettings extends Component { ...@@ -38,6 +42,7 @@ export class AnnotationSettings extends Component {
> >
{ autoScroll ? <SyncIcon /> : <SyncDisabledIcon /> } { autoScroll ? <SyncIcon /> : <SyncDisabledIcon /> }
</MiradorMenuButton> </MiradorMenuButton>
)}
</> </>
); );
} }
......
...@@ -75,7 +75,6 @@ export const windowsReducer = (state = {}, action) => { ...@@ -75,7 +75,6 @@ export const windowsReducer = (state = {}, action) => {
{ {
...(orig || {}), ...(orig || {}),
canvasId: action.canvasId, canvasId: action.canvasId,
currentTime: 0,
visibleCanvases: action.visibleCanvases || [], visibleCanvases: action.visibleCanvases || [],
}), state); }), state);
case ActionTypes.ADD_COMPANION_WINDOW: case ActionTypes.ADD_COMPANION_WINDOW:
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment