diff --git a/package.json b/package.json index 07700a6b..2f6967da 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "impro", - "version": "0.20.84", + "version": "0.20.85", "type": "module", "scripts": { "start": "rm -rf \"${BUILD_DIR:-build}\" && NODE_ENV=development eleventy --serve", diff --git a/src/js/views/notifications.view.js b/src/js/views/notifications.view.js index eea34e09..9c7f71a0 100644 --- a/src/js/views/notifications.view.js +++ b/src/js/views/notifications.view.js @@ -190,7 +190,6 @@ export default async function notificationsView({ } function isWithinGroupWindow(notificationGroup, notification) { - if (notificationGroup.type !== "subscribed-post") return true; const head = notificationGroup.notifications[0]; const ageDifferenceMs = new Date(head.indexedAt) - new Date(notification.indexedAt); diff --git a/tests/e2e/specs/views/notifications.view.test.js b/tests/e2e/specs/views/notifications.view.test.js index 2ec954e5..86eaadb3 100644 --- a/tests/e2e/specs/views/notifications.view.test.js +++ b/tests/e2e/specs/views/notifications.view.test.js @@ -240,6 +240,40 @@ test.describe("Notifications view", () => { await expect(item.locator(".notification-avatar")).toHaveCount(2); }); + test("should not group follows more than 48h apart", async ({ page }) => { + const hoursAgo = (hours) => + new Date(Date.now() - hours * 60 * 60 * 1000).toISOString(); + const mockServer = new MockServer(); + mockServer.addNotifications([ + createNotification({ + reason: "follow", + author: alice, + indexedAt: hoursAgo(1), + }), + createNotification({ + reason: "follow", + author: bob, + indexedAt: hoursAgo(10), + }), + createNotification({ + reason: "follow", + author: charlie, + indexedAt: hoursAgo(60), + }), + ]); + await mockServer.setup(page); + + await login(page); + await page.goto("/notifications"); + + const view = page.locator("#notifications-view"); + const items = view.locator(".notification-item"); + await expect(items).toHaveCount(2, { timeout: 10000 }); + await expect(items.nth(0).locator(".notification-avatar")).toHaveCount(2); + await expect(items.nth(1).locator(".notification-avatar")).toHaveCount(1); + await expect(items.nth(1)).toContainText("Charlie"); + }); + test("should show the starter pack a follow came from", async ({ page }) => { const mockServer = new MockServer(); const starterPack = createStarterPack({