diff --git a/__tests__/integration/mirador/sequence_switching.test.js b/__tests__/integration/mirador/sequence_switching.test.js new file mode 100644 index 0000000000000000000000000000000000000000..f968726a3b43270af231c3ecfe5eaaeccfb4615e --- /dev/null +++ b/__tests__/integration/mirador/sequence_switching.test.js @@ -0,0 +1,35 @@ +/* global miradorInstance */ + +describe('Window Sidebar Sequence Dropdown', () => { + 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-2/multipleSequences.json'); + await expect(page).toClick('#fetchBtn'); + + await expect(page).toMatchElement('[data-manifestid="http://localhost:4488/__tests__/fixtures/version-2/multipleSequences.json"] button'); + await expect(page).toClick('[data-manifestid="http://localhost:4488/__tests__/fixtures/version-2/multipleSequences.json"] button'); + }); + + it('allows the user to switch the application', 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-2/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('#sequence-1'); + await expect(page).toClick('#sequence-1'); + await expect(page).toMatchElement('p', { text: 'fragm1a_1r' }); + }); +}); diff --git a/src/components/WindowSideBarCanvasPanel.js b/src/components/WindowSideBarCanvasPanel.js index 1d6376d584e9039db0ff5093130d54495cdf0bc6..372b4589219b0245081ab54be417f3c488ef33a4 100644 --- a/src/components/WindowSideBarCanvasPanel.js +++ b/src/components/WindowSideBarCanvasPanel.js @@ -137,7 +137,7 @@ export class WindowSideBarCanvasPanel extends Component { classes={{ select: classes.select }} className={classes.selectEmpty} > - { sequences.map((s, i) => <MenuItem value={s.id} key={s.id}><Typography variant="body2">{ WindowSideBarCanvasPanel.getUseableLabel(s, i) }</Typography></MenuItem>) } + { sequences.map((s, i) => <MenuItem id={`sequence-${i}`} value={s.id} key={s.id}><Typography variant="body2">{ WindowSideBarCanvasPanel.getUseableLabel(s, i) }</Typography></MenuItem>) } </Select> </FormControl> )