Skip to content
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

Open
wants to merge 108 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
108 commits
Select commit Hold shift + click to select a range
8252ebe
wip: first stab at migration for stx by default.
httpJunkie Jan 7, 2025
6e2cb2e
feat: enable STX by default with migration 65:
httpJunkie Jan 7, 2025
dfaf2c4
fix: export State for test
httpJunkie Jan 7, 2025
3b451b1
fix: add explicit null checks (alongside `typeof`) in migration 65 er…
httpJunkie Jan 7, 2025
ebaa6d2
test: create initial test for STX by default migration.
httpJunkie Jan 8, 2025
f91d3be
test: continued work on STX by default migration test.
httpJunkie Jan 8, 2025
a6ab361
test: continued work on STX by default migration test
httpJunkie Jan 8, 2025
c1c58d2
test: continued work on STX by default migration test
httpJunkie Jan 8, 2025
fdd0210
test: continued work on STX by default migration test
httpJunkie Jan 8, 2025
68ce7ae
test: continued work on STX by default migration test
httpJunkie Jan 8, 2025
54b561f
feat: create banner component for STX enabled
httpJunkie Jan 8, 2025
53fb3aa
fix: comment out code that is not yet being used
httpJunkie Jan 8, 2025
a3eed30
feat: Updated string references to use new locale keys
httpJunkie Jan 8, 2025
0c570ef
feat: create useSmartTransactionsEnabled hook
httpJunkie Jan 8, 2025
5b3ae78
feat: implement test for hook
httpJunkie Jan 8, 2025
8fbcce4
test: add test for SmartTransactionsEnabledBanner
httpJunkie Jan 8, 2025
a504eb7
feat: update SmartTransactionsEnabledBanner and useTransactionsEnabled
httpJunkie Jan 9, 2025
e95a6fa
feat: add action to store settings
httpJunkie Jan 9, 2025
e9f2846
feat: add smartTransactionsBannerDismissed preferenceController and i…
httpJunkie Jan 9, 2025
b4f2132
feat: add SmartTransactionsEnabledBanner to TransactionReview
httpJunkie Jan 9, 2025
f0cdee7
feat: increase migration number temporarily to avoid conflicts
httpJunkie Jan 14, 2025
2674cfa
Merge branch 'main' into feat/enable-stx-migration
httpJunkie Jan 14, 2025
c346158
feat: remove temporary migration file used to try and setup state, th…
httpJunkie Jan 14, 2025
1cc1453
Merge branch 'main' into feat/enable-stx-migration
httpJunkie Jan 14, 2025
6f64bf2
feat: remove SmartTransactionsEnabledBanner from TransactionReview, e…
httpJunkie Jan 14, 2025
dccd1ef
feat: update SmartTransactionsEnabledBanner to dismiss ALert when lin…
httpJunkie Jan 15, 2025
9be5ae1
fix: update useSmartTransactionsEnabled.test.ts
httpJunkie Jan 15, 2025
00730de
fix: update useSmartTransactionsEnabled hook to add additional checks…
httpJunkie Jan 15, 2025
7133f70
feat: update and improve useSmartTransactionsEnabled
httpJunkie Jan 16, 2025
921ad78
fix: move smartTransactionsBannerDismissed to featureFlags
httpJunkie Jan 16, 2025
971bdca
Merge branch 'main' into feat/enable-stx-migration
httpJunkie Jan 16, 2025
cad3fe3
feat: add banner alert to ApproveTransactionReview and TransactionReview
httpJunkie Jan 16, 2025
378cdcb
feat: add SmartTransactionsEnabledBanner to Swaps Quotes VIew
httpJunkie Jan 16, 2025
e11721c
fix: temporary code to reset `smartTransactionsBannerDismissed` for q…
httpJunkie Jan 16, 2025
f0d6ac6
feat: update QuickView and placement of the the SmartTransactionsEnab…
httpJunkie Jan 16, 2025
02bc56c
fix: update naming convention of SmartTransactionsEnableBanner on Tra…
httpJunkie Jan 16, 2025
bea3655
Merge branch 'main' into feat/enable-stx-migration
httpJunkie Jan 16, 2025
9f7bb23
fix: remove devTestId from TransactionReview view
httpJunkie Jan 17, 2025
76f5758
Merge branch 'feat/enable-stx-migration' of github.com:MetaMask/metam…
httpJunkie Jan 17, 2025
7efc46a
fix: remove dev testing code from `useSmartTransactionsEnabled` hook.
httpJunkie Jan 17, 2025
17a7eeb
Merge branch 'feat/enable-stx-migration' of github.com:MetaMask/metam…
httpJunkie Jan 17, 2025
d745beb
fix: refactor `useSmartTransactionsEnabled` hook to use selectors ins…
httpJunkie Jan 17, 2025
d767fe1
refactor: move smartTransactionsMigrationApplied into PreferencesCont…
httpJunkie Jan 17, 2025
ab77e91
fix: addressing Daniels comments
httpJunkie Jan 17, 2025
ed2a08b
test: update snapshots for:
httpJunkie Jan 17, 2025
badf5c0
test: fix migration test
httpJunkie Jan 17, 2025
08e81ae
fix: update testID values after component name change to be consistent
httpJunkie Jan 17, 2025
3d2e813
test: update location of `smartTransactionsMigrationApplied` to be wi…
httpJunkie Jan 17, 2025
ef8f1ed
test: update snapshot for Approval to account for our component and s…
httpJunkie Jan 17, 2025
6456e04
Merge branch 'main' into feat/enable-stx-migration
httpJunkie Jan 17, 2025
45524be
feat: update migration to #067 from #096
httpJunkie Jan 18, 2025
f5fe246
fix: bump error message details to show 67 instead of 65 for the migr…
httpJunkie Jan 20, 2025
4d4d881
Merge branch 'main' into feat/enable-stx-migration
httpJunkie Jan 20, 2025
ed1d792
test: update test for migration to expect test #067 instead of #065
httpJunkie Jan 20, 2025
306cd8a
Merge branch 'feat/enable-stx-migration' of github.com:MetaMask/metam…
httpJunkie Jan 20, 2025
f9b1150
Merge branch 'feat/enable-stx-migration' of github.com:MetaMask/metam…
httpJunkie Jan 20, 2025
dce025a
Merge branch 'main' into feat/enable-stx-migration
httpJunkie Jan 20, 2025
8322024
Merge branch 'main' into feat/enable-stx-migration
httpJunkie Jan 21, 2025
9a52902
feat: add my migration back after accepting merge change?
httpJunkie Jan 21, 2025
e7146da
feat: Update SmartTransactionMigrationBanner chain support
httpJunkie Jan 30, 2025
f4ee165
Merge branch 'main' into feat/enable-stx-migration plus "migration in…
httpJunkie Jan 31, 2025
121f122
Merge branch 'main' into feat/enable-stx-migration
httpJunkie Jan 31, 2025
2e4096c
Merge branch 'main' into feat/enable-stx-migration
httpJunkie Jan 31, 2025
1818d42
fix: simplify STX migration to ignore transaction history
httpJunkie Jan 31, 2025
2a5b2cb
test: update STX banner tests to use proper mocks
httpJunkie Jan 31, 2025
bbb2db1
Merge branch 'main' into feat/enable-stx-migration
httpJunkie Jan 31, 2025
814bacf
Merge branch 'main' into feat/enable-stx-migration
httpJunkie Jan 31, 2025
9f502c6
fix: mock smart transaction selectors for tests
httpJunkie Jan 31, 2025
a7da8fc
fix: remove extra line in migrations index
httpJunkie Jan 31, 2025
e2ecdad
test: fix test mocks for STX migration changes
httpJunkie Feb 1, 2025
d112b29
test: add missing transaction simulation selector mock
httpJunkie Feb 1, 2025
8320dec
test: add missing selectors to component tests
httpJunkie Feb 3, 2025
04c92b4
fix: update path in test and add `selectGasFeeEstimates`
httpJunkie Feb 3, 2025
05d6bd8
Merge branch 'main' into feat/enable-stx-migration
httpJunkie Feb 3, 2025
e3c0d6d
Merge branch 'main' into feat/enable-stx-migration
httpJunkie Feb 4, 2025
204aa91
Merge branch 'main' into feat/enable-stx-migration
httpJunkie Feb 4, 2025
197f8fd
Merge branch 'main' into feat/enable-stx-migration
httpJunkie Feb 4, 2025
6848326
Bump version number to 1545
metamaskbot Feb 4, 2025
fb42b12
fix: bump version to create testflight build
httpJunkie Feb 5, 2025
3a11c05
Merge branch 'feat/enable-stx-migration' of https://github.com/MetaMa…
httpJunkie Feb 5, 2025
37d7f20
Bump version number to 1546
metamaskbot Feb 5, 2025
a9daaea
Merge branch 'main' into feat/enable-stx-migration
httpJunkie Feb 5, 2025
c62542a
Merge branch 'main' into feat/enable-stx-migration
httpJunkie Feb 5, 2025
45140b7
Merge branch 'main' into feat/enable-stx-migration
httpJunkie Feb 5, 2025
0c82dcb
fix: change package version back
httpJunkie Feb 5, 2025
6eb572d
Merge branch 'feat/enable-stx-migration' of https://github.com/MetaMa…
httpJunkie Feb 5, 2025
a87d0f6
Merge branch 'main' into feat/enable-stx-migration
httpJunkie Feb 6, 2025
d31b420
fix: remove change to project file
httpJunkie Feb 6, 2025
5bee131
fix: revert changes to bitrise.yml
httpJunkie Feb 6, 2025
9f83a70
fix: revert build.gradle
httpJunkie Feb 6, 2025
d5360ff
Update migration to flip logic
httpJunkie Feb 6, 2025
e43c7d0
Merge branch 'feat/enable-stx-migration' of https://github.com/MetaMa…
httpJunkie Feb 6, 2025
7036964
Merge branch 'main' into feat/enable-stx-migration
httpJunkie Feb 6, 2025
a54b04d
fix: update migration test after changes
httpJunkie Feb 6, 2025
5a41b9f
Merge branch 'main' into feat/enable-stx-migration
httpJunkie Feb 6, 2025
f5f0806
Merge branch 'main' into feat/enable-stx-migration
httpJunkie Feb 6, 2025
240ed08
refactor(STX): clean up SmartTransactionsMigrationBanner by removing …
httpJunkie Feb 7, 2025
bd12f3b
Merge branch 'main' into feat/enable-stx-migration
httpJunkie Feb 7, 2025
7dba93e
Merge branch 'main' into feat/enable-stx-migration
httpJunkie Feb 7, 2025
9fbc3f5
Merge branch 'main' into feat/enable-stx-migration
httpJunkie Feb 7, 2025
c67ae7e
Merge branch 'feat/enable-stx-migration' of https://github.com/MetaMa…
httpJunkie Feb 7, 2025
966c607
test: expand banner visibility test coverage
httpJunkie Feb 7, 2025
0224e64
Merge branch 'main' into feat/enable-stx-migration
httpJunkie Feb 7, 2025
4b9f8a7
fix: enable custom style override and update test
httpJunkie Feb 7, 2025
bf9332a
fix: apply marginVertical and ensure test handles properly
httpJunkie Feb 7, 2025
62098eb
fix: move `f (!shouldShowBanner)` above dismissBanner const
httpJunkie Feb 7, 2025
0c47f4e
fix: remove unused fragment
httpJunkie Feb 7, 2025
0ed05c1
Merge branch 'main' into feat/enable-stx-migration
httpJunkie Feb 7, 2025
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 11 additions & 0 deletions app/components/UI/Swaps/QuotesView.js
Original file line number Diff line number Diff line change
Expand Up @@ -118,6 +118,7 @@ import { selectGasFeeControllerEstimateType } from '../../../selectors/gasFeeCon
import { addSwapsTransaction } from '../../../util/swaps/swaps-transactions';
import { getTransaction1559GasFeeEstimates } from './utils/gas';
import { getGlobalEthQuery } from '../../../util/networks/global-network';
import SmartTransactionsMigrationBanner from '../../Views/confirmations/components/SmartTransactionsMigrationBanner/SmartTransactionsMigrationBanner';

const LOG_PREFIX = 'Swaps';
const POLLING_INTERVAL = 30000;
Expand Down Expand Up @@ -148,6 +149,11 @@ const createStyles = (colors) =>
marginVertical: 10,
width: '100%',
},
smartTransactionsMigrationBanner: {
paddingHorizontal: 20,
marginBottom: -8,
Copy link
Member

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?

width: '100%',
},
timerWrapper: {
backgroundColor: colors.background.alternative,
borderRadius: 20,
Expand Down Expand Up @@ -1788,6 +1794,11 @@ function SwapsQuotesView({
keyboardShouldPersistTaps="handled"
>
<View style={styles.topBar}>
{shouldUseSmartTransaction && (
<View style={styles.smartTransactionsMigrationBanner}>
<SmartTransactionsMigrationBanner />
</View>
)}
{(!hasEnoughTokenBalance || !hasEnoughEthBalance) && (
<View style={styles.alertBar}>
<Alert small type={AlertType.Info}>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -592,6 +592,14 @@ exports[`Approval render matches snapshot 1`] = `
}
}
>
<View
style={
{
"marginBottom": -8,
"marginHorizontal": 16,
}
}
/>
Comment on lines +595 to +602
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This will cause an issue on layout - can we avoid adding this?

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The PR will not pass without it, this is a snapshot update?

Copy link
Member

@OGPoyraz OGPoyraz Feb 7, 2025

Choose a reason for hiding this comment

The 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 View with negative margin for some cases.

This is an unwanted empty component, this could broke layout because it's empty and adding negative margin.

<View
style={
{
Expand Down
20 changes: 19 additions & 1 deletion app/components/Views/confirmations/Approval/index.test.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,15 @@ import initialRootState from '../../../../util/test/initial-root-state';

const TRANSACTION_ID_MOCK = '123';
jest.mock('../../../../selectors/smartTransactionsController', () => ({
selectShouldUseSmartTransaction: jest.fn().mockReturnValue(false),
selectSmartTransactionsEnabled: () => false,
selectShouldUseSmartTransaction: () => false
}));

jest.mock('../../../../selectors/preferencesController', () => ({
selectSmartTransactionsBannerDismissed: () => false,
selectSmartTransactionsMigrationApplied: () => false,
selectSmartTransactionsOptInStatus: () => false,
selectUseTransactionSimulations: () => false
}));

jest.mock('../../../../util/dappTransactions', () => ({
Expand All @@ -38,6 +46,16 @@ jest.mock('../../../../core/Engine', () => ({
},
}));

jest.mock('../../../../selectors/confirmTransaction', () => ({
selectCurrentTransactionSecurityAlertResponse: () => null,
selectCurrentTransactionMetadata: () => null,
selectGasFeeEstimates: () => ({})
}));

jest.mock('../../../../selectors/tokenListController', () => ({
selectTokenList: () => ({})
}));

const Stack = createStackNavigator();
const mockStore = configureMockStore();
const navigationPropMock = {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,14 @@ import Routes from '../../../../../constants/navigation/Routes';

const TRANSACTION_ID_MOCK = '123';
jest.mock('../../../../../selectors/smartTransactionsController', () => ({
selectShouldUseSmartTransaction: jest.fn().mockReturnValue(false),
selectSmartTransactionsEnabled: () => false,
selectShouldUseSmartTransaction: () => false,
}));

jest.mock('../../../../../selectors/preferencesController', () => ({
selectSmartTransactionsBannerDismissed: () => false,
selectSmartTransactionsMigrationApplied: () => false,
selectSmartTransactionsOptInStatus: () => false,
}));

jest.mock('../../../../../core/GasPolling/GasPolling', () => ({
Expand Down
14 changes: 9 additions & 5 deletions app/components/Views/confirmations/SendFlow/Confirm/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -138,6 +138,7 @@ import {
} from '../../../../../selectors/networkController';
import { selectContractExchangeRatesByChainId } from '../../../../../selectors/tokenRatesController';
import { updateTransactionToMaxValue } from './utils';
import SmartTransactionsMigrationBanner from '../../components/SmartTransactionsMigrationBanner/SmartTransactionsMigrationBanner';
import { isNativeToken } from '../../utils/generic';

const EDIT = 'edit';
Expand Down Expand Up @@ -1422,11 +1423,14 @@ class Confirm extends PureComponent {
/>
<ScrollView style={baseStyles.flexGrow} ref={this.setScrollViewRef}>
{this.state.transactionMeta?.id && (
<TransactionBlockaidBanner
transactionId={this.state.transactionMeta.id}
style={styles.blockaidBanner}
onContactUsClicked={this.onContactUsClicked}
/>
<>
<TransactionBlockaidBanner
transactionId={this.state.transactionMeta.id}
style={styles.blockaidBanner}
onContactUsClicked={this.onContactUsClicked}
/>
<SmartTransactionsMigrationBanner style={styles.smartTransactionsMigrationBanner}/>
</>
)}
{!selectedAsset.tokenId ? (
<View style={styles.amountWrapper}>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -185,6 +185,24 @@ jest.mock('../../../../../core/redux/slices/transactionMetrics', () => ({
selectTransactionMetrics: jest.fn().mockReturnValue({}),
}));

jest.mock('../../../../../reducers/swaps', () => ({
swapsStateSelector: () => ({
featureFlags: {
smart_transactions: {
mobile_active: false
}
}
}),
swapsSmartTxFlagEnabled: () => false
}));

jest.mock('../../../../../selectors/preferencesController', () => ({
selectSmartTransactionsBannerDismissed: () => false,
selectSmartTransactionsMigrationApplied: () => false,
selectSmartTransactionsOptInStatus: () => false,
selectUseTransactionSimulations: () => false,
}));

function render(
// TODO: Replace "any" with type
// eslint-disable-next-line @typescript-eslint/no-explicit-any
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -153,6 +153,10 @@ const createStyles = (colors: any) =>
marginRight: 24,
marginBottom: 24,
},
smartTransactionsMigrationBanner: {
marginBottom: -8,
httpJunkie marked this conversation as resolved.
Show resolved Hide resolved
marginHorizontal: 16,
},
});

export default createStyles;
Original file line number Diff line number Diff line change
Expand Up @@ -103,7 +103,7 @@
import DevLogger from '../../../../../core/SDKConnect/utils/DevLogger';
import { WC2Manager } from '../../../../../core/WalletConnect/WalletConnectV2';
import { WALLET_CONNECT_ORIGIN } from '../../../../../util/walletconnect';

import SmartTransactionsMigrationBanner from '../SmartTransactionsMigrationBanner/SmartTransactionsMigrationBanner';
const { ORIGIN_DEEPLINK, ORIGIN_QR_CODE } = AppConstants.DEEPLINKS;
const POLLING_INTERVAL_ESTIMATED_L1_FEE = 30000;

Expand Down Expand Up @@ -919,6 +919,7 @@
style={styles.blockaidWarning}
onContactUsClicked={this.onContactUsClicked}
/>
<SmartTransactionsMigrationBanner style={styles.smartTransactionsMigrationBanner} />
<Text variant={TextVariant.HeadingMD} style={styles.title}>
{this.getTrustTitle(
originIsDeeplink,
Expand Down Expand Up @@ -1352,7 +1353,7 @@
shouldUseSmartTransaction: selectShouldUseSmartTransaction(state),
securityAlertResponse: selectCurrentTransactionSecurityAlertResponse(state),
};
}

Check warning on line 1356 in app/components/Views/confirmations/components/ApproveTransactionReview/index.js

View workflow job for this annotation

GitHub Actions / scripts (lint)

Missing semicolon

const mapDispatchToProps = (dispatch) => ({
setTransactionObject: (transaction) =>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -172,6 +172,10 @@ const createStyles = (colors: any) =>
marginTop: 20,
marginHorizontal: 10,
},
SmartTransactionsMigrationBanner: {
marginHorizontal: 16,
marginBottom: -8,
},
});

export default createStyles;
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);
});
});
});
Loading
Loading