-
Notifications
You must be signed in to change notification settings - Fork 411
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
fix: Hide Security&Login from settings if not a social signer (#2734)
* fix: Hide Security&Login from settings if not a social signer * refactor: Remove Boolean expression * fix: Add tooltip to info text on welcome page * fix: Close popover when password recovery opens * fix: Failing tests
- Loading branch information
1 parent
842836f
commit c81b9fb
Showing
6 changed files
with
128 additions
and
30 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
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
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,78 @@ | ||
import SettingsHeader from '@/components/settings/SettingsHeader/index' | ||
import * as safeAddress from '@/hooks/useSafeAddress' | ||
import * as feature from '@/hooks/useChains' | ||
import * as wallet from '@/hooks/wallets/useWallet' | ||
import { ONBOARD_MPC_MODULE_LABEL } from '@/services/mpc/SocialLoginModule' | ||
import { connectedWalletBuilder } from '@/tests/builders/wallet' | ||
|
||
import { render } from '@/tests/test-utils' | ||
import { faker } from '@faker-js/faker' | ||
|
||
describe('SettingsHeader', () => { | ||
beforeEach(() => { | ||
jest.resetAllMocks() | ||
}) | ||
|
||
describe('A safe is open', () => { | ||
beforeEach(() => { | ||
jest.resetAllMocks() | ||
jest.spyOn(safeAddress, 'default').mockReturnValue(faker.finance.ethereumAddress()) | ||
}) | ||
|
||
it('displays safe specific preferences if on a safe', () => { | ||
const result = render(<SettingsHeader />) | ||
|
||
expect(result.getByText('Setup')).toBeInTheDocument() | ||
}) | ||
|
||
it('displays Notifications if feature is enabled', () => { | ||
jest.spyOn(feature, 'useHasFeature').mockReturnValue(true) | ||
|
||
const result = render(<SettingsHeader />) | ||
|
||
expect(result.getByText('Notifications')).toBeInTheDocument() | ||
}) | ||
|
||
it('displays Security & Login if connected wallet is a social signer', () => { | ||
const mockWallet = connectedWalletBuilder().with({ label: ONBOARD_MPC_MODULE_LABEL }).build() | ||
jest.spyOn(wallet, 'default').mockReturnValue(mockWallet) | ||
|
||
const result = render(<SettingsHeader />) | ||
|
||
expect(result.getByText('Security & Login')).toBeInTheDocument() | ||
}) | ||
}) | ||
|
||
describe('No safe is open', () => { | ||
beforeEach(() => { | ||
jest.resetAllMocks() | ||
jest.spyOn(safeAddress, 'default').mockReturnValue('') | ||
}) | ||
|
||
it('displays general preferences if no safe is open', () => { | ||
const result = render(<SettingsHeader />) | ||
|
||
expect(result.getByText('Cookies')).toBeInTheDocument() | ||
expect(result.getByText('Appearance')).toBeInTheDocument() | ||
expect(result.getByText('Data')).toBeInTheDocument() | ||
expect(result.getByText('Environment variables')).toBeInTheDocument() | ||
}) | ||
|
||
it('displays Notifications if feature is enabled', () => { | ||
jest.spyOn(feature, 'useHasFeature').mockReturnValue(true) | ||
|
||
const result = render(<SettingsHeader />) | ||
|
||
expect(result.getByText('Notifications')).toBeInTheDocument() | ||
}) | ||
|
||
it('displays Security & Login if connected wallet is a social signer', () => { | ||
const mockWallet = connectedWalletBuilder().with({ label: ONBOARD_MPC_MODULE_LABEL }).build() | ||
jest.spyOn(wallet, 'default').mockReturnValue(mockWallet) | ||
|
||
const result = render(<SettingsHeader />) | ||
|
||
expect(result.getByText('Security & Login')).toBeInTheDocument() | ||
}) | ||
}) | ||
}) |
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