diff --git a/__tests__/fixtures/version-3/001.json b/__tests__/fixtures/version-3/001.json index a148c32bc8..83772517b7 100644 --- a/__tests__/fixtures/version-3/001.json +++ b/__tests__/fixtures/version-3/001.json @@ -240,7 +240,11 @@ { "id": "https://iiif.bodleian.ox.ac.uk/iiif/canvas/9cca8fdd-4a61-4429-8ac1-f648764b4d6d.json", "type": "Canvas", - "label": "Whole Page", + "label": { + "en": [ + "Whole Page" + ] + }, "width": 5776, "height": 9125, "items": [ @@ -360,4 +364,4 @@ ] } ] -} +} \ No newline at end of file diff --git a/__tests__/fixtures/version-3/multipleSequences.json b/__tests__/fixtures/version-3/multipleSequences.json new file mode 100644 index 0000000000..4f84d0bc00 --- /dev/null +++ b/__tests__/fixtures/version-3/multipleSequences.json @@ -0,0 +1,59 @@ +{ + "@context": [ + "http://iiif.io/api/presentation/3/context.json" + ], + "id": "http://foo.test/1/manifest", + "type": "Manifest", + "label": { + "none": ["Version 3 manifest for multiple ranges (sequences behavior) related tests"] + }, + "items": [ + { + "id": "http://foo.test/1/canvas/c1", + "type": "Canvas", + "label":{"none":["Test Canvas 1"]} + }, + { + "id": "http://foo.test/1/canvas/c2", + "type": "Canvas", + "label":{"none":["Test Canvas 2"]} + }, + { + "id": "http://foo.test/1/canvas/c3", + "type": "Canvas", + "label":{"none":["Test Canvas 3"]} + } + ], + "structures": [ + { + "id": "http://foo.test/1/range/root", + "type": "Range", + "behavior": "sequence", + "items": [ + { + "id": "http://foo.test/1/canvas/c1", + "type": "Canvas", + "label":{"none":["Test Canvas 1"]} + } + ] + }, + { + "id": "http://foo.test/1/range/second", + "type": "Range", + "behavior": "sequence", + "items": [ + { + "id": "http://foo.test/1/canvas/c2", + "type": "Canvas", + "label":{"none":["Test Canvas 2"]} + }, + { + "id": "http://foo.test/1/canvas/c3", + "type": "Canvas", + "label":{"none":["Test Canvas 3"]} + } + ] + } + ] + } + \ No newline at end of file diff --git a/__tests__/integration/mirador/sequence_switching_v3.test.js b/__tests__/integration/mirador/sequence_switching_v3.test.js new file mode 100644 index 0000000000..a9f64680b1 --- /dev/null +++ b/__tests__/integration/mirador/sequence_switching_v3.test.js @@ -0,0 +1,34 @@ +/* global miradorInstance */ + +describe('Window Sidebar Sequence Dropdown v3', () => { + beforeAll(async () => { + await page.goto('http://127.0.0.1:4488/__tests__/integration/mirador/blank.html'); + + 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/multipleSequences.json'); + await expect(page).toClick('#fetchBtn'); + + await expect(page).toMatchElement('[data-manifestid="http://localhost:4488/__tests__/fixtures/version-3/multipleSequences.json"] button'); + await expect(page).toClick('[data-manifestid="http://localhost:4488/__tests__/fixtures/version-3/multipleSequences.json"] button'); + }); + + it('allows the user to switch the v3 ranges (behavior sequences)', async () => { + const windows = await page.evaluate(() => ( + miradorInstance.store.getState().windows + )); + + const windowId = Object.values(windows) + .find(window => window.manifestId === 'http://localhost:4488/__tests__/fixtures/version-3/multipleSequences.json') + .id; + + await expect(page).toMatchElement(`#${windowId} button[aria-label="Toggle sidebar"]`); + await expect(page).toClick(`#${windowId} button[aria-label="Toggle sidebar"]`); + await expect(page).toMatchElement(`#${windowId} button[aria-label="Index"]`); + await expect(page).toClick(`#${windowId} button[aria-label="Index"]`); + await expect(page).toClick('#mui-component-select-sequenceId'); + await expect(page).toMatchElement('[data-value="http://foo.test/1/range/second"]'); + await expect(page).toClick('[data-value="http://foo.test/1/range/second"]'); + await expect(page).toMatchElement('p', { text: 'Test Canvas 2' }); + }); +}); diff --git a/__tests__/src/selectors/sequences.test.js b/__tests__/src/selectors/sequences.test.js index 240fa6004a..8b94e6d1f4 100644 --- a/__tests__/src/selectors/sequences.test.js +++ b/__tests__/src/selectors/sequences.test.js @@ -13,6 +13,8 @@ import { getSequenceBehaviors, } from '../../../src/state/selectors/sequences'; +jest.mock('uuid', () => ({ v4: () => '00000000-0000-0000-0000-000000000000' })); + describe('getSequences', () => { describe('with a v2 manifest', () => { const state = { manifests: { x: { json: manifestFixtureGau } } }; @@ -49,7 +51,7 @@ describe('getSequences', () => { const state = { manifests: { x: { json: manifest } } }; const sequences = getSequences(state, { manifestId: 'x' }); expect(sequences.length).toEqual(3); - expect(sequences.map(s => s.id)).toEqual([undefined, 'a', 'b']); + expect(sequences.map(s => s.id)).toEqual(['00000000-0000-0000-0000-000000000000', 'a', 'b']); }); }); diff --git a/src/components/WindowSideBarCanvasPanel.js b/src/components/WindowSideBarCanvasPanel.js index abd76e08f4..69d1513065 100644 --- a/src/components/WindowSideBarCanvasPanel.js +++ b/src/components/WindowSideBarCanvasPanel.js @@ -88,7 +88,6 @@ export class WindowSideBarCanvasPanel extends Component { /> ); } - return ( { sequences && sequences.length > 1 && ( - +