From 61aec529765777f4dc20b9ff14b3a13bd75a5453 Mon Sep 17 00:00:00 2001 From: James Browning Date: Fri, 3 Apr 2026 16:06:37 +0100 Subject: [PATCH 1/3] tests: implement and enable 'can be notified for profile being mentioned in a post' notification e2e --- cypress/e2e/notifications.cy.ts | 41 +++++++++++++++++-- .../MentionPopover/MentionPopover.tsx | 1 + 2 files changed, 39 insertions(+), 3 deletions(-) diff --git a/cypress/e2e/notifications.cy.ts b/cypress/e2e/notifications.cy.ts index 3fac02189..91c690f41 100644 --- a/cypress/e2e/notifications.cy.ts +++ b/cypress/e2e/notifications.cy.ts @@ -19,8 +19,12 @@ import { import { verifyNotificationCounter } from '../support/common'; import { goToProfilePageFromHeader } from '../support/header'; +const uniqueSuffix = String(Date.now()).slice(-5); + const profile1 = { username: 'Notif #1', pubkyAlias: 'pubky_1' }; -const profile2 = { username: 'Notif #2', pubkyAlias: 'pubky_2' }; +// profile 2 has a unique suffix to avoid conflicts when mentioning profile 2 in new posts across test runs +// todo: use space in username after bug fixed https://github.com/pubky/pubky-app/issues/1638 +const profile2 = { username: `Notif#${uniqueSuffix}`, pubkyAlias: 'pubky_2' }; describe('notifications', () => { before(() => { @@ -159,8 +163,39 @@ describe('notifications', () => { // * profile 2 checks for absence of notifications }); - // todo: blocked by bug, see https://github.com/pubky/franky/issues/717 - it('can be notified for profile being mentioned in a post'); + it('can be notified for profile being mentioned in a post', () => { + // * profile 1 creates a post mentioning profile 2 via @username autocomplete + cy.get('[data-cy="home-post-input"]') + .should('be.visible') + .within(() => { + cy.get('textarea').should('have.value', '').type('Hey '); + // Type @Notif2 to trigger mention autocomplete for profile 2 only + cy.get('textarea').type(`@${profile2.username}`); + + // Wait for the mention popover and click profile 2's suggestion + cy.get('[data-cy="mention-popover"]').should('be.visible').contains(profile2.username).click(); + + // Submit the post + cy.intercept('PUT', '**/pub/pubky.app/posts/**').as('postCreated'); + cy.get('[data-cy="post-input-action-bar-post"]').click(); + cy.wait('@postCreated').its('response.statusCode').should('eq', 201); + cy.get('textarea').should('have.value', ''); + }); + + // * profile 2 checks for notification for being mentioned + cy.signOut(HasBackedUp.Yes); + + cy.signInWithEncryptedFile(backupDownloadFilePath(profile2.username)); + verifyNotificationCounter(1); + goToProfilePageFromHeader(); + verifyNotificationCounter(0); + checkLatestNotification([profile1.username, 'mentioned you in post'], LatestNotificationReadState.Unread); + + // * toggle tabs to check unread dot disappears + causeNotificationsToBeRead(); + verifyNotificationCounter(0); + checkLatestNotification([profile1.username, 'mentioned you in post'], LatestNotificationReadState.Read); + }); it('can be notified for your post being replied to', () => { // * profile 1 creates a post (1) diff --git a/src/components/molecules/MentionPopover/MentionPopover.tsx b/src/components/molecules/MentionPopover/MentionPopover.tsx index 786cdcc66..673dc0946 100644 --- a/src/components/molecules/MentionPopover/MentionPopover.tsx +++ b/src/components/molecules/MentionPopover/MentionPopover.tsx @@ -50,6 +50,7 @@ export function MentionPopover({ users, selectedIndex, onSelect, onHover }: Ment ref={containerRef} role="listbox" aria-label="User suggestions" + data-cy="mention-popover" data-testid="mention-popover" overrideDefaults className={Libs.cn(POPOVER_CLASSNAME)} From c3bf26ae3f798b2d205a64170fb5f18af08b1807 Mon Sep 17 00:00:00 2001 From: James Browning Date: Fri, 3 Apr 2026 16:29:09 +0100 Subject: [PATCH 2/3] tests: add skipped 'disable being notified for profile being mentioned in a post' test --- cypress/e2e/notifications.cy.ts | 64 ++++++++++++++++++++++----------- cypress/support/posts.ts | 14 ++++++++ 2 files changed, 58 insertions(+), 20 deletions(-) diff --git a/cypress/e2e/notifications.cy.ts b/cypress/e2e/notifications.cy.ts index 91c690f41..e56600c07 100644 --- a/cypress/e2e/notifications.cy.ts +++ b/cypress/e2e/notifications.cy.ts @@ -1,5 +1,13 @@ import { backupDownloadFilePath } from '../support/auth'; -import { createQuickPost, replyToPost, repostPost, deletePost, editPost, fastTagPostInFeed } from '../support/posts'; +import { + createQuickPost, + createQuickPostWithMention, + replyToPost, + repostPost, + deletePost, + editPost, + fastTagPostInFeed, +} from '../support/posts'; import { slowCypressDown } from 'cypress-slow-down'; import 'cypress-slow-down/commands'; import { searchAndFollowProfile, searchForProfileByPubky } from '../support/contacts'; @@ -21,10 +29,12 @@ import { goToProfilePageFromHeader } from '../support/header'; const uniqueSuffix = String(Date.now()).slice(-5); +// profile 1 and 2 are used for enabled notifications, profile 3 is used for disabled notifications const profile1 = { username: 'Notif #1', pubkyAlias: 'pubky_1' }; -// profile 2 has a unique suffix to avoid conflicts when mentioning profile 2 in new posts across test runs +// profile 2 and 3 have a unique suffix to avoid conflicts when mentioning profile 2 and 3 in new posts across test runs // todo: use space in username after bug fixed https://github.com/pubky/pubky-app/issues/1638 -const profile2 = { username: `Notif#${uniqueSuffix}`, pubkyAlias: 'pubky_2' }; +const profile2 = { username: `Notif#2${uniqueSuffix}`, pubkyAlias: 'pubky_2' }; +const profile3 = { username: `Notif#3${uniqueSuffix}`, pubkyAlias: 'pubky_3' }; describe('notifications', () => { before(() => { @@ -38,6 +48,10 @@ describe('notifications', () => { // * create profile 2 cy.onboardAsNewUser(profile2.username, '', [BackupType.EncryptedFile], profile2.pubkyAlias); cy.signOut(HasBackedUp.Yes); + + // * create profile 3 + cy.onboardAsNewUser(profile3.username, '', [BackupType.EncryptedFile], profile3.pubkyAlias); + cy.signOut(HasBackedUp.Yes); }); beforeEach(() => { @@ -45,6 +59,7 @@ describe('notifications', () => { cy.log('Re-creating aliases in beforeEach'); cy.wrap(Cypress.expose(profile1.pubkyAlias)).as(profile1.pubkyAlias); cy.wrap(Cypress.expose(profile2.pubkyAlias)).as(profile2.pubkyAlias); + cy.wrap(Cypress.expose(profile3.pubkyAlias)).as(profile3.pubkyAlias); // sign in if not already cy.location('pathname').then((currentPath) => { @@ -164,23 +179,8 @@ describe('notifications', () => { }); it('can be notified for profile being mentioned in a post', () => { - // * profile 1 creates a post mentioning profile 2 via @username autocomplete - cy.get('[data-cy="home-post-input"]') - .should('be.visible') - .within(() => { - cy.get('textarea').should('have.value', '').type('Hey '); - // Type @Notif2 to trigger mention autocomplete for profile 2 only - cy.get('textarea').type(`@${profile2.username}`); - - // Wait for the mention popover and click profile 2's suggestion - cy.get('[data-cy="mention-popover"]').should('be.visible').contains(profile2.username).click(); - - // Submit the post - cy.intercept('PUT', '**/pub/pubky.app/posts/**').as('postCreated'); - cy.get('[data-cy="post-input-action-bar-post"]').click(); - cy.wait('@postCreated').its('response.statusCode').should('eq', 201); - cy.get('textarea').should('have.value', ''); - }); + // * profile 1 creates a post mentioning profile 2 via @username lookup + createQuickPostWithMention(profile2.username); // * profile 2 checks for notification for being mentioned cy.signOut(HasBackedUp.Yes); @@ -197,6 +197,30 @@ describe('notifications', () => { checkLatestNotification([profile1.username, 'mentioned you in post'], LatestNotificationReadState.Read); }); + // todo: disabling notifications still shows notification, see bug https://github.com/pubky/pubky-app/issues/1603 + it.skip('can disable being notified for profile being mentioned in a post', () => { + // * profile 3 signs in and disables mention notifications + cy.signOut(HasBackedUp.Yes); + cy.signInWithEncryptedFile(backupDownloadFilePath(profile3.username)); + cy.get('[data-cy="header-settings-btn"]').click(); + cy.location('pathname').should('eq', '/settings/account'); + cy.get('[data-cy="settings-menu-item-notifications"]').click(); + cy.location('pathname').should('eq', '/settings/notifications'); + cy.get('#notification-switch-mention').click(); + + // * profile 1 signs in and creates a post mentioning profile 3 via @username lookup + cy.signOut(HasBackedUp.Yes); + cy.signInWithEncryptedFile(backupDownloadFilePath(profile1.username)); + createQuickPostWithMention(profile3.username); + + // * profile 3 checks for absence of notification for being mentioned + cy.signOut(HasBackedUp.Yes); + cy.signInWithEncryptedFile(backupDownloadFilePath(profile3.username)); + verifyNotificationCounter(0); + goToProfilePageFromHeader(); + cy.get('[data-cy="notifications-list"]').should('contain.text', 'No notifications yet'); + }); + it('can be notified for your post being replied to', () => { // * profile 1 creates a post (1) const postContent = `I will be notified when this post is replied to! ${Date.now()}`; diff --git a/cypress/support/posts.ts b/cypress/support/posts.ts index df8f80654..cb7f0f16e 100644 --- a/cypress/support/posts.ts +++ b/cypress/support/posts.ts @@ -62,6 +62,20 @@ export const createQuickPost = (postContent: string, tags?: string[], expectedPo }); }; +export const createQuickPostWithMention = (mentionUsername: string) => { + cy.get('[data-cy="home-post-input"]') + .should('be.visible') + .within(() => { + cy.get('textarea').should('have.value', '').type('Hey '); + cy.get('textarea').type(`@${mentionUsername}`); + cy.get('[data-cy="mention-popover"]').should('be.visible').contains(mentionUsername).click(); + cy.intercept('PUT', '**/pub/pubky.app/posts/**').as('postCreated'); + cy.get('[data-cy="post-input-action-bar-post"]').click(); + cy.wait('@postCreated').its('response.statusCode').should('eq', 201); + cy.get('textarea').should('have.value', ''); + }); +}; + export const createPostFromDialog = (postContent: string, expectedPostLength?: number) => { // click button to display new post dialog cy.get('[data-cy="new-post-btn"]').click(); From b99604800171c98ccb6d69b2e924fa077000ac6b Mon Sep 17 00:00:00 2001 From: James Browning Date: Fri, 3 Apr 2026 16:58:01 +0100 Subject: [PATCH 3/3] tests: update snapshot --- .../molecules/MentionPopover/MentionPopover.test.tsx.snap | 2 ++ 1 file changed, 2 insertions(+) diff --git a/src/components/molecules/MentionPopover/MentionPopover.test.tsx.snap b/src/components/molecules/MentionPopover/MentionPopover.test.tsx.snap index 6dad9985c..6607b0f33 100644 --- a/src/components/molecules/MentionPopover/MentionPopover.test.tsx.snap +++ b/src/components/molecules/MentionPopover/MentionPopover.test.tsx.snap @@ -6,6 +6,7 @@ exports[`MentionPopover > MentionPopover - Snapshots > matches snapshot with sel
@@ -52,6 +53,7 @@ exports[`MentionPopover > MentionPopover - Snapshots > matches snapshot with use