diff --git a/app/client/cypress/integration/Smoke_TestSuite/ClientSideTests/Comments/AddComments_spec.js b/app/client/cypress/integration/Smoke_TestSuite/ClientSideTests/Comments/AddComments_spec.js index 16390d2e44..eef6ad32f0 100644 --- a/app/client/cypress/integration/Smoke_TestSuite/ClientSideTests/Comments/AddComments_spec.js +++ b/app/client/cypress/integration/Smoke_TestSuite/ClientSideTests/Comments/AddComments_spec.js @@ -121,6 +121,19 @@ describe("Comments", function() { }); }); + it("Can invite new collaborators, with substring emails", () => { + cy.get(commentsLocators.cancelCommentButton).click({ force: true }); + cy.get(homePage.shareApp).click({ force: true }); + cy.shareApp("cypresstest@appsmith.com", homePage.viewerRole); + cy.get(commonLocators.canvas).click(30, 30); + cy.wait(300); + cy.get(commentsLocators.mentionsInput).type("@test@appsmith.com", { + delay: 100, + }); + cy.wait(1000); + cy.contains("Invite a new user").should("exist"); + }); + it("unread indicator is visible for another app user when a new comment is added", () => { // share app with TESTUSERNAME2 cy.get(homePage.shareApp).click({ force: true }); diff --git a/app/client/cypress/locators/commentsLocators.json b/app/client/cypress/locators/commentsLocators.json index de72ea0d8b..13114ea2aa 100644 --- a/app/client/cypress/locators/commentsLocators.json +++ b/app/client/cypress/locators/commentsLocators.json @@ -2,6 +2,7 @@ "switchToCommentModeBtn": ".t--switch-comment-mode-on", "mentionsInput": "[data-testid='mentions-input']", "postButtonAddComment": "[data-cy='add-comment-submit']", + "cancelCommentButton": "[data-cy='add-comment-cancel']", "inlineCommentThreadPin": ".t--inline-comment-pin-trigger-", "toggleCommentModeOnUnread": ".t--toggle-comment-mode-on--unread", "toggleCommentModeOn": ".t--toggle-comment-mode-on" diff --git a/app/client/src/comments/inlineComments/AddCommentInput.tsx b/app/client/src/comments/inlineComments/AddCommentInput.tsx index f84e36b716..51a862ce26 100644 --- a/app/client/src/comments/inlineComments/AddCommentInput.tsx +++ b/app/client/src/comments/inlineComments/AddCommentInput.tsx @@ -267,6 +267,7 @@ function AddCommentInput({ const filteredSuggestions = useMemo(() => { let suggestionResults = suggestions; + let hasExactMatch = false; if (!suggestionsQuery) return suggestionResults; else { const filter = suggestionsQuery.toLowerCase(); @@ -274,14 +275,18 @@ function AddCommentInput({ .filter((suggestion) => { const name = suggestion.name.toLowerCase(); const username = suggestion.user?.username.toLowerCase() || ""; + hasExactMatch = name === filter || username === filter; return name.indexOf(filter) !== -1 || username.indexOf(filter) !== -1; }) .sort(sortMentionData(filter)); } - - if (suggestionResults.length !== 0) return suggestionResults; - - return [{ name: suggestionsQuery, isInviteTrigger: true }]; + const couldBeNewEmail = isEmail(suggestionsQuery); + const inviteNew = [{ name: suggestionsQuery, isInviteTrigger: true }]; + // Show invite prompt only if there is no exact match and user has typed email. + return [ + ...suggestionResults, + ...(couldBeNewEmail && !hasExactMatch ? inviteNew : []), + ]; }, [suggestionsQuery, suggestions, trigger]); const onAddMention = (mention: MentionData) => { @@ -332,6 +337,7 @@ function AddCommentInput({