test: add test for shortcut when focus is inside status (#2232)

This commit is contained in:
Nolan Lawson 2022-11-23 08:49:40 -08:00 committed by GitHub
parent 8792d912bc
commit 53803db5be
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
2 changed files with 25 additions and 3 deletions

View file

@ -7,9 +7,17 @@ import {
getNthStatusMediaImg, getNthStatusMediaImg,
getNthStatusSensitiveMediaButton, getNthStatusSensitiveMediaButton,
getNthStatusSpoiler, getNthStatusSpoiler,
getUrl, modalDialog, getUrl,
modalDialog,
scrollToStatus, scrollToStatus,
isNthStatusActive, getActiveElementRectTop, scrollToTop, isActiveStatusPinned, getFirstModalMedia isNthStatusActive,
getActiveElementRectTop,
scrollToTop,
isActiveStatusPinned,
getFirstModalMedia,
getNthStatusAccountLink,
getNthStatusAccountLinkSelector,
focus
} from '../utils' } from '../utils'
import { homeTimeline } from '../fixtures' import { homeTimeline } from '../fixtures'
import { loginAsFoobar } from '../roles' import { loginAsFoobar } from '../roles'
@ -216,3 +224,13 @@ test('Shortcut j/k change the active status on pinned statuses', async t => {
.expect(isNthStatusActive(1)()).ok() .expect(isNthStatusActive(1)()).ok()
.expect(isActiveStatusPinned()).eql(true) .expect(isActiveStatusPinned()).eql(true)
}) })
test('Shortcut down makes next status active when focused inside of a status', async t => {
await loginAsFoobar(t)
await t
.expect(getNthStatusAccountLink(1).exists).ok()
await focus(getNthStatusAccountLinkSelector(1))()
await t
.pressKey('down')
.expect(isNthStatusActive(2)()).ok()
})

View file

@ -522,8 +522,12 @@ export function getNthStatusOptionsButton (n) {
return $(`${getNthStatusSelector(n)} .status-toolbar button:nth-child(4)`) return $(`${getNthStatusSelector(n)} .status-toolbar button:nth-child(4)`)
} }
export function getNthStatusAccountLinkSelector (n) {
return `${getNthStatusSelector(n)} .status-author-name`
}
export function getNthStatusAccountLink (n) { export function getNthStatusAccountLink (n) {
return $(`${getNthStatusSelector(n)} .status-author-name`) return $(getNthStatusAccountLinkSelector(n))
} }
export function getNthFavoritedLabel (n) { export function getNthFavoritedLabel (n) {