From 5f9f90c3e27bfcd32ba2183b76fd7ed6d61c98b6 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Pablo=20V=C3=A9lez?= Date: Fri, 14 Mar 2025 09:57:31 +0100 Subject: [PATCH] MM-T360 - search hashtags from mentions (#30406) Co-authored-by: Mattermost Build --- .../messaging/at_mentions_user_spec.js | 37 +++++++++++++++++++ 1 file changed, 37 insertions(+) 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}); + }); +}