fix: fix keyboard shortcuts in notifications (#903)

fixes #894
This commit is contained in:
Nolan Lawson 2019-01-19 16:04:06 -08:00 committed by GitHub
parent 031caec406
commit b014778761
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
3 changed files with 22 additions and 3 deletions

View file

@ -1,6 +1,6 @@
{#if status}
<Status {index} {length} {timelineType} {timelineValue} {focusSelector}
{status} {notification} {active} on:recalculateHeight
{status} {notification} {active} {shortcutScope} on:recalculateHeight
/>
{:else}
<article class="notification-article {active ? 'active' : ''}"

View file

@ -3,6 +3,7 @@
timelineType={virtualProps.timelineType}
timelineValue={virtualProps.timelineValue}
focusSelector={virtualProps.focusSelector}
shortcutScope={virtualKey}
index={virtualIndex}
length={virtualLength}
{active}

View file

@ -6,8 +6,9 @@ import {
getNthStatusMedia,
getNthStatusSensitiveMediaButton,
getNthStatusSpoiler,
getUrl,
scrollToStatus } from '../utils'
getUrl, notificationsNavButton,
scrollToStatus
} from '../utils'
import { homeTimeline } from '../fixtures'
import { loginAsFoobar } from '../roles'
import { indexWhere } from '../../src/routes/_utils/arrays'
@ -126,3 +127,20 @@ test('Shortcut f toggles favorite status', async t => {
.pressKey('f')
.expect(getNthFavorited(idx)).eql('false')
})
test('Shortcut f toggles favorite status in notification', async t => {
let idx = 0
await loginAsFoobar(t)
await t
.expect(getUrl()).eql('http://localhost:4002/')
.click(notificationsNavButton)
.expect(getUrl()).contains('/notifications')
.expect(getNthStatus(idx).exists).ok({ timeout: 30000 })
.expect(getNthFavorited(idx)).eql('false')
.pressKey('j '.repeat(idx + 1))
.expect(getNthStatus(idx).hasClass('status-active')).ok()
.pressKey('f')
.expect(getNthFavorited(idx)).eql('true')
.pressKey('f')
.expect(getNthFavorited(idx)).eql('false')
})