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: Adding simulation section to personal sign page #11737

Merged
merged 8 commits into from
Oct 11, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
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
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ const styleSheet = (params: { theme: Theme }) => {
backgroundColor: theme.colors.background.alternative,
paddingHorizontal: 16,
paddingVertical: 24,
minHeight: '60%',
minHeight: '70%',
borderTopLeftRadius: 20,
borderTopRightRadius: 20,
paddingBottom: Device.isIphoneX() ? 20 : 0,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -121,7 +121,7 @@ exports[`Confirm should match snapshot for personal sign 1`] = `
"borderTopLeftRadius": 20,
"borderTopRightRadius": 20,
"justifyContent": "space-between",
"minHeight": "60%",
"minHeight": "70%",
"paddingBottom": 20,
"paddingHorizontal": 16,
"paddingVertical": 24,
Expand Down Expand Up @@ -344,6 +344,131 @@ exports[`Confirm should match snapshot for personal sign 1`] = `
/>
</View>
</TouchableOpacity>
<View
style={
{
"backgroundColor": "#ffffff",
"borderColor": "#bbc0c566",
"borderRadius": 8,
"borderWidth": 1,
"marginBottom": 8,
"padding": 8,
}
}
>
<View
style={
{
"display": "flex",
"flexDirection": "row",
"flexWrap": "wrap",
"justifyContent": "space-between",
"paddingBottom": 8,
"paddingHorizontal": 8,
}
}
>
<View
style={
{
"alignItems": "center",
"display": "flex",
"flexDirection": "row",
"marginTop": 8,
}
}
>
<Text
style={
{
"color": "#141618",
"fontFamily": "EuclidCircularB-Bold",
"fontSize": 14,
"fontWeight": "500",
}
}
>
Estimated changes
</Text>
<View>
<TouchableOpacity
accessible={true}
activeOpacity={1}
disabled={false}
onPress={[Function]}
onPressIn={[Function]}
onPressOut={[Function]}
style={
{
"alignItems": "center",
"borderRadius": 8,
"height": 24,
"justifyContent": "center",
"opacity": 1,
"width": 24,
}
}
testID="tooltipTestId"
>
<SvgMock
color="#9fa6ae"
height={16}
name="Info"
style={
{
"height": 16,
"width": 16,
}
}
width={16}
/>
</TouchableOpacity>
<Modal
animationType="none"
deviceHeight={null}
deviceWidth={null}
hardwareAccelerated={false}
hideModalContentWhileAnimating={false}
onBackdropPress={[Function]}
onModalHide={[Function]}
onModalWillHide={[Function]}
onModalWillShow={[Function]}
onRequestClose={[Function]}
onSwipeComplete={[Function]}
panResponderThreshold={4}
scrollHorizontal={false}
scrollOffset={0}
scrollOffsetMax={0}
scrollTo={null}
statusBarTranslucent={false}
supportedOrientations={
[
"portrait",
"landscape",
]
}
swipeDirection="down"
swipeThreshold={100}
transparent={true}
visible={false}
/>
</View>
</View>
<Text
style={
{
"color": "#141618",
"fontFamily": "EuclidCircularB-Regular",
"fontSize": 14,
"fontWeight": "400",
"marginTop": 8,
}
}
>
You’re signing into a site and there are no predicted changes to your account.
</Text>
</View>
</View>
<View
style={
{
Expand Down
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
import React from 'react';
import { fireEvent } from '@testing-library/react-native';

import renderWithProvider from '../../../../../../../../util/test/renderWithProvider';
import { personalSignatureConfirmationState } from '../../../../../../../../util/test/confirm-data-helpers';
import Message from './index';
import { fireEvent } from '@testing-library/react-native';

describe('Message', () => {
it('should match snapshot', async () => {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ import InfoSection from '../../../UI/InfoRow/InfoSection';
import InfoRow from '../../../UI/InfoRow';
import InfoURL from '../../../UI/InfoRow/InfoValue/InfoURL';
import Message from './Message';
import Simulation from './Simulation';

const PersonalSign = () => {
const { approvalRequest } = useApprovalRequest();
Expand All @@ -16,6 +17,7 @@ const PersonalSign = () => {

return (
<>
<Simulation />
<InfoSection>
<InfoRow
label={strings('confirm.request_from')}
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
import React from 'react';

import renderWithProvider from '../../../../../../../../util/test/renderWithProvider';
import { personalSignatureConfirmationState } from '../../../../../../../../util/test/confirm-data-helpers';
import Simulation from './index';

describe('Simulation', () => {
it('should match snapshot', async () => {
const container = renderWithProvider(<Simulation />, {
state: personalSignatureConfirmationState,
});
expect(container).toMatchSnapshot();
});

it('should return null if preference useTransactionSimulations is not enabled', async () => {
const container = renderWithProvider(<Simulation />, {
state: {
engine: {
backgroundState: {
...personalSignatureConfirmationState,
PreferencesController: {
...personalSignatureConfirmationState.engine.backgroundState
.PreferencesController,
useTransactionSimulations: false,
},
},
},
},
});
expect(container).toMatchSnapshot();
});
});
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
import React from 'react';
import { useSelector } from 'react-redux';

import { strings } from '../../../../../../../../../locales/i18n';
import { selectUseTransactionSimulations } from '../../../../../../../../selectors/preferencesController';
import InfoSection from '../../../../UI/InfoRow/InfoSection';
import InfoRow from '../../../../UI/InfoRow';

const Simulation = () => {
const useTransactionSimulations = useSelector(
selectUseTransactionSimulations,
);

if (useTransactionSimulations !== true) {
return null;
}

return (
<InfoSection>
<InfoRow
label={strings('confirm.simulation.title')}
tooltip={strings('confirm.simulation.tooltip')}
>
{strings('confirm.simulation.personal_sign_info')}
</InfoRow>
</InfoSection>
);
};

export default Simulation;
Original file line number Diff line number Diff line change
@@ -0,0 +1,131 @@
// Jest Snapshot v1, https://goo.gl/fbAQLP

exports[`Simulation should match snapshot 1`] = `
<View
style={
{
"backgroundColor": "#ffffff",
"borderColor": "#bbc0c566",
"borderRadius": 8,
"borderWidth": 1,
"marginBottom": 8,
"padding": 8,
}
}
>
<View
style={
{
"display": "flex",
"flexDirection": "row",
"flexWrap": "wrap",
"justifyContent": "space-between",
"paddingBottom": 8,
"paddingHorizontal": 8,
}
}
>
<View
style={
{
"alignItems": "center",
"display": "flex",
"flexDirection": "row",
"marginTop": 8,
}
}
>
<Text
style={
{
"color": "#141618",
"fontFamily": "EuclidCircularB-Bold",
"fontSize": 14,
"fontWeight": "500",
}
}
>
Estimated changes
</Text>
<View>
<TouchableOpacity
accessible={true}
activeOpacity={1}
disabled={false}
onPress={[Function]}
onPressIn={[Function]}
onPressOut={[Function]}
style={
{
"alignItems": "center",
"borderRadius": 8,
"height": 24,
"justifyContent": "center",
"opacity": 1,
"width": 24,
}
}
testID="tooltipTestId"
>
<SvgMock
color="#9fa6ae"
height={16}
name="Info"
style={
{
"height": 16,
"width": 16,
}
}
width={16}
/>
</TouchableOpacity>
<Modal
animationType="none"
deviceHeight={null}
deviceWidth={null}
hardwareAccelerated={false}
hideModalContentWhileAnimating={false}
onBackdropPress={[Function]}
onModalHide={[Function]}
onModalWillHide={[Function]}
onModalWillShow={[Function]}
onRequestClose={[Function]}
onSwipeComplete={[Function]}
panResponderThreshold={4}
scrollHorizontal={false}
scrollOffset={0}
scrollOffsetMax={0}
scrollTo={null}
statusBarTranslucent={false}
supportedOrientations={
[
"portrait",
"landscape",
]
}
swipeDirection="down"
swipeThreshold={100}
transparent={true}
visible={false}
/>
</View>
</View>
<Text
style={
{
"color": "#141618",
"fontFamily": "EuclidCircularB-Regular",
"fontSize": 14,
"fontWeight": "400",
"marginTop": 8,
}
}
>
You’re signing into a site and there are no predicted changes to your account.
</Text>
</View>
</View>
`;

exports[`Simulation should return null if preference useTransactionSimulations is not enabled 1`] = `null`;
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
export { default } from './Simulation';
Loading
Loading