Repository navigation
Fix Link Navigation relative to current Environment - #24483
Conversation
| CAPTURE_METRICS: lodashGet(Config, 'CAPTURE_METRICS', 'false') === 'true', | ||
| ONYX_METRICS: lodashGet(Config, 'ONYX_METRICS', 'false') === 'true', | ||
| DEV_PORT: process.env.PORT || 8080, | ||
| DEV_PORT: process.env.PORT || 8082, |
There was a problem hiding this comment.
Updated since we now run dev on 8082 so fallback port should be 8082.
| // would be most commonly assumed to be on a mobile phone vs. a tablet or desktop style view. This behavior can be | ||
| // overridden by explicitly setting the dimensions inside a test via Dimensions.set() | ||
| let dimensions = CONST.TESTING.SCREEN_SIZE.SMALL; | ||
| let dimensions = { |
There was a problem hiding this comment.
I had to make these changes because this mock file was importing CONST file which was in turn importing src/libs/Url.js file in which we have imported the polyfill. Since the polyfill import internally imports RN packages and since we are in test environment the packages were being used before mocking them (which is done later in this file) and the test suite broke.To fix this we have multiple options:
-
We can import the polyfill in the root
App.jsfile as mentioned in the usage guidelines (https://github.com/charpeni/react-native-url-polyfill) but it will then overrideURLandURLSearchParamsclasses in the entire project.I actually committed that change in the previous commit and everything was working fine including the test cases.Also these 2 classes are not used much so the chance of breaking something is low and since the overrides basically extends the default RN classes so I think we are fine using this option too. -
Remove the import from the test suite before the mocking happens.In this option I had 2 further options:
- Remove the Url.js import from CONST.js as it was imported to use the addTrailingForwardSlash just at one place in the file.Also importing lib files in CONST file does not make sense.
- The other option was to remove the CONST file import in this file and that's what I have done now.
Let me know what you think is the best way forward.
There was a problem hiding this comment.
remove the CONST file import in this file
Current solution you did works for me.
@francoisl what do you think?
| expect(Url.hasSameExpensifyOrigin('https://www.new.expensify.com/inbox/124', 'https://www.new.expensify.com/action/123')).toBe(true); | ||
| }); | ||
| it('It should work correctly without https://', () => { | ||
| expect(Url.hasSameExpensifyOrigin('new.expensify.com/action/1234', 'new.expensify.com/action/123')).toBe(true); |
There was a problem hiding this comment.
Why this case was removed? It should still work without https://
There was a problem hiding this comment.
URL href attributes always need to have a protocol in them otherwise it is an invalid URL.If you type google.com in any chat on STG and then hover over it to view the href it will show https://google.com, so our logic already creates the correct href
Any url without the protocol and // is treated as a relative URL and is not spec complaint.You can go to any browser and type new URL('google.com') in the console section and it will throw an error.
Therefore, the previous test case was invalid.
| const Url = require('../../src/libs/Url'); | ||
|
|
||
| describe('Url', () => { | ||
| describe('getURLObject()', () => { |
There was a problem hiding this comment.
All these example urls should still be unit tested in getPathFromURL.
There was a problem hiding this comment.
Added tests for getPathFromURL
| // would be most commonly assumed to be on a mobile phone vs. a tablet or desktop style view. This behavior can be | ||
| // overridden by explicitly setting the dimensions inside a test via Dimensions.set() | ||
| let dimensions = CONST.TESTING.SCREEN_SIZE.SMALL; | ||
| let dimensions = { |
There was a problem hiding this comment.
remove the CONST file import in this file
Current solution you did works for me.
@francoisl what do you think?
|
@situchan @francoisl Any updates on PR review? |
|
@Talha345 please pull main. Unit Tests are now fixed in main |
Done! |
|
@situchan Bump for review! |
|
I am not able to get dev/staging |
@situchan How can i install multiple versions? You can simply set the environment by setting the ENV variable |
Reviewer Checklist
Screenshots/VideosWebweb-staging.movMobile Web - Chromemchrome-dev.movMobile Web - Safarimsafari-dev.movDesktopdesktop.movdesktop2.moviOSios-dev.movios-prod.movAndroidandroid-dev.mov |
situchan
left a comment
There was a problem hiding this comment.
LGTM ![]()
@francoisl all yours
|
✋ This PR was not deployed to staging yet because QA is ongoing. It will be automatically deployed to staging after the next production release. |
|
Hi @situchan @francoisl @Talha345 App/src/components/HTMLEngineProvider/HTMLRenderers/AnchorRenderer.js Lines 54 to 57 in a6fa52d But the URL params is required to attachment URL. Steps to reproduce
You will see the copied URL: is open wrong link without params I think we need to exclude the attachment URLs from this condition or add new condition previous this condition to open the attachment URLs with full URL issue is reported in slack here by @ayazhussain79 |
Hi @ahmedGaber93, I see what you mean. We updated how the This can be resolved easily by updating @situchan @francoisl Where should I update this change? Create a new PR or what? |
|
Yes, can you make a new PR please? |
|
bump @Talha345 |
|
🚀 Deployed to staging by https://github.com/francoisl in version: 1.3.56-0 🚀
|
|
🚀 Deployed to production by https://github.com/roryabraham in version: 1.3.56-24 🚀
|
Details
Fixed Issues
$ #22523
PROPOSAL: #22523 (comment)
Tests
Test Case 1:
Test Case 2:
In Dev: All 3 links should be external.
In STG: 2nd link should be internal
in PROD: Last link should be internal
This test case ensures that if an extra www subdomain is added to any URL, it is discarded and the correct behaviour prevails.
Note: In Dev ENV, you can change the line https://github.com/Expensify/App/compare/main...Talha345:fix/22523?expand=1#diff-810e7a5e5e8692ea5ea69e3b593e7e6abb3992e2682a7aaf89c8615db6840d83R22 and set it to
const environmentURL = CONST.STAGING_NEW_EXPENSIFY_URL;orconst environmentURL = CONST.NEW_EXPENSIFY_URL;to test the behaviour in STG and PROD environments on localhost.Offline tests
Same as above
QA Steps
PR Author Checklist
### Fixed Issuessection aboveTestssectionOffline stepssectionQA stepssectiontoggleReportand notonIconClick)myBool && <MyComponent />.src/languages/*files and using the translation methodWaiting for Copylabel for a copy review on the original GH to get the correct copy.STYLE.md) were followedAvatar, I verified the components usingAvatarare working as expected)/** comment above it */thisproperly so there are no scoping issues (i.e. foronClick={this.submit}the methodthis.submitshould be bound tothisin the constructor)thisare necessary to be bound (i.e. avoidthis.submit = this.submit.bind(this);ifthis.submitis never passed to a component event handler likeonClick)StyleUtils.getBackgroundAndBorderStyle(themeColors.componentBG))Avataris modified, I verified thatAvataris working as expected in all cases)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
Web
web.mov
Mobile Web - Chrome
WhatsApp.Video.2023-08-12.at.2.57.19.PM.mp4
Mobile Web - Safari
safari.mov
Desktop
Since the desktop app runs on port 8083 so only localhost links with port 8083 will be treated as internal.
desktop.mov
iOS
Since the DEV_PORT returned in native apps is 8082, only localhost links with port 8082 will be treated as internal on IOS and Android.
ios.mov
Android
android.mov