-
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: [cherrypick][V12.3.0] PermitSingle, PermitBatch, PermitTransferF…
…rom, PermitBatchTransferFrom simulation "Spending cap" (#27300) <!-- 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** Cherry-picks #26684 into V12.3.0 resolved conflicts: - permit-simulation (does not have static simulation yet) - tests + snaps (12.3.0 does not have useConfirmContext yet) <!-- 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? --> [![Open in GitHub Codespaces](https://github.com/codespaces/badge.svg)](https://codespaces.new/MetaMask/metamask-extension/pull/27300?quickstart=1) ## **Related issues** Fixes: #26591 (PermitSingle) Fixes: #26592 (PermitBatch) ## **Manual testing steps** 1. Go to this page... 2. 3. ## **Screenshots/Recordings** <!-- 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** - [ ] 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. ## **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
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.