add another focus test

This commit is contained in:
Nolan Lawson 2018-03-15 20:31:58 -07:00
parent a25dd048b6
commit c0a2a1e8bf
2 changed files with 29 additions and 2 deletions

View file

@ -1,5 +1,6 @@
import { import {
getNthStatus, scrollToStatus, closeDialogButton, modalDialogContents, getActiveElementClass, goBack, getUrl getNthStatus, scrollToStatus, closeDialogButton, modalDialogContents, getActiveElementClass, goBack, getUrl,
goBackButton, getActiveElementInnerText
} from '../utils' } from '../utils'
import { foobarRole } from '../roles' import { foobarRole } from '../roles'
@ -21,5 +22,26 @@ test('timeline preserves focus', async t => {
.expect(getUrl()).contains('/statuses/') .expect(getUrl()).contains('/statuses/')
await goBack() await goBack()
await t.expect(getActiveElementClass()).eql('status-article status-in-timeline') await t.expect(getUrl()).eql('http://localhost:4002/')
.expect(getActiveElementClass()).eql('status-article status-in-timeline')
})
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')
})
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')
}) })

View file

@ -31,6 +31,7 @@ export const accountProfileName = $('.account-profile .account-profile-name')
export const accountProfileUsername = $('.account-profile .account-profile-username') export const accountProfileUsername = $('.account-profile .account-profile-username')
export const accountProfileFollowedBy = $('.account-profile .account-profile-followed-by') export const accountProfileFollowedBy = $('.account-profile .account-profile-followed-by')
export const accountProfileFollowButton = $('.account-profile .account-profile-follow button') export const accountProfileFollowButton = $('.account-profile .account-profile-follow button')
export const goBackButton = $('.dynamic-page-go-back')
export const favoritesCountElement = $('.status-favs-reblogs:nth-child(3)').addCustomDOMProperties({ export const favoritesCountElement = $('.status-favs-reblogs:nth-child(3)').addCustomDOMProperties({
innerCount: el => parseInt(el.innerText, 10) innerCount: el => parseInt(el.innerText, 10)
@ -48,6 +49,10 @@ export const getActiveElementClass = exec(() =>
document.activeElement ? document.activeElement.getAttribute('class') : '' document.activeElement ? document.activeElement.getAttribute('class') : ''
) )
export const getActiveElementInnerText = exec(() =>
document.activeElement && document.activeElement.innerText
)
export const goBack = exec(() => window.history.back()) export const goBack = exec(() => window.history.back())
export const forceOffline = exec(() => window.store.set({online: false})) export const forceOffline = exec(() => window.store.set({online: false}))