From 74ab056f18ea6d1fb170d0a7b3a7e101dff1af60 Mon Sep 17 00:00:00 2001 From: Nolan Lawson Date: Sat, 19 Jan 2019 23:52:39 -0800 Subject: [PATCH] fix: fix notification m/p keyboard shortcuts (#907) fixes #905 --- src/routes/_components/status/Status.html | 9 ++++--- tests/spec/026-shortcuts-notification.js | 30 +++++++++++++++++++++++ 2 files changed, 35 insertions(+), 4 deletions(-) diff --git a/src/routes/_components/status/Status.html b/src/routes/_components/status/Status.html index 099132f1..b779265b 100644 --- a/src/routes/_components/status/Status.html +++ b/src/routes/_components/status/Status.html @@ -203,12 +203,12 @@ goto(`/statuses/${originalStatusId}`) }, openAuthorProfile () { - let { originalAccountId } = this.get() - goto(`/accounts/${originalAccountId}`) + let { accountForShortcut } = this.get() + goto(`/accounts/${accountForShortcut.id}`) }, async mentionAuthor () { - let { originalAccount } = this.get() - await composeNewStatusMentioning(originalAccount) + let { accountForShortcut } = this.get() + await composeNewStatusMentioning(accountForShortcut) } }, computed: { @@ -222,6 +222,7 @@ accountId: ({ account }) => account.id, originalAccount: ({ originalStatus }) => originalStatus.account, originalAccountId: ({ originalAccount }) => originalAccount.id, + accountForShortcut: ({ originalAccount, notification }) => notification ? notification.account : originalAccount, visibility: ({ originalStatus }) => originalStatus.visibility, plainTextContent: ({ content }) => htmlToPlainText(content), plainTextContentLength: ({ plainTextContent }) => measureText(plainTextContent), diff --git a/tests/spec/026-shortcuts-notification.js b/tests/spec/026-shortcuts-notification.js index df67d486..527c7ec3 100644 --- a/tests/spec/026-shortcuts-notification.js +++ b/tests/spec/026-shortcuts-notification.js @@ -56,3 +56,33 @@ test('Shortcut m toggles mention in a follow notification', async t => { .click(closeDialogButton) .expect(modalDialog.exists).notOk() }) + +test('Shortcut p refers to booster in a boost notification', async t => { + let idx = 1 // "@admin boosted your status" + await loginAsFoobar(t) + await t + .expect(getUrl()).eql('http://localhost:4002/') + .click(notificationsNavButton) + .expect(getUrl()).contains('/notifications') + .expect(getNthStatus(0).exists).ok({ timeout: 30000 }) + .pressKey('j '.repeat(idx + 1)) + .expect(getNthStatus(idx).hasClass('status-active')).ok() + .pressKey('p') + .expect(getUrl()).contains('/accounts/1') +}) + +test('Shortcut m refers to favoriter in a favorite notification', async t => { + let idx = 0 // "@admin favorited your status" + await loginAsFoobar(t) + await t + .expect(getUrl()).eql('http://localhost:4002/') + .click(notificationsNavButton) + .expect(getUrl()).contains('/notifications') + .expect(getNthStatus(0).exists).ok({ timeout: 30000 }) + .pressKey('j '.repeat(idx + 1)) + .expect(getNthStatus(idx).hasClass('status-active')).ok() + .pressKey('m') + .expect(composeModalInput.value).eql('@admin ') + .click(closeDialogButton) + .expect(modalDialog.exists).notOk() +})