-
Notifications
You must be signed in to change notification settings - Fork 4.9k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
fix: PermitSingle, PermitBatch, PermitTransferFrom, PermitBatchTransf…
…erFrom simulation "Spending cap" (#26684) <!-- 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. --> Fixes PermitSingle, PermitBatch, PermitTransferFrom, PermitBatchTransferFrom simulation to use their respective provided token and amount in token details. Additionally: - adjusts styles to have an 8px gap between each "Spending Cap" entry and right align content - create PermitSimulationValueDisplay component to separate individual token contract value logic - adds tests - adds sentry error to capture exception in case token isn't provided for the relevant primaryTypes dev note: majority of the newlines come from updated and new test snapshots [![Open in GitHub Codespaces](https://github.com/codespaces/badge.svg)](https://codespaces.new/MetaMask/metamask-extension/pull/26684?quickstart=1) Fixes: #26591 (PermitSingle) Fixes: #26592 (PermitBatch) Test PermitSingle & PermitBatch with Improved Signature setting enabled See related issues for repro steps <!-- If applicable, add screenshots and/or recordings to visualize the before and after of your change. --> <img width="320" src="https://github.com/user-attachments/assets/aac7fa8c-285a-4d2b-bcec-84c7fc6245bf"> <!-- [screenshots/recordings] --> See Issue screenshots <!-- [screenshots/recordings] --> ![image](https://github.com/user-attachments/assets/4564530d-1c3d-430b-b821-15ed0fca6152) - [ ] I've followed [MetaMask Contributor Docs](https://github.com/MetaMask/contributor-docs) and [MetaMask Extension Coding Standards](https://github.com/MetaMask/metamask-extension/blob/develop/.github/guidelines/CODING_GUIDELINES.md). - [ ] I've completed the PR template to the best of my ability - [ ] I’ve included tests if applicable - [ ] I’ve documented my code using [JSDoc](https://jsdoc.app/) format if applicable - [ ] I’ve applied the right labels on the PR (see [labeling guidelines](https://github.com/MetaMask/metamask-extension/blob/develop/.github/guidelines/LABELING_GUIDELINES.md)). Not required for external contributors. - [ ] 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
Showing
11 changed files
with
2,284 additions
and
420 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
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
29 changes: 23 additions & 6 deletions
29
...irmations/components/confirm/info/typed-sign/permit-simulation/permit-simulation.test.tsx
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 |
---|---|---|
@@ -1,24 +1,41 @@ | ||
import React from 'react'; | ||
import configureMockStore from 'redux-mock-store'; | ||
|
||
import { act } from 'react-dom/test-utils'; | ||
import mockState from '../../../../../../../../test/data/mock-state.json'; | ||
// import { getMockTypedSignConfirmStateForRequest } from '../../../../../../../../test/data/confirmations/helper'; | ||
import { renderWithProvider } from '../../../../../../../../test/lib/render-helpers'; | ||
// TODO: readd in 12.4.0 | ||
// import { renderWithConfirmContextProvider } from '../../../../../../../../test/lib/confirmations/render-helpers'; | ||
import { permitSignatureMsg } from '../../../../../../../../test/data/confirmations/typed_sign'; | ||
import PermitSimulation from './permit-simulation'; | ||
|
||
jest.mock('../../../../../../../store/actions', () => { | ||
return { | ||
getTokenStandardAndDetails: jest.fn().mockResolvedValue({ decimals: 2 }), | ||
}; | ||
}); | ||
|
||
describe('PermitSimulation', () => { | ||
it('renders component correctly', () => { | ||
it('renders component correctly', async () => { | ||
const state = { | ||
...mockState, | ||
confirm: { | ||
currentConfirmation: permitSignatureMsg, | ||
}, | ||
}; | ||
// TODO: readd in 12.4.0 | ||
// const state = getMockTypedSignConfirmStateForRequest(permitSignatureMsg); | ||
const mockStore = configureMockStore([])(state); | ||
const { container } = renderWithProvider( | ||
<PermitSimulation tokenDecimals={2} />, | ||
mockStore, | ||
); | ||
expect(container).toMatchSnapshot(); | ||
|
||
await act(async () => { | ||
const { container, findByText } = renderWithProvider( | ||
<PermitSimulation />, | ||
mockStore, | ||
); | ||
|
||
expect(await findByText('30')).toBeInTheDocument(); | ||
expect(container).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
Oops, something went wrong.