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(23946): Add advanced details component #24833

Merged
merged 34 commits into from
Jun 21, 2024
Merged
Show file tree
Hide file tree
Changes from 28 commits
Commits
Show all changes
34 commits
Select commit Hold shift + click to select a range
b725dc8
wip
pedronfigueiredo May 28, 2024
7988d2c
wip
pedronfigueiredo May 29, 2024
402cb2b
wip
pedronfigueiredo May 29, 2024
e95274f
wip
pedronfigueiredo May 29, 2024
e3d5c20
wip
pedronfigueiredo May 29, 2024
5e8e17e
wip
pedronfigueiredo May 29, 2024
78a5817
wip
pedronfigueiredo May 29, 2024
8f4a090
Update app/images/icons/customize.svg
pedronfigueiredo May 29, 2024
b58e988
address feedback
pedronfigueiredo May 29, 2024
58313e2
Update app/_locales/en/messages.json
pedronfigueiredo Jun 3, 2024
5fae743
address feedback
pedronfigueiredo Jun 3, 2024
3c40ea5
address feedback
pedronfigueiredo Jun 3, 2024
e8af2ac
address feedback
pedronfigueiredo Jun 3, 2024
7d9d773
tweak e2e tests
pedronfigueiredo Jun 3, 2024
6c84f16
tweak unit tests
pedronfigueiredo Jun 3, 2024
13b36a7
tweak unit tests
pedronfigueiredo Jun 3, 2024
0494ad1
wip
pedronfigueiredo Jun 4, 2024
ad9ea2e
wip
pedronfigueiredo Jun 4, 2024
df7e5db
tweak e2e test
pedronfigueiredo Jun 4, 2024
62e94f8
fix bug with scroll to bottom arrow
pedronfigueiredo Jun 4, 2024
0ac531b
wip
pedronfigueiredo Jun 6, 2024
a38d1f6
revert yarnrc
pedronfigueiredo Jun 6, 2024
69fc542
wip
pedronfigueiredo Jun 6, 2024
26fcf4b
wip
pedronfigueiredo Jun 6, 2024
4c0131a
wip
pedronfigueiredo Jun 11, 2024
4153dc2
wip
pedronfigueiredo Jun 11, 2024
fd252f6
wip
pedronfigueiredo Jun 11, 2024
cc91236
wip
pedronfigueiredo Jun 11, 2024
dc7c25a
Merge branch 'develop' into pnf/23946
matthewwalsh0 Jun 19, 2024
7159a89
Fix linting
matthewwalsh0 Jun 19, 2024
82b9fc0
Remove console logs
matthewwalsh0 Jun 19, 2024
f4b5a1a
Fix E2E tests
matthewwalsh0 Jun 20, 2024
60a96bf
Merge branch 'develop' into pnf/23946
matthewwalsh0 Jun 20, 2024
0b51574
Fix firefox E2E tests
matthewwalsh0 Jun 20, 2024
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
12 changes: 12 additions & 0 deletions app/_locales/en/messages.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

3 changes: 3 additions & 0 deletions app/images/icons/customize.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
186 changes: 186 additions & 0 deletions test/e2e/tests/confirmations/contract-interaction-redesign.spec.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,186 @@
const {
defaultGanacheOptions,
openDapp,
unlockWallet,
WINDOW_TITLES,
withFixtures,
} = require('../../helpers');
const FixtureBuilder = require('../../fixture-builder');

describe('Confirmation Redesign Contract Interaction Component', function () {
if (!process.env.ENABLE_CONFIRMATION_REDESIGN) {
return;
}

it('Sends a contract interaction type 0 transaction without custom nonce editing', async function () {
await withFixtures(
{
dapp: true,
fixtures: new FixtureBuilder()
.withPermissionControllerConnectedToTestDapp()
.withPreferencesController({
preferences: { redesignedConfirmationsEnabled: true },
})
.build(),
ganacheOptions: defaultGanacheOptions,
title: this.test?.fullTitle(),
pedronfigueiredo marked this conversation as resolved.
Show resolved Hide resolved
},
async ({ driver }) => {
await unlockWallet(driver);
await openDapp(driver);

await createContractDeploymentTransaction(driver);
await confirmContractDeploymentTransaction(driver);

await createDepositTransaction(driver);
await confirmDepositTransaction(driver);
},
);
});

it('Sends a contract interaction type 0 transaction with custom nonce editing', async function () {
await withFixtures(
{
dapp: true,
fixtures: new FixtureBuilder()
.withPermissionControllerConnectedToTestDapp()
.withPreferencesController({
preferences: { redesignedConfirmationsEnabled: true },
})
.build(),
ganacheOptions: defaultGanacheOptions,
title: this.test?.fullTitle(),
},
async ({ driver }) => {
await unlockWallet(driver);
await openDapp(driver);

await toggleOnCustomNonce(driver);

await createContractDeploymentTransaction(driver);
await confirmContractDeploymentTransaction(driver);

await createDepositTransaction(driver);
await confirmDepositTransactionWithCustomNonce(driver, '10');
},
);
});
});

async function toggleOnCustomNonce(driver) {
// switch to metamask page and open the three dots menu
await driver.switchToWindowWithTitle(WINDOW_TITLES.ExtensionInFullScreenView);

// Open settings menu button
const accountOptionsMenuSelector =
'[data-testid="account-options-menu-button"]';
await driver.waitForSelector(accountOptionsMenuSelector);
await driver.clickElement(accountOptionsMenuSelector);

// Click settings from dropdown menu
const globalMenuSettingsSelector = '[data-testid="global-menu-settings"]';
await driver.waitForSelector(globalMenuSettingsSelector);
await driver.clickElement(globalMenuSettingsSelector);

// Click Advanced tab
const advancedTabRawLocator = {
text: 'Advanced',
tag: 'div',
};
await driver.clickElement(advancedTabRawLocator);

// Toggle on custom toggle setting (off by default)
await driver.clickElement('.custom-nonce-toggle');

// Close settings
await driver.clickElement(
'.settings-page__header__title-container__close-button',
);
}

async function createContractDeploymentTransaction(driver) {
await driver.switchToWindowWithTitle(WINDOW_TITLES.TestDApp);
await driver.clickElement(`#deployButton`);
}

async function confirmContractDeploymentTransaction(driver) {
await driver.delay(2000);
await driver.switchToWindowWithTitle(WINDOW_TITLES.Dialog);

await driver.waitForSelector({
css: '.confirm-page-container-summary__action__name',
text: 'Contract deployment',
});

await driver.clickElement({ text: 'Confirm', tag: 'button' });
await driver.waitUntilXWindowHandles(2);
await driver.switchToWindowWithTitle(WINDOW_TITLES.ExtensionInFullScreenView);
await driver.clickElement({ text: 'Activity', tag: 'button' });
await driver.waitForSelector(
'.transaction-list__completed-transactions .activity-list-item:nth-of-type(1)',
);
}

async function createDepositTransaction(driver) {
await driver.switchToWindowWithTitle(WINDOW_TITLES.TestDApp);
await driver.clickElement(`#depositButton`);
}

async function confirmDepositTransaction(driver) {
await driver.delay(2000);
await driver.switchToWindowWithTitle(WINDOW_TITLES.Dialog);

await driver.waitForSelector({
css: 'h2',
text: 'Transaction request',
});

await driver.clickElement(`[data-testid="header-advanced-details-button"]`);

await driver.waitForSelector({
css: 'p',
text: 'Nonce',
});

await driver.clickElement(`[data-testid="confirm-footer-button"]`);
}

async function confirmDepositTransactionWithCustomNonce(driver, customNonce) {
await driver.delay(2000);
await driver.switchToWindowWithTitle(WINDOW_TITLES.Dialog);

await driver.waitForSelector({
css: 'h2',
text: 'Transaction request',
});

await driver.clickElement(`[data-testid="header-advanced-details-button"]`);

await driver.waitForSelector({
css: 'p',
text: 'Nonce',
});

await driver.clickElement('.edit-nonce-btn');
await driver.fill('[data-testid="custom-nonce-input"]', customNonce);
await driver.clickElement({
text: 'Save',
tag: 'button',
});
await driver.clickElement(`[data-testid="confirm-footer-button"]`);

// Confirm tx was submitted with the higher nonce
await driver.switchToWindowWithTitle(WINDOW_TITLES.ExtensionInFullScreenView);

await driver.delay(500);

const sendTransactionListItem = await driver.findElement(
'.transaction-list__pending-transactions .activity-list-item',
);
await sendTransactionListItem.click();

await driver.waitForSelector({
css: '.transaction-breakdown__value',
text: customNonce,
});
}
4 changes: 2 additions & 2 deletions ui/components/app/confirm/info/row/row.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -66,15 +66,15 @@ export const ConfirmInfoRowContext = createContext({
variant: ConfirmInfoRowVariant.Default,
});

export const ConfirmInfoRow = ({
export const ConfirmInfoRow: React.FC<ConfirmInfoRowProps> = ({
label,
children,
variant = ConfirmInfoRowVariant.Default,
tooltip,
style,
labelChildren,
color,
}: ConfirmInfoRowProps) => (
}) => (
<ConfirmInfoRowContext.Provider value={{ variant }}>
<Box
className="confirm-info-row"
Expand Down
11 changes: 9 additions & 2 deletions ui/components/app/confirm/info/row/text.stories.tsx
Original file line number Diff line number Diff line change
@@ -1,19 +1,21 @@
import { action } from '@storybook/addon-actions';
import React from 'react';
import { ConfirmInfoRow } from './row';
import { ConfirmInfoRowText } from './text';

const ConfirmInfoRowTextStory = {
title: 'Components/App/Confirm/InfoRowText',
component: ConfirmInfoRowText,

decorators: [
(story) => <ConfirmInfoRow label="Message">{story()}</ConfirmInfoRow>,
],

argTypes: {
url: {
control: 'text',
},
onEditClick: {
action: 'onEditClick',
},
},
};

Expand All @@ -22,4 +24,9 @@ DefaultStory.args = {
text: 'Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat. Duis aute irure dolor in reprehenderit in voluptate velit esse cillum dolore eu fugiat nulla pariatur. Excepteur sint occaecat cupidatat non proident, sunt in culpa qui officia deserunt mollit anim id est laborum.',
};

export const EditableStory = (props) => <ConfirmInfoRowText {...props} />;
EditableStory.args = {
text: 'Lorem ipsum dolor sit amet.',
};

export default ConfirmInfoRowTextStory;
28 changes: 25 additions & 3 deletions ui/components/app/confirm/info/row/text.tsx
Original file line number Diff line number Diff line change
@@ -1,17 +1,29 @@
import React from 'react';
import { Box, Text } from '../../../../component-library';
import React, { useContext } from 'react';
import { I18nContext } from '../../../../../contexts/i18n';
import {
AlignItems,
Display,
FlexWrap,
IconColor,
TextColor,
} from '../../../../../helpers/constants/design-system';
import { Box, ButtonIcon, IconName, Text } from '../../../../component-library';

export type ConfirmInfoRowTextProps = {
text: string;
onEditClick?: () => void;
editIconClassName?: string;
};

export const ConfirmInfoRowText = ({ text }: ConfirmInfoRowTextProps) => {
export const ConfirmInfoRowText: React.FC<ConfirmInfoRowTextProps> = ({
text,
onEditClick,
editIconClassName,
}) => {
const t = useContext(I18nContext);

const isEditable = Boolean(onEditClick);

return (
<Box
display={Display.Flex}
Expand All @@ -22,6 +34,16 @@ export const ConfirmInfoRowText = ({ text }: ConfirmInfoRowTextProps) => {
<Text color={TextColor.inherit} style={{ whiteSpace: 'pre-wrap' }}>
{text}
</Text>
{isEditable ? (
<ButtonIcon
className={editIconClassName || undefined}
color={IconColor.primaryDefault}
ariaLabel={t('edit')}
marginLeft={4}
iconName={IconName.Edit}
onClick={onEditClick}
/>
) : null}
</Box>
);
};
1 change: 1 addition & 0 deletions ui/components/component-library/icon/icon.types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -60,6 +60,7 @@ export enum IconName {
Connect = 'connect',
CopySuccess = 'copy-success',
Copy = 'copy',
Customize = 'customize',
Danger = 'danger',
Dark = 'dark',
Data = 'data',
Expand Down
Loading