pinafore/tests/spec/010-focus.js

99 lines
3.8 KiB
JavaScript
Raw Normal View History

2018-02-21 17:26:22 +00:00
import {
2018-03-16 03:31:58 +00:00
getNthStatus, scrollToStatus, closeDialogButton, modalDialogContents, getActiveElementClass, goBack, getUrl,
goBackButton, getActiveElementInnerText, getNthReplyButton, getActiveElementInsideNthStatus, focus,
getNthStatusSelector
2018-02-21 17:26:22 +00:00
} from '../utils'
import { foobarRole } from '../roles'
2018-03-07 05:32:51 +00:00
fixture`010-focus.js`
2018-02-21 17:26:22 +00:00
.page`http://localhost:4002`
test('modal preserves focus', async t => {
await t.useRole(foobarRole)
await scrollToStatus(t, 9)
// explicitly hover-focus-click
await t.hover(getNthStatus(9).find('.play-video-button'))
await focus(`${getNthStatusSelector(9)} .play-video-button`)()
2018-02-21 17:26:22 +00:00
await t.click(getNthStatus(9).find('.play-video-button'))
.click(closeDialogButton)
.expect(modalDialogContents.exists).notOk()
2018-03-16 06:01:38 +00:00
.expect(getActiveElementClass()).contains('play-video-button')
2018-03-17 02:04:48 +00:00
.expect(getActiveElementInsideNthStatus()).eql('9')
2018-02-21 17:26:22 +00:00
})
test('timeline preserves focus', async t => {
await t.useRole(foobarRole)
// explicitly hover-focus-click
await t.hover(getNthStatus(0))
await focus(getNthStatusSelector(0))()
await t.click(getNthStatus(0))
2018-03-06 06:36:54 +00:00
.expect(getUrl()).contains('/statuses/')
2018-02-21 17:26:22 +00:00
await goBack()
2018-03-16 03:31:58 +00:00
await t.expect(getUrl()).eql('http://localhost:4002/')
2018-03-16 06:01:38 +00:00
.expect(getActiveElementClass()).contains('status-article status-in-timeline')
2018-03-17 02:04:48 +00:00
.expect(getActiveElementInsideNthStatus()).eql('0')
2018-03-16 03:31:58 +00:00
})
test('timeline link preserves focus', async t => {
await t.useRole(foobarRole)
.expect(getNthStatus(0).exists).ok({timeout: 20000})
2018-03-16 03:31:58 +00:00
.click(getNthStatus(0).find('.status-header a'))
.expect(getUrl()).contains('/accounts/')
.click(goBackButton)
.expect(getUrl()).eql('http://localhost:4002/')
.expect(getNthStatus(0).exists).ok()
2018-03-16 03:31:58 +00:00
.expect(getActiveElementInnerText()).eql('admin')
.click(getNthStatus(0).find('.status-sidebar'))
.expect(getUrl()).contains('/accounts/')
.click(goBackButton)
.expect(getUrl()).eql('http://localhost:4002/')
.expect(getActiveElementClass()).contains('status-sidebar')
2018-03-17 02:04:48 +00:00
.expect(getActiveElementInsideNthStatus()).eql('0')
2018-03-16 03:31:58 +00:00
})
test('notification timeline preserves focus', async t => {
await t.useRole(foobarRole)
.navigateTo('/notifications')
await scrollToStatus(t, 5)
await t.click(getNthStatus(5).find('.status-header a'))
.expect(getUrl()).contains('/accounts/')
.click(goBackButton)
.expect(getUrl()).eql('http://localhost:4002/notifications')
.expect(getNthStatus(0).exists).ok()
2018-03-16 03:31:58 +00:00
.expect(getActiveElementInnerText()).eql('quux')
2018-03-17 02:04:48 +00:00
.expect(getActiveElementInsideNthStatus()).eql('5')
})
test('thread preserves focus', async t => {
await t.useRole(foobarRole)
.navigateTo('/accounts/3')
await scrollToStatus(t, 2)
await t.click(getNthStatus(2))
.expect(getUrl()).contains('/statuses/')
.click(getNthStatus(24).find('.status-sidebar'))
.expect(getUrl()).contains('/accounts/')
.click(goBackButton)
.expect(getUrl()).contains('/statuses/')
.expect(getNthStatus(24).exists).ok()
.expect(getActiveElementClass()).contains('status-sidebar')
.expect(getActiveElementInsideNthStatus()).eql('24')
.click(getNthStatus(23))
.expect(getNthStatus(23).find('.status-absolute-date').exists).ok()
await goBack()
await t.expect(getNthStatus(24).find('.status-absolute-date').exists).ok()
.expect(getActiveElementClass()).contains('status-article status-in-timeline')
.expect(getActiveElementInsideNthStatus()).eql('23')
})
2018-03-17 02:04:48 +00:00
test('reply preserves focus and moves focus to the text input', async t => {
await t.useRole(foobarRole)
.expect(getNthStatus(1).exists).ok({timeout: 20000})
2018-03-17 02:04:48 +00:00
.click(getNthReplyButton(1))
.expect(getActiveElementClass()).contains('compose-box-input')
2018-02-21 17:26:22 +00:00
})
test('focus .container div on index page load', async t => {
await t.expect(getActiveElementClass()).contains('container')
})