1
0
mirror of https://github.com/nolanlawson/pinafore synced 2024-12-15 11:48:35 +01:00
Pinafore-Web-Client-Frontend/tests/spec/030-shortcuts-modal.js
Nolan Lawson 8fc8108454
fix: back button dismisses the modal dialog (#826)
* fix: back button dismisses the modal dialog

fixes #60

* try to manage nested modals

* seems working now

* fix modal timing issue

* fix test flakiness

* improve test flakiness again

* fix muting timing issue

* Revert "fix muting timing issue"

* remove setTimeout from MediaDialog

* refactor
2019-03-24 15:08:34 -07:00

54 lines
1.6 KiB
JavaScript

import {
getMediaScrollLeft,
getNthStatusMediaButton, getNthStatusOptionsButton,
modalDialog, scrollToStatus, sleep
} from '../utils'
import { loginAsFoobar } from '../roles'
import { indexWhere } from '../../src/routes/_utils/arrays'
import { homeTimeline } from '../fixtures'
fixture`030-shortcuts-modal.js`
.page`http://localhost:4002`
test('Backspace dismisses modal', async t => {
await loginAsFoobar(t)
await t
.click(getNthStatusOptionsButton(1))
.expect(modalDialog.hasAttribute('aria-hidden')).notOk()
await sleep(1000)
await t
.pressKey('backspace')
.expect(modalDialog.exists).false
})
test('Backspace dismisses media modal', async t => {
await loginAsFoobar(t)
let idx = indexWhere(homeTimeline, _ => (_.content || '').includes('2 kitten photos'))
await scrollToStatus(t, idx + 1)
await t
.click(getNthStatusMediaButton(idx + 1))
.expect(modalDialog.hasAttribute('aria-hidden')).notOk()
await sleep(1000)
await t
.pressKey('backspace')
.expect(modalDialog.exists).false
})
test('Left/right changes active media in modal', async t => {
await loginAsFoobar(t)
let idx = indexWhere(homeTimeline, _ => (_.content || '').includes('2 kitten photos'))
await scrollToStatus(t, idx + 1)
await t
.click(getNthStatusMediaButton(idx + 1))
.expect(modalDialog.hasAttribute('aria-hidden')).notOk()
.expect(getMediaScrollLeft()).eql(0)
await sleep(1000)
await t
.pressKey('right')
.expect(getMediaScrollLeft()).gt(0)
await sleep(1000)
await t
.pressKey('backspace')
.expect(modalDialog.exists).false
})