test: add test

This commit is contained in:
Nolan Lawson 2022-11-27 10:02:34 -08:00
parent 08593d0dbb
commit 5bbbc91747
2 changed files with 21 additions and 1 deletions

View File

@ -14,7 +14,7 @@ import {
getActiveElementTagName, getActiveElementTagName,
getActiveElementClassList, getActiveElementClassList,
getNthStatusSensitiveMediaButton, getNthStatusSensitiveMediaButton,
getActiveElementAriaLabel, settingsNavButton, getActiveElementHref, communityNavButton getActiveElementAriaLabel, settingsNavButton, getActiveElementHref, communityNavButton, getActiveElementId
} from '../utils' } from '../utils'
import { loginAsFoobar } from '../roles' import { loginAsFoobar } from '../roles'
import { Selector as $ } from 'testcafe' import { Selector as $ } from 'testcafe'
@ -73,6 +73,22 @@ test('timeline link preserves focus', async t => {
.expect(getActiveElementInsideNthStatus()).eql('1') .expect(getActiveElementInsideNthStatus()).eql('1')
}) })
test('timeline link preserves focus - reblogger avatar', async t => {
await loginAsFoobar(t)
await t
.expect(getNthStatus(1).exists).ok({ timeout: 20000 })
const avatar = `${getNthStatusSelector(1)} .status-header-avatar a`
const id = await $(avatar).getAttribute('id')
await t
.click($(avatar))
.expect(getUrl()).contains('/accounts/')
.click(goBackButton)
.expect(getUrl()).eql('http://localhost:4002/')
.expect(getNthStatus(1).exists).ok()
.expect(getActiveElementId()).eql(id)
})
test('notification timeline preserves focus', async t => { test('notification timeline preserves focus', async t => {
await loginAsFoobar(t) await loginAsFoobar(t)
await t await t

View File

@ -169,6 +169,10 @@ export const getActiveElementInnerText = exec(() =>
(document.activeElement && document.activeElement.innerText) || '' (document.activeElement && document.activeElement.innerText) || ''
) )
export const getActiveElementId = exec(() =>
(document.activeElement && document.activeElement.id) || ''
)
export const getActiveElementRectTop = exec(() => ( export const getActiveElementRectTop = exec(() => (
(document.activeElement && document.activeElement.getBoundingClientRect().top) || -1 (document.activeElement && document.activeElement.getBoundingClientRect().top) || -1
)) ))