-
Notifications
You must be signed in to change notification settings - Fork 5k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
fix: fix sticky autodetection banner (#29061)
<!-- 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** fix sticky autodetection banner <!-- 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/29061?quickstart=1) ## **Related issues** Fixes: #29059 ## **Manual testing steps** 1. Go to autodetected banner 2. click on ignore all 3. you should have allNetworks selected ## **Screenshots/Recordings** <!-- If applicable, add screenshots and/or recordings to visualize the before and after of your change. --> ### **Before** <!-- [screenshots/recordings] --> ### **After** https://drive.google.com/file/d/11zcmgV1Bdq5wx9MkDlhxr8oDBr9DGB3d/view?usp=sharing <!-- [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/main/.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/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. --------- Co-authored-by: Brian Bergeron <[email protected]>
- Loading branch information
Showing
4 changed files
with
198 additions
and
5 deletions.
There are no files selected for viewing
153 changes: 153 additions & 0 deletions
153
...detected-token-ignored-popover/__snapshots__/detected-token-ignored-popover.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,153 @@ | ||
// Jest Snapshot v1, https://goo.gl/fbAQLP | ||
|
||
exports[`DetectedTokenIgnoredPopover should match snapshot for ignore mode 1`] = ` | ||
<body> | ||
<div | ||
id="popover-content" | ||
/> | ||
<div /> | ||
<div | ||
class="mm-modal detected-token-ignored-popover detected-token-ignored-popover--ignore" | ||
> | ||
<div | ||
aria-hidden="true" | ||
class="mm-box mm-modal-overlay mm-box--width-full mm-box--height-full mm-box--background-color-overlay-default" | ||
/> | ||
<div | ||
data-focus-guard="true" | ||
style="width: 1px; height: 0px; padding: 0px; overflow: hidden; position: fixed; top: 1px; left: 1px;" | ||
tabindex="0" | ||
/> | ||
<div | ||
data-focus-lock-disabled="false" | ||
> | ||
<div | ||
class="mm-box mm-modal-content mm-box--padding-top-4 mm-box--sm:padding-top-8 mm-box--md:padding-top-12 mm-box--padding-right-4 mm-box--padding-bottom-4 mm-box--sm:padding-bottom-8 mm-box--md:padding-bottom-12 mm-box--padding-left-4 mm-box--display-flex mm-box--justify-content-center mm-box--align-items-flex-start mm-box--width-screen mm-box--height-screen" | ||
> | ||
<section | ||
aria-modal="true" | ||
class="mm-box mm-modal-content__dialog mm-modal-content__dialog--size-sm mm-box--padding-4 mm-box--width-full mm-box--background-color-background-default mm-box--rounded-lg" | ||
role="dialog" | ||
style="overflow-y: auto;" | ||
> | ||
<div | ||
class="mm-box mm-header-base mm-modal-header mm-box--margin-bottom-4 mm-box--display-flex mm-box--justify-content-space-between" | ||
> | ||
<div | ||
class="mm-box" | ||
> | ||
<header | ||
class="mm-box mm-text mm-text--heading-sm mm-text--text-align-center mm-box--color-text-default" | ||
> | ||
[areYouSure] | ||
</header> | ||
</div> | ||
</div> | ||
<p | ||
class="mm-box mm-text mm-text--body-md mm-box--margin-bottom-4 mm-box--color-text-default" | ||
> | ||
[ignoreTokenWarning] | ||
</p> | ||
<div | ||
class="mm-box mm-box--display-flex mm-box--gap-4 mm-box--justify-content-center" | ||
> | ||
<button | ||
class="mm-box mm-text mm-button-base mm-button-base--size-lg mm-button-base--block detected-token-ignored-popover__ignore-button mm-button-secondary mm-text--body-md-medium mm-box--padding-0 mm-box--padding-right-4 mm-box--padding-left-4 mm-box--display-inline-flex mm-box--justify-content-center mm-box--align-items-center mm-box--color-primary-default mm-box--background-color-transparent mm-box--rounded-pill mm-box--border-color-primary-default box--border-style-solid box--border-width-1" | ||
> | ||
[cancel] | ||
</button> | ||
<button | ||
class="mm-box mm-text mm-button-base mm-button-base--size-lg mm-button-base--block detected-token-ignored-popover__import-button mm-button-primary mm-text--body-md-medium mm-box--padding-0 mm-box--padding-right-4 mm-box--padding-left-4 mm-box--display-inline-flex mm-box--justify-content-center mm-box--align-items-center mm-box--color-primary-inverse mm-box--background-color-primary-default mm-box--rounded-pill" | ||
data-testid="detected-token-ignored-popover-confirm-button" | ||
data-theme="light" | ||
> | ||
[confirm] | ||
</button> | ||
</div> | ||
</section> | ||
</div> | ||
</div> | ||
<div | ||
data-focus-guard="true" | ||
style="width: 1px; height: 0px; padding: 0px; overflow: hidden; position: fixed; top: 1px; left: 1px;" | ||
tabindex="0" | ||
/> | ||
</div> | ||
</body> | ||
`; | ||
|
||
exports[`DetectedTokenIgnoredPopover should match snapshot for import mode 1`] = ` | ||
<body> | ||
<div | ||
id="popover-content" | ||
/> | ||
<div /> | ||
<div | ||
class="mm-modal detected-token-ignored-popover detected-token-ignored-popover--import" | ||
> | ||
<div | ||
aria-hidden="true" | ||
class="mm-box mm-modal-overlay mm-box--width-full mm-box--height-full mm-box--background-color-overlay-default" | ||
/> | ||
<div | ||
data-focus-guard="true" | ||
style="width: 1px; height: 0px; padding: 0px; overflow: hidden; position: fixed; top: 1px; left: 1px;" | ||
tabindex="0" | ||
/> | ||
<div | ||
data-focus-lock-disabled="false" | ||
> | ||
<div | ||
class="mm-box mm-modal-content mm-box--padding-top-4 mm-box--sm:padding-top-8 mm-box--md:padding-top-12 mm-box--padding-right-4 mm-box--padding-bottom-4 mm-box--sm:padding-bottom-8 mm-box--md:padding-bottom-12 mm-box--padding-left-4 mm-box--display-flex mm-box--justify-content-center mm-box--align-items-flex-start mm-box--width-screen mm-box--height-screen" | ||
> | ||
<section | ||
aria-modal="true" | ||
class="mm-box mm-modal-content__dialog mm-modal-content__dialog--size-sm mm-box--padding-4 mm-box--width-full mm-box--background-color-background-default mm-box--rounded-lg" | ||
role="dialog" | ||
style="overflow-y: auto;" | ||
> | ||
<div | ||
class="mm-box mm-header-base mm-modal-header mm-box--margin-bottom-4 mm-box--display-flex mm-box--justify-content-space-between" | ||
> | ||
<div | ||
class="mm-box" | ||
> | ||
<header | ||
class="mm-box mm-text mm-text--heading-sm mm-text--text-align-center mm-box--color-text-default" | ||
> | ||
[importSelectedTokens] | ||
</header> | ||
</div> | ||
</div> | ||
<p | ||
class="mm-box mm-text mm-text--body-md mm-box--margin-bottom-4 mm-box--color-text-default" | ||
> | ||
[importSelectedTokensDescription] | ||
</p> | ||
<div | ||
class="mm-box mm-box--display-flex mm-box--gap-4 mm-box--justify-content-center" | ||
> | ||
<button | ||
class="mm-box mm-text mm-button-base mm-button-base--size-lg mm-button-base--block detected-token-ignored-popover__ignore-button mm-button-secondary mm-text--body-md-medium mm-box--padding-0 mm-box--padding-right-4 mm-box--padding-left-4 mm-box--display-inline-flex mm-box--justify-content-center mm-box--align-items-center mm-box--color-primary-default mm-box--background-color-transparent mm-box--rounded-pill mm-box--border-color-primary-default box--border-style-solid box--border-width-1" | ||
> | ||
[cancel] | ||
</button> | ||
<button | ||
class="mm-box mm-text mm-button-base mm-button-base--size-lg mm-button-base--block detected-token-ignored-popover__import-button mm-button-primary mm-text--body-md-medium mm-box--padding-0 mm-box--padding-right-4 mm-box--padding-left-4 mm-box--display-inline-flex mm-box--justify-content-center mm-box--align-items-center mm-box--color-primary-inverse mm-box--background-color-primary-default mm-box--rounded-pill" | ||
data-testid="detected-token-ignored-popover-confirm-button" | ||
data-theme="light" | ||
> | ||
[confirm] | ||
</button> | ||
</div> | ||
</section> | ||
</div> | ||
</div> | ||
<div | ||
data-focus-guard="true" | ||
style="width: 1px; height: 0px; padding: 0px; overflow: hidden; position: fixed; top: 1px; left: 1px;" | ||
tabindex="0" | ||
/> | ||
</div> | ||
</body> | ||
`; |
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
37 changes: 37 additions & 0 deletions
37
...app/detected-token/detected-token-ignored-popover/detected-token-ignored-popover.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 |
---|---|---|
@@ -0,0 +1,37 @@ | ||
import React from 'react'; | ||
import { render, screen, fireEvent } from '@testing-library/react'; | ||
import DetectedTokenIgnoredPopover from './detected-token-ignored-popover'; | ||
|
||
describe('DetectedTokenIgnoredPopover', () => { | ||
const defaultProps = { | ||
partiallyIgnoreDetectedTokens: false, | ||
onCancelIgnore: jest.fn(), | ||
handleClearTokensSelection: jest.fn(), | ||
isOpen: true, | ||
}; | ||
|
||
const renderComponent = (props = {}) => | ||
render(<DetectedTokenIgnoredPopover {...defaultProps} {...props} />); | ||
|
||
it('should match snapshot for ignore mode', () => { | ||
const { baseElement } = renderComponent(); | ||
expect(baseElement).toMatchSnapshot(); | ||
}); | ||
|
||
it('should match snapshot for import mode', () => { | ||
const { baseElement } = renderComponent({ | ||
partiallyIgnoreDetectedTokens: true, | ||
}); | ||
expect(baseElement).toMatchSnapshot(); | ||
}); | ||
|
||
it('should call handleClearTokensSelection when the confirm button is clicked', () => { | ||
renderComponent(); | ||
const confirmButton = screen.getByTestId( | ||
'detected-token-ignored-popover-confirm-button', | ||
); | ||
fireEvent.click(confirmButton); | ||
expect(defaultProps.handleClearTokensSelection).toHaveBeenCalled(); | ||
expect(defaultProps.handleClearTokensSelection).not.toThrow(); | ||
}); | ||
}); |
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