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} {#if status}
<Status {index} {length} {timelineType} {timelineValue} {focusSelector} <Status {index} {length} {timelineType} {timelineValue} {focusSelector}
{status} {notification} {active} on:recalculateHeight {status} {notification} {active} {shortcutScope} on:recalculateHeight
/> />
{:else} {:else}
<article class="notification-article {active ? 'active' : ''}" <article class="notification-article {active ? 'active' : ''}"

View File

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

View File

@ -6,8 +6,9 @@ import {
getNthStatusMedia, getNthStatusMedia,
getNthStatusSensitiveMediaButton, getNthStatusSensitiveMediaButton,
getNthStatusSpoiler, getNthStatusSpoiler,
getUrl, getUrl, notificationsNavButton,
scrollToStatus } from '../utils' scrollToStatus
} from '../utils'
import { homeTimeline } from '../fixtures' import { homeTimeline } from '../fixtures'
import { loginAsFoobar } from '../roles' import { loginAsFoobar } from '../roles'
import { indexWhere } from '../../src/routes/_utils/arrays' import { indexWhere } from '../../src/routes/_utils/arrays'
@ -126,3 +127,20 @@ test('Shortcut f toggles favorite status', async t => {
.pressKey('f') .pressKey('f')
.expect(getNthFavorited(idx)).eql('false') .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')
})