2018-02-21 18:26:22 +01:00
|
|
|
import {
|
2018-03-16 04:31:58 +01:00
|
|
|
getNthStatus, scrollToStatus, closeDialogButton, modalDialogContents, getActiveElementClass, goBack, getUrl,
|
2018-03-17 03:04:48 +01:00
|
|
|
goBackButton, getActiveElementInnerText, getNthReplyButton, getActiveElementAriaLabel, getActiveElementInsideNthStatus
|
2018-02-21 18:26:22 +01:00
|
|
|
} from '../utils'
|
|
|
|
import { foobarRole } from '../roles'
|
|
|
|
|
2018-03-07 06:32:51 +01:00
|
|
|
fixture`010-focus.js`
|
2018-02-21 18:26:22 +01:00
|
|
|
.page`http://localhost:4002`
|
|
|
|
|
|
|
|
test('modal preserves focus', async t => {
|
|
|
|
await t.useRole(foobarRole)
|
|
|
|
await scrollToStatus(t, 9)
|
|
|
|
await t.click(getNthStatus(9).find('.play-video-button'))
|
|
|
|
.click(closeDialogButton)
|
|
|
|
.expect(modalDialogContents.exists).notOk()
|
2018-03-16 07:01:38 +01:00
|
|
|
.expect(getActiveElementClass()).contains('play-video-button')
|
2018-03-17 03:04:48 +01:00
|
|
|
.expect(getActiveElementInsideNthStatus()).eql('9')
|
2018-02-21 18:26:22 +01:00
|
|
|
})
|
|
|
|
|
|
|
|
test('timeline preserves focus', async t => {
|
|
|
|
await t.useRole(foobarRole)
|
|
|
|
.click(getNthStatus(0))
|
2018-03-06 07:36:54 +01:00
|
|
|
.expect(getUrl()).contains('/statuses/')
|
2018-02-21 18:26:22 +01:00
|
|
|
|
|
|
|
await goBack()
|
2018-03-16 04:31:58 +01:00
|
|
|
await t.expect(getUrl()).eql('http://localhost:4002/')
|
2018-03-16 07:01:38 +01:00
|
|
|
.expect(getActiveElementClass()).contains('status-article status-in-timeline')
|
2018-03-17 03:04:48 +01:00
|
|
|
.expect(getActiveElementInsideNthStatus()).eql('0')
|
2018-03-16 04:31:58 +01:00
|
|
|
})
|
|
|
|
|
|
|
|
test('timeline link preserves focus', async t => {
|
|
|
|
await t.useRole(foobarRole)
|
|
|
|
.click(getNthStatus(0).find('.status-header a'))
|
|
|
|
.expect(getUrl()).contains('/accounts/')
|
|
|
|
.click(goBackButton)
|
|
|
|
.expect(getUrl()).eql('http://localhost:4002/')
|
|
|
|
.expect(getActiveElementInnerText()).eql('admin')
|
2018-03-17 02:48:24 +01:00
|
|
|
.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 03:04:48 +01:00
|
|
|
.expect(getActiveElementInsideNthStatus()).eql('0')
|
2018-03-16 04:31:58 +01: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(getActiveElementInnerText()).eql('quux')
|
2018-03-17 03:04:48 +01:00
|
|
|
.expect(getActiveElementInsideNthStatus()).eql('5')
|
|
|
|
})
|
|
|
|
|
|
|
|
test('reply preserves focus and moves focus to the text input', async t => {
|
|
|
|
await t.useRole(foobarRole)
|
|
|
|
.click(getNthReplyButton(1))
|
|
|
|
.expect(getUrl()).contains('/reply')
|
|
|
|
.expect(getActiveElementClass()).contains('compose-box-input')
|
|
|
|
.click(goBackButton)
|
|
|
|
.expect(getUrl()).eql('http://localhost:4002/')
|
|
|
|
.expect(getActiveElementClass()).contains('icon-button')
|
|
|
|
.expect(getActiveElementAriaLabel()).eql('Reply')
|
|
|
|
.expect(getActiveElementInsideNthStatus()).eql('1')
|
2018-02-21 18:26:22 +01:00
|
|
|
})
|