diff --git a/tests/spec/010-focus.js b/tests/spec/010-focus.js index fee95009..644384e3 100644 --- a/tests/spec/010-focus.js +++ b/tests/spec/010-focus.js @@ -1,5 +1,6 @@ import { - getNthStatus, scrollToStatus, closeDialogButton, modalDialogContents, getActiveElementClass, goBack, getUrl + getNthStatus, scrollToStatus, closeDialogButton, modalDialogContents, getActiveElementClass, goBack, getUrl, + goBackButton, getActiveElementInnerText } from '../utils' import { foobarRole } from '../roles' @@ -21,5 +22,26 @@ test('timeline preserves focus', async t => { .expect(getUrl()).contains('/statuses/') 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') }) diff --git a/tests/utils.js b/tests/utils.js index b674ef42..dc51ca83 100644 --- a/tests/utils.js +++ b/tests/utils.js @@ -31,6 +31,7 @@ export const accountProfileName = $('.account-profile .account-profile-name') export const accountProfileUsername = $('.account-profile .account-profile-username') export const accountProfileFollowedBy = $('.account-profile .account-profile-followed-by') 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({ innerCount: el => parseInt(el.innerText, 10) @@ -48,6 +49,10 @@ export const getActiveElementClass = exec(() => document.activeElement ? document.activeElement.getAttribute('class') : '' ) +export const getActiveElementInnerText = exec(() => + document.activeElement && document.activeElement.innerText +) + export const goBack = exec(() => window.history.back()) export const forceOffline = exec(() => window.store.set({online: false}))