-
-
Notifications
You must be signed in to change notification settings - Fork 1.2k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
feat: enable STX by default with migration and notification #12857
base: main
Are you sure you want to change the base?
Changes from all commits
8252ebe
6e2cb2e
dfaf2c4
3b451b1
ebaa6d2
f91d3be
a6ab361
c1c58d2
fdd0210
68ce7ae
54b561f
53fb3aa
a3eed30
0c570ef
5b3ae78
8fbcce4
a504eb7
e95a6fa
e9f2846
b4f2132
f0cdee7
2674cfa
c346158
1cc1453
6f64bf2
dccd1ef
9be5ae1
00730de
7133f70
921ad78
971bdca
cad3fe3
378cdcb
e11721c
f0d6ac6
02bc56c
bea3655
9f7bb23
76f5758
7efc46a
17a7eeb
d745beb
d767fe1
ab77e91
ed2a08b
badf5c0
08e81ae
3d2e813
ef8f1ed
6456e04
45524be
f5fe246
4d4d881
ed1d792
306cd8a
f9b1150
dce025a
8322024
9a52902
e7146da
f4ee165
121f122
2e4096c
1818d42
2a5b2cb
bbb2db1
814bacf
9f502c6
a7da8fc
e2ecdad
d112b29
8320dec
04c92b4
05d6bd8
e3c0d6d
204aa91
197f8fd
6848326
fb42b12
3a11c05
37d7f20
a9daaea
c62542a
45140b7
0c82dcb
6eb572d
a87d0f6
d31b420
5bee131
9f83a70
d5360ff
e43c7d0
7036964
a54b04d
5a41b9f
f5f0806
240ed08
bd12f3b
7dba93e
9fbc3f5
c67ae7e
966c607
0224e64
4b9f8a7
bf9332a
62098eb
0c47f4e
0ed05c1
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -592,6 +592,14 @@ exports[`Approval render matches snapshot 1`] = ` | |
} | ||
} | ||
> | ||
<View | ||
style={ | ||
{ | ||
"marginBottom": -8, | ||
"marginHorizontal": 16, | ||
} | ||
} | ||
/> | ||
Comment on lines
+595
to
+602
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This will cause an issue on layout - can we avoid adding this? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. The PR will not pass without it, this is a snapshot update? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Apologies for the confusion @httpJunkie , if this is added in the snapshots, this mean that there is a posibility to include this empty This is an unwanted empty component, this could broke layout because it's empty and adding negative margin. |
||
<View | ||
style={ | ||
{ | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
import { StyleSheet, ViewStyle } from 'react-native'; | ||
import { Theme } from '../../../../../util/theme/models'; | ||
|
||
const styleSheet = (params: { theme: Theme; vars: { style?: ViewStyle } }) => | ||
StyleSheet.create({ | ||
banner: { | ||
marginVertical: 16, | ||
...params.vars.style, | ||
}, | ||
textContainer: { | ||
flexWrap: 'wrap', | ||
}, | ||
link: { | ||
color: params.theme.colors.primary.default, | ||
}, | ||
description: { | ||
color: params.theme.colors.text.default, | ||
} | ||
}); | ||
|
||
export default styleSheet; |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,134 @@ | ||
import React from 'react'; | ||
import { render, fireEvent } from '@testing-library/react-native'; | ||
import { Provider } from 'react-redux'; | ||
import configureMockStore from 'redux-mock-store'; | ||
import SmartTransactionsMigrationBanner from './SmartTransactionsMigrationBanner'; | ||
import Engine from '../../../../../core/Engine'; | ||
|
||
jest.mock('../../../../../core/Engine', () => ({ | ||
context: { | ||
PreferencesController: { | ||
setFeatureFlag: jest.fn(), | ||
}, | ||
}, | ||
})); | ||
|
||
jest.mock('../../../../../../locales/i18n', () => ({ | ||
strings: jest.fn((key) => key), | ||
})); | ||
|
||
// Mock the selectors | ||
jest.mock('../../../../../selectors/preferencesController', () => ({ | ||
selectSmartTransactionsMigrationApplied: jest.fn(() => true), | ||
selectSmartTransactionsBannerDismissed: jest.fn(() => false), | ||
})); | ||
|
||
jest.mock('../../../../../selectors/smartTransactionsController', () => ({ | ||
selectShouldUseSmartTransaction: jest.fn(() => true), | ||
})); | ||
|
||
describe('SmartTransactionsMigrationBanner', () => { | ||
const mockStore = configureMockStore(); | ||
const mockSetFeatureFlag = jest.mocked(Engine.context.PreferencesController.setFeatureFlag); | ||
const mockedPreferences = jest.requireMock('../../../../../selectors/preferencesController'); | ||
const mockedSmartTransactions = jest.requireMock('../../../../../selectors/smartTransactionsController'); | ||
|
||
beforeEach(() => { | ||
jest.clearAllMocks(); | ||
// Reset only the selectors we're actually using | ||
mockedPreferences.selectSmartTransactionsMigrationApplied.mockReturnValue(true); | ||
mockedPreferences.selectSmartTransactionsBannerDismissed.mockReturnValue(false); | ||
mockedSmartTransactions.selectShouldUseSmartTransaction.mockReturnValue(true); | ||
}); | ||
|
||
describe('banner visibility', () => { | ||
it('renders nothing when banner is dismissed', () => { | ||
mockedPreferences.selectSmartTransactionsBannerDismissed.mockReturnValue(true); | ||
|
||
const store = mockStore({}); | ||
const { queryByTestId } = render( | ||
<Provider store={store}> | ||
<SmartTransactionsMigrationBanner /> | ||
</Provider> | ||
); | ||
expect(queryByTestId('smart-transactions-migration-banner')).toBeNull(); | ||
}); | ||
|
||
it('renders nothing when smart transactions are not enabled', () => { | ||
mockedSmartTransactions.selectShouldUseSmartTransaction.mockReturnValue(false); | ||
const store = mockStore({}); | ||
const { queryByTestId } = render( | ||
<Provider store={store}> | ||
<SmartTransactionsMigrationBanner /> | ||
</Provider> | ||
); | ||
expect(queryByTestId('smart-transactions-migration-banner')).toBeNull(); | ||
}); | ||
|
||
it('renders nothing when migration is not applied', () => { | ||
mockedPreferences.selectSmartTransactionsMigrationApplied.mockReturnValue(false); | ||
const store = mockStore({}); | ||
const { queryByTestId } = render( | ||
<Provider store={store}> | ||
<SmartTransactionsMigrationBanner /> | ||
</Provider> | ||
); | ||
expect(queryByTestId('smart-transactions-migration-banner')).toBeNull(); | ||
}); | ||
|
||
it('renders banner when all conditions are met', () => { | ||
const store = mockStore({}); | ||
|
||
const { getByTestId, getByText } = render( | ||
<Provider store={store}> | ||
<SmartTransactionsMigrationBanner /> | ||
</Provider> | ||
); | ||
|
||
expect(getByTestId('smart-transactions-migration-banner')).toBeDefined(); | ||
expect(getByText('smart_transactions_migration.title')).toBeDefined(); | ||
expect(getByText('smart_transactions_migration.link')).toBeDefined(); | ||
}); | ||
}); | ||
|
||
describe('banner interactions', () => { | ||
it('calls setFeatureFlag when close button is pressed', () => { | ||
const store = mockStore({}); | ||
|
||
const { getByTestId } = render( | ||
<Provider store={store}> | ||
<SmartTransactionsMigrationBanner /> | ||
</Provider> | ||
); | ||
|
||
fireEvent.press(getByTestId('banner-close-button-icon')); | ||
expect(mockSetFeatureFlag).toHaveBeenCalledWith( | ||
'smartTransactionsBannerDismissed', | ||
true, | ||
); | ||
}); | ||
}); | ||
|
||
describe('banner styling', () => { | ||
it('accepts and applies custom styles', () => { | ||
const store = mockStore({}); | ||
const customStyle = { marginTop: 20 }; | ||
|
||
const { getByTestId } = render( | ||
<Provider store={store}> | ||
<SmartTransactionsMigrationBanner style={customStyle} /> | ||
</Provider> | ||
); | ||
|
||
const banner = getByTestId('smart-transactions-migration-banner'); | ||
const style = banner.props.style; | ||
|
||
// Check if either marginVertical is set, or both marginTop/marginBottom are set | ||
const hasCorrectMargins = | ||
(style.marginVertical !== undefined) || | ||
(style.marginTop === 20 && style.marginBottom === 16); | ||
|
||
expect(hasCorrectMargins).toBe(true); | ||
}); | ||
}); | ||
}); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Can we avoid adding negative margin values?