-
-
Notifications
You must be signed in to change notification settings - Fork 1.1k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
fix: Use domain for origin pill component (#11730)
<!-- Please submit this PR as a draft initially. Do not mark it as "Ready for review" until the template has been completely filled out, and PR status checks have passed at least once. --> ## **Description** This PR fixes an issue where the full URL is displayed in the origin pill for transaction requests triggered from a dapp within the in-app browser, rather than just the domain. The expected behavior is to display only the domain, similar to how signature requests are handled. This update ensures consistency across both transaction and signature requests. <!-- Write a short description of the changes included in this pull request, also include relevant motivation and context. Have in mind the following questions: 1. What is the reason for the change? 2. What is the improvement/solution? --> ## **Related issues** Fixes: #11690 ## **Manual testing steps** 1. Open a dapp within the in app browser 2. Trigger a transaction request 3. See the origin pill ## **Screenshots/Recordings** [origin.webm](https://github.com/user-attachments/assets/31736e36-9054-496e-992e-5ab55688361c) <!-- If applicable, add screenshots and/or recordings to visualize the before and after of your change. --> ### **Before** <!-- [screenshots/recordings] --> ### **After** <!-- [screenshots/recordings] --> ## **Pre-merge author checklist** - [x] I’ve followed [MetaMask Contributor Docs](https://github.com/MetaMask/contributor-docs) and [MetaMask Mobile Coding Standards](https://github.com/MetaMask/metamask-mobile/blob/main/.github/guidelines/CODING_GUIDELINES.md). - [x] I've completed the PR template to the best of my ability - [x] I’ve included tests if applicable - [x] I’ve documented my code using [JSDoc](https://jsdoc.app/) format if applicable - [x] I’ve applied the right labels on the PR (see [labeling guidelines](https://github.com/MetaMask/metamask-mobile/blob/main/.github/guidelines/LABELING_GUIDELINES.md)). Not required for external contributors. ## **Pre-merge reviewer checklist** - [ ] I've manually tested the PR (e.g. pull and build branch, run the app, test code being changed). - [ ] I confirm that this PR addresses all acceptance criteria described in the ticket it closes and includes the necessary testing evidence such as recordings and or screenshots.
- Loading branch information
1 parent
092d567
commit 3774729
Showing
5 changed files
with
111 additions
and
11 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,34 @@ | ||
import React from 'react'; | ||
import renderWithProvider from '../../../util/test/renderWithProvider'; | ||
import ApprovalTagUrl from './ApprovalTagUrl'; | ||
import { backgroundState } from '../../../util/test/initial-root-state'; | ||
|
||
const ADDRESS_MOCK = '0x1234567890abcdef1234567890abcdef12345678'; | ||
const DOMAIN_MOCK = 'metamask.github.io'; | ||
const mockInitialState = { | ||
settings: {}, | ||
engine: { | ||
backgroundState: { | ||
...backgroundState, | ||
PreferencesController: { | ||
selectedAddress: ADDRESS_MOCK, | ||
}, | ||
}, | ||
}, | ||
}; | ||
|
||
describe('ApprovalTagUrl', () => { | ||
it('renders correctly', () => { | ||
const { toJSON } = renderWithProvider( | ||
<ApprovalTagUrl | ||
from={ADDRESS_MOCK} | ||
origin={DOMAIN_MOCK} | ||
url={`https://${DOMAIN_MOCK}/test-dapp/mock-url-query`} | ||
sdkDappMetadata={{ url: '', icon: '' }} | ||
/>, | ||
{ state: mockInitialState }, | ||
); | ||
|
||
expect(toJSON()).toMatchSnapshot(); | ||
}); | ||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
69 changes: 69 additions & 0 deletions
69
app/components/UI/ApprovalTagUrl/__snapshots__/ApprovalTagUrl.test.tsx.snap
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,69 @@ | ||
// Jest Snapshot v1, https://goo.gl/fbAQLP | ||
|
||
exports[`ApprovalTagUrl renders correctly 1`] = ` | ||
<View | ||
style={ | ||
{ | ||
"alignItems": "center", | ||
"alignSelf": "center", | ||
"backgroundColor": "#ffffff", | ||
"borderColor": "#bbc0c5", | ||
"borderRadius": 99, | ||
"borderWidth": 1, | ||
"flexDirection": "row", | ||
"marginBottom": 16, | ||
"paddingLeft": 8, | ||
"paddingRight": 16, | ||
"paddingVertical": 8, | ||
} | ||
} | ||
testID="APPROVAL_TAG_URL_ORIGIN_PILL" | ||
> | ||
<View | ||
style={ | ||
{ | ||
"backgroundColor": "#ffffff", | ||
"borderRadius": 16, | ||
"height": 24, | ||
"marginRight": 8, | ||
"overflow": "hidden", | ||
"width": 24, | ||
} | ||
} | ||
> | ||
<Image | ||
onError={[Function]} | ||
resizeMode="contain" | ||
source={ | ||
{ | ||
"uri": "", | ||
} | ||
} | ||
style={ | ||
{ | ||
"flex": 1, | ||
"height": undefined, | ||
"width": undefined, | ||
} | ||
} | ||
testID="favicon-avatar-image" | ||
/> | ||
</View> | ||
<Text | ||
accessibilityRole="text" | ||
style={ | ||
{ | ||
"color": "#6a737d", | ||
"flexShrink": 1, | ||
"fontFamily": "EuclidCircularB-Regular", | ||
"fontSize": 14, | ||
"fontWeight": "400", | ||
"letterSpacing": 0, | ||
"lineHeight": 22, | ||
} | ||
} | ||
> | ||
https://metamask.github.io | ||
</Text> | ||
</View> | ||
`; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters