[No QA] add unit tests to isDomainPublic and getEmailDomain#74314
Conversation
|
@MonilBhavsar Please copy/paste the Reviewer Checklist from here into a new comment on this PR and complete it. If you have the K2 extension, you can simply click: [this button] |
Codecov Report✅ All modified and coverable lines are covered by tests. |
|
Flaky tests fail |
| }); | ||
|
|
||
| it('Should handle invalid email formats gracefully', () => { | ||
| expect(getEmailDomain('email')).toBe('email'); |
There was a problem hiding this comment.
I would expect empty string since there's no domain
There was a problem hiding this comment.
It wraps the extractEmailDomain from expensify-common repository:
extractEmailDomain(email) {
return this.cutBefore(email, '@');
},
So I think it should be fine? Or should we write our own implementation for getEmailDomain?
There was a problem hiding this comment.
It wraps the extractEmailDomain from expensify-common repository:
Ah I see
So I think it should be fine?
I am mostly concerned because it works differently from the implementation we have at server side and I doubt if it will create unnecessary bugs. The server side method would return empty string for this case
Or should we write our own implementation for getEmailDomain?
How do you propose to write it - To not use cutBefore()? I think the problem is cutBefore returns the entire string if substring/needle is not found
There was a problem hiding this comment.
extractEmailDomain is heavily used throughout the codebase, so changing its behavior would be a larger change affecting other parts of the app. For this specific use case, we could add validation to match server behavior
function getEmailDomain(email: string): string {
if (!email.includes('@')) {
return '';
}
return Str.extractEmailDomain(email).toLowerCase();
}
On the other hand, getEmailDomain is only used in one really small piece of the app, matching the underlying extractEmailDomain function that's used everywhere else. Maybe it's a better idea to keep consistency within our own codebase for now?
There was a problem hiding this comment.
In all usages of extractEmailDomain(), we do pass email login, so it is working as expected
Maybe it's a better idea to keep consistency within our own codebase for now?
Yeah, I think it's fine for now.
If we see an off behavior, we could try updating extractEmailDomain() method since. I'm going to give it a try.
Reviewer Checklist
Screenshots/VideosAndroid: HybridAppAndroid: mWeb ChromeiOS: HybridAppiOS: mWeb SafariMacOS: Chrome / SafariMacOS: Desktop |
|
🚀 Deployed to staging by https://github.com/MonilBhavsar in version: 9.2.55-3 🚀
|
|
🚀 Deployed to staging by https://github.com/MonilBhavsar in version: 9.2.57-0 🚀
|
|
🚀 Deployed to production by https://github.com/cristipaval in version: 9.2.57-4 🚀
|
Explanation of Change
Follow up PR to #74069
Fixed Issues
$ #74088
PROPOSAL:
Tests
Tests should pass
Offline tests
QA Steps
// TODO: These must be filled out, or the issue title must include "[No QA]."
PR Author Checklist
### Fixed Issuessection aboveTestssectionOffline stepssectionQA stepssectioncanBeMissingparam foruseOnyxtoggleReportand notonIconClick)src/languages/*files and using the translation methodSTYLE.md) were followedAvatar, I verified the components usingAvatarare working as expected)StyleUtils.getBackgroundAndBorderStyle(theme.componentBG))npm run compress-svg)Avataris modified, I verified thatAvataris working as expected in all cases)Designlabel and/or tagged@Expensify/designso the design team can review the changes.ScrollViewcomponent to make it scrollable when more elements are added to the page.mainbranch was merged into this PR after a review, I tested again and verified the outcome was still expected according to theTeststeps.Screenshots/Videos
Android: Native
Android: mWeb Chrome
iOS: Native
iOS: mWeb Safari
MacOS: Chrome / Safari
MacOS: Desktop