Skip to content

Commit

Permalink
[MMI] updates onboarding flow for MMI (#20905)
Browse files Browse the repository at this point in the history
Updates the amount of steps during onboarding for a MMI user, by
reducing the number of screens one has to go through.
Meaning the user will go from the Welcome screen to -> Create Password
screen -> Pin Extension screen -> Continue to MMI screen.

## Pre-merge author checklist

- [x] I've clearly explained:
  - [x] What problem this PR is solving
  - [x] How this problem was solved
  - [x] How reviewers can test my changes
- [x] Sufficient automated test coverage has been added

## Pre-merge reviewer checklist

- [x] Manual testing (e.g. pull and build branch, run in browser, test
code being changed)
- [ ] **IF** this PR fixes a bug in the release milestone, add this PR
to the release milestone

If further QA is required (e.g. new feature, complex testing steps,
large refactor), add the `Extension QA Board` label.

In this case, a QA Engineer approval will be be required.

---------

Co-authored-by: MetaMask Bot <metamaskbot@users.noreply.github.com>
Co-authored-by: Brad Decker <bhdecker84@gmail.com>
  • Loading branch information
3 people authored Oct 5, 2023
1 parent 4c67c06 commit 945dc7f
Show file tree
Hide file tree
Showing 23 changed files with 1,275 additions and 189 deletions.
30 changes: 30 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.

112 changes: 112 additions & 0 deletions app/images/onboarding-mmi-pin-browser.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
26 changes: 1 addition & 25 deletions lavamoat/browserify/mmi/policy.json
Original file line number Diff line number Diff line change
Expand Up @@ -4984,32 +4984,8 @@
},
"react-responsive-carousel": {
"globals": {
"HTMLElement": true,
"addEventListener": true,
"clearTimeout": true,
"console.warn": true,
"document": true,
"getComputedStyle": true,
"removeEventListener": true,
"setTimeout": true
},
"packages": {
"classnames": true,
"react": true,
"react-dom": true,
"react-responsive-carousel>react-easy-swipe": true
}
},
"react-responsive-carousel>react-easy-swipe": {
"globals": {
"addEventListener": true,
"define": true,
"document.addEventListener": true,
"document.removeEventListener": true
},
"packages": {
"prop-types": true,
"react": true
"removeEventListener": true
}
},
"react-router-dom": {
Expand Down
2 changes: 1 addition & 1 deletion test/e2e/metamask-ui.spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ const Ganache = require('./ganache');
const ganacheServer = new Ganache();
const dappPort = 8080;

describe('MetaMask', function () {
describe('MetaMask @no-mmi', function () {
let driver;
let dappServer;
let tokenAddress;
Expand Down
4 changes: 2 additions & 2 deletions test/e2e/metrics/wallet-created.spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -48,8 +48,8 @@ async function mockSegment(mockServer) {
];
}

describe('Wallet Created Events', function () {
it('are sent when onboarding user who chooses to opt in metrics @no-mmi', async function () {
describe('Wallet Created Events @no-mmi', function () {
it('are sent when onboarding user who chooses to opt in metrics', async function () {
await withFixtures(
{
fixtures: new FixtureBuilder({ onboarding: true })
Expand Down
2 changes: 1 addition & 1 deletion test/e2e/nft/remove-erc1155.spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ describe('Remove ERC1155 NFT', function () {
],
};

it('user should be able to remove ERC1155 NFT on details page', async function () {
it('user should be able to remove ERC1155 NFT on details page @no-mmi', async function () {
await withFixtures(
{
dapp: true,
Expand Down
2 changes: 1 addition & 1 deletion test/e2e/nft/send-nft.spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ describe('Send NFT', function () {
],
};

it('should be able to send ERC721 NFT', async function () {
it('should be able to send ERC721 NFT @no-mmi', async function () {
await withFixtures(
{
dapp: true,
Expand Down
2 changes: 1 addition & 1 deletion test/e2e/nft/view-erc1155-details.spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ describe('View ERC1155 NFT details', function () {
],
};

it('user should be able to view ERC1155 NFT details', async function () {
it('user should be able to view ERC1155 NFT details @no-mmi', async function () {
await withFixtures(
{
dapp: true,
Expand Down
2 changes: 1 addition & 1 deletion test/e2e/tests/import-flow.spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ const ganacheOptions = {
],
};

describe('Import flow', function () {
describe('Import flow @no-mmi', function () {
it('Import wallet using Secret Recovery Phrase', async function () {
const testPassword = 'correct horse battery staple';

Expand Down
2 changes: 1 addition & 1 deletion test/e2e/tests/metamask-responsive-ui.spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ const {
const FixtureBuilder = require('../fixture-builder');

describe('MetaMask Responsive UI', function () {
it('Creating a new wallet', async function () {
it('Creating a new wallet @no-mmi', async function () {
const driverOptions = { openDevToolsForTabs: true };

await withFixtures(
Expand Down
4 changes: 2 additions & 2 deletions test/e2e/tests/onboarding.spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ const {
} = require('../helpers');
const FixtureBuilder = require('../fixture-builder');

describe('MetaMask onboarding', function () {
describe('MetaMask onboarding @no-mmi', function () {
const testPassword = 'correct horse battery staple';
const wrongSeedPhrase =
'test test test test test test test test test test test test';
Expand Down Expand Up @@ -239,7 +239,7 @@ describe('MetaMask onboarding', function () {
);
});

it(`User can add custom network during onboarding`, async function () {
it('User can add custom network during onboarding', async function () {
const networkName = 'Localhost 8546';
const networkUrl = 'http://127.0.0.1:8546';
const currencySymbol = 'ETH';
Expand Down
2 changes: 2 additions & 0 deletions ui/helpers/constants/routes.ts
Original file line number Diff line number Diff line change
Expand Up @@ -70,6 +70,7 @@ const ONBOARDING_REVIEW_SRP_ROUTE = '/onboarding/review-recovery-phrase';
const ONBOARDING_CONFIRM_SRP_ROUTE = '/onboarding/confirm-recovery-phrase';
const ONBOARDING_CREATE_PASSWORD_ROUTE = '/onboarding/create-password';
const ONBOARDING_COMPLETION_ROUTE = '/onboarding/completion';
const MMI_ONBOARDING_COMPLETION_ROUTE = '/onboarding/account-completion';
const ONBOARDING_UNLOCK_ROUTE = '/onboarding/unlock';
const ONBOARDING_HELP_US_IMPROVE_ROUTE = '/onboarding/help-us-improve';
const ONBOARDING_IMPORT_WITH_SRP_ROUTE =
Expand Down Expand Up @@ -276,6 +277,7 @@ export {
ONBOARDING_CONFIRM_SRP_ROUTE,
ONBOARDING_PRIVACY_SETTINGS_ROUTE,
ONBOARDING_COMPLETION_ROUTE,
MMI_ONBOARDING_COMPLETION_ROUTE,
ONBOARDING_UNLOCK_ROUTE,
ONBOARDING_PIN_EXTENSION_ROUTE,
ONBOARDING_WELCOME_ROUTE,
Expand Down
9 changes: 9 additions & 0 deletions ui/pages/institutional/onboarding-successful/index.scss
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
.onboarding-successful {
@include screen-sm-min {
display: flex;
flex-direction: column;
align-items: center;
}

max-width: 600px;
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,50 @@
import React from 'react';
import { useDispatch, useSelector } from 'react-redux';
import { Box, Text } from '../../../components/component-library';
import Button from '../../../components/ui/button';
import {
TextVariant,
TextAlign,
FontWeight,
} from '../../../helpers/constants/design-system';
import { useI18nContext } from '../../../hooks/useI18nContext';
import { setCompletedOnboarding } from '../../../store/actions';
import { getMMIConfiguration } from '../../../selectors/institutional/selectors';

export default function OnboardingSuccessful() {
const t = useI18nContext();
const dispatch = useDispatch();
const { portfolio } = useSelector(getMMIConfiguration);

return (
<div className="onboarding-successful" data-testid="onboarding-successful">
<Box textAlign={TextAlign.Center}>
<Text
variant={TextVariant.headingLg}
fontWeight={FontWeight.Bold}
margin={6}
>
{t('extensionInsallCompleteTitle')}
</Text>
<Text marginTop={6} marginBottom={6}>
{t('extensionInsallCompleteDescription')}
</Text>
</Box>

<Box marginTop={6}>
<Button
data-testid="onboarding-continue-button"
type="primary"
large
rounded
onClick={async () => {
await dispatch(setCompletedOnboarding());
window.open(portfolio.url);
}}
>
{t('continueMmiOnboarding')}
</Button>
</Box>
</div>
);
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
import React from 'react';
import OnboardingSuccessful from './onboarding-successful';

export default {
title: 'Pages/Institutional/OnboardingSuccessful',
};

export const DefaultStory = () => {
return (
<div style={{ maxHeight: '2000px' }}>
<OnboardingSuccessful />
</div>
);
};

DefaultStory.storyName = 'Default';
Original file line number Diff line number Diff line change
@@ -0,0 +1,44 @@
import React from 'react';
import configureMockStore from 'redux-mock-store';
import thunk from 'redux-thunk';
import {
renderWithProvider,
setBackgroundConnection,
} from '../../../../test/jest';
import OnboardingSuccessful from './onboarding-successful';

const mockHistoryPush = jest.fn();

const completeOnboardingStub = jest
.fn()
.mockImplementation(() => Promise.resolve());

jest.mock('react-router-dom', () => ({
...jest.requireActual('react-router-dom'),
useHistory: () => ({
push: mockHistoryPush,
}),
}));

describe('Successful Onboarding View', () => {
const mockStore = {
metamask: {
providerConfig: {
type: 'test',
},
},
};
const store = configureMockStore([thunk])(mockStore);
setBackgroundConnection({ completeOnboarding: completeOnboardingStub });

afterEach(() => {
jest.resetAllMocks();
});

it('should render the onboarding-successful view', () => {
const { getByTestId } = renderWithProvider(<OnboardingSuccessful />, store);
const continueButton = getByTestId('onboarding-continue-button');
expect(getByTestId('onboarding-successful')).toBeInTheDocument();
expect(continueButton).toBeInTheDocument();
});
});
Loading

0 comments on commit 945dc7f

Please sign in to comment.