From fcf64c21698791308602a7d08101bb54399e7b3d Mon Sep 17 00:00:00 2001 From: Nolan Lawson Date: Wed, 29 May 2019 18:48:59 -0700 Subject: [PATCH] fix: fix "Show more" button in Notifications timeline when filtered (#1255) --- src/routes/_components/timeline/Timeline.html | 4 +-- .../computations/timelineComputations.js | 8 +++++ .../spec/125-notification-timeline-filters.js | 36 ++++++++++++++++++- 3 files changed, 45 insertions(+), 3 deletions(-) diff --git a/src/routes/_components/timeline/Timeline.html b/src/routes/_components/timeline/Timeline.html index e6236808..5eaeff4e 100644 --- a/src/routes/_components/timeline/Timeline.html +++ b/src/routes/_components/timeline/Timeline.html @@ -130,8 +130,8 @@ itemIds: ({ $filteredTimelineItemSummaries }) => ( $filteredTimelineItemSummaries && $filteredTimelineItemSummaries.map(_ => _.id) ), - itemIdsToAdd: ({ $timelineItemSummariesToAdd }) => ( - $timelineItemSummariesToAdd && $timelineItemSummariesToAdd.map(_ => _.id) + itemIdsToAdd: ({ $filteredTimelineItemSummariesToAdd }) => ( + $filteredTimelineItemSummariesToAdd && $filteredTimelineItemSummariesToAdd.map(_ => _.id) ), headerProps: ({ itemIdsToAdd }) => { return { diff --git a/src/routes/_store/computations/timelineComputations.js b/src/routes/_store/computations/timelineComputations.js index 26785190..5280151d 100644 --- a/src/routes/_store/computations/timelineComputations.js +++ b/src/routes/_store/computations/timelineComputations.js @@ -143,6 +143,14 @@ export function timelineComputations (store) { } ) + store.compute( + 'filteredTimelineItemSummariesToAdd', + ['timelineItemSummariesToAdd', 'timelineFilterFunction'], + (timelineItemSummariesToAdd, timelineFilterFunction) => { + return timelineItemSummariesToAdd && timelineItemSummariesToAdd.filter(timelineFilterFunction) + } + ) + store.compute('timelineNotificationItemSummaries', [`timelineData_timelineItemSummariesToAdd`, 'timelineFilterFunction', 'currentInstance'], (root, timelineFilterFunction, currentInstance) => ( diff --git a/tests/spec/125-notification-timeline-filters.js b/tests/spec/125-notification-timeline-filters.js index a43e5027..fe9eba6f 100644 --- a/tests/spec/125-notification-timeline-filters.js +++ b/tests/spec/125-notification-timeline-filters.js @@ -4,7 +4,11 @@ import { instanceSettingNotificationReblogs, notificationBadge, instanceSettingNotificationFavs, - instanceSettingNotificationMentions, instanceSettingNotificationFollows + instanceSettingNotificationMentions, + instanceSettingNotificationFollows, + notificationsNavButton, + getUrl, + sleep, showMoreButton, scrollToBottom, scrollToTop } from '../utils' import { loginAsFoobar } from '../roles' import { Selector as $ } from 'testcafe' @@ -91,3 +95,33 @@ test('Notification timeline filters correctly affect counts - follows', async t .expect(notificationBadge.innerText).eql('1', { timeout }) await unfollowAs('ExternalLinks', 'foobar') }) + +test('Notification timeline filters correctly show "show more" button', async t => { + await loginAsFoobar(t) + await t + .click(settingsNavButton) + .click($('a').withText('Instances')) + .click($('a').withText('localhost:3000')) + .click(instanceSettingNotificationMentions) + .expect(instanceSettingNotificationMentions.checked).notOk() + .click(notificationsNavButton) + .expect(getUrl()).contains('/notifications') + .expect(getNthStatusContent(1).exists).ok() + await scrollToBottom() + await sleep(1000) + await postAs('admin', 'hey @foobar you should ignore this') + await sleep(1000) + await scrollToTop() + await sleep(1000) + await t + .expect(showMoreButton.innerText).contains('Show 0 more') // not shown + await scrollToBottom() + await sleep(1000) + await followAs('ExternalLinks', 'foobar') + await sleep(1000) + await scrollToTop() + await sleep(1000) + await t + .expect(showMoreButton.innerText).contains('Show 1 more', { timeout: 20000 }) + await unfollowAs('ExternalLinks', 'foobar') +})