diff --git a/e2e-tests/cypress/tests/integration/channels/messaging/at_mentions_user_spec.js b/e2e-tests/cypress/tests/integration/channels/messaging/at_mentions_user_spec.js index 620ed2e8d4..55cff98a9a 100644 --- a/e2e-tests/cypress/tests/integration/channels/messaging/at_mentions_user_spec.js +++ b/e2e-tests/cypress/tests/integration/channels/messaging/at_mentions_user_spec.js @@ -36,4 +36,41 @@ describe('Mention self', () => { }); }); }); + + it('should be able to click on tryAI hashtag in a message with self-mention', () => { + // Create a message that includes both a self-mention and the #tryAI hashtag + const message = `Hey @${testUser.username} check out #tryAI`; + + // Post the message + cy.postMessage(message); + + // # Open RHS in recent mentions mode + cy.findByRole('button', {name: /Recent mentions/i}).click(); + + // # Get last postId + cy.getLastPostId().as('lastPostId'); + + // * Search result should return the message with the self-mention and the #tryAI hashtag + cy.get('@lastPostId').then((postId) => { + verifySearchResult(postId, message); + }); + + // # Verify RHS is open and contains the search results + cy.get('.sidebar--right__title').should('contain.text', 'Search Results'); + + cy.get('@lastPostId').then((postId) => { + verifySearchResult(postId, message); + }); + }); }); + +// Helper function to verify search result and click on #tryAI hashtag +function verifySearchResult(postId, fullMessage) { + // Find the specific search item container that contains our post ID + cy.get(`[data-testid="search-item-container"] #rhsPostMessageText_${postId}`).closest('[data-testid="search-item-container"]').within(() => { + cy.get(`#rhsPostMessageText_${postId}`).should('have.text', `${fullMessage}`); + + // This will find the exact element containing just "#tryAI" + cy.contains('a', '#tryAI').click({force: true}); + }); +}