-
Notifications
You must be signed in to change notification settings - Fork 136
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
make usermention case insensitive #584
Conversation
CLA Assistant Lite bot All contributors have signed the CLA ✍️ ✅ |
@nikhildewoolkar Could you please sign the CLA? |
@nikhildewoolkar Bump on this |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Please add automated tests for this case so that people don't change it in the future and accidentally cause a regression.
The current code change looks good though 👍 |
I have read the CLA Document and I hereby sign the CLA |
recheck |
Thanks @nikhildewoolkar! Could you now take care of this comment from @neil-marcellini ? |
updated pr with testcases |
@neil-marcellini Could you please review this one again? |
Yes I will review it today |
2174a6f
updated the pr with suggested changes.kindly review |
lib/ExpensiMark.js
Outdated
replacement: (match) => { | ||
if (!Str.isValidMention(match)) { | ||
return match; | ||
} | ||
return `<mention-user>${match}</mention-user>`; | ||
return `<mention-user>${match.toLowerCase()}</mention-user>`; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@nikhildewoolkar Won't this convert the input to lowercase? As discussed in the issue, we don't want to convert the input to lower case. We want to leave it as it is.
Context: Expensify/App#26016 (comment)
Expensify/App#26016 (comment)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Ok yes good catch, thank you. I agree that we don't want to make it lowercase here.
That also makes me think that we should have tests for converting a mention in html back to markdown, with uppercase, lowercase, mixed, etc.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Sobit pointed out that we don't want to change the case and I agree. Please update that.
lib/ExpensiMark.js
Outdated
replacement: (match) => { | ||
if (!Str.isValidMention(match)) { | ||
return match; | ||
} | ||
return `<mention-user>${match}</mention-user>`; | ||
return `<mention-user>${match.toLowerCase()}</mention-user>`; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Ok yes good catch, thank you. I agree that we don't want to make it lowercase here.
That also makes me think that we should have tests for converting a mention in html back to markdown, with uppercase, lowercase, mixed, etc.
updated PR. please review. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM!
@sobitneupane @neil-marcellini btw, what is the process to update the version in App?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looking good, but let's also add complete tests please, as I mentioned last time.
we should have tests for converting a mention in html back to markdown, with uppercase, lowercase, mixed, etc.
PR Updated |
__tests__/ExpensiMark-HTML-test.js
Outdated
|
||
testString = '@user@domain.com'; | ||
expect(parser.replace('<mention-user>@user@domain.com</mention-user>')).toBe(testString); | ||
|
||
testString = '@USER@DOMAIN.COM'; | ||
expect(parser.replace('<mention-user>@USER@DOMAIN.COM</mention-user>')).toBe(testString); | ||
|
||
testString = '@USER@domain.com'; | ||
expect(parser.replace('<mention-user>@USER@domain.com</mention-user>')).toBe(testString); | ||
|
||
testString = '@user@DOMAIN.com'; | ||
expect(parser.replace('<mention-user>@user@DOMAIN.com</mention-user>')).toBe(testString); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looks good, but I think we should add these tests to __tests__/ExpensiMark-HTMLToText-test.js
and __tests__/ExpensiMark-Markdown-test.js
.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Sorry that this is dragging on for a while. Please DM me when you make the updates and we can have faster iterations and get this merged today.
By mistake, I closed this PR. So made new PR with the changes suggested in earlier chats #591. Kindly Review. |
Fixed Issues
Expensify/App#26016
Tests
Open the app
Open any report
Write '@' to trigger mentions
Select any one mention, make any letter of mention as capital and send
Hover on mention to observe that tooltip doesn't display the right display name and avatar
For same mention as step 4 or select different mention and capitalize all letters and send
Observe that now it is not displayed as mention