From 903a1dfdd28c85c75e5f562ba8e8890ce34fd3e0 Mon Sep 17 00:00:00 2001 From: "imranasghar96@hotmail.com" <imranasghar96@hotmail.com> Date: Mon, 26 Oct 2020 19:27:08 -0400 Subject: [PATCH] Add integration test for multi-seq dropdown --- .../mirador/sequence_switching.test.js | 35 +++++++++++++++++++ src/components/WindowSideBarCanvasPanel.js | 2 +- 2 files changed, 36 insertions(+), 1 deletion(-) create mode 100644 __tests__/integration/mirador/sequence_switching.test.js diff --git a/__tests__/integration/mirador/sequence_switching.test.js b/__tests__/integration/mirador/sequence_switching.test.js new file mode 100644 index 000000000..f968726a3 --- /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 1d6376d58..372b45892 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> ) -- GitLab