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

Creation successful onboarding test improvements #18256

Merged
merged 24 commits into from
Apr 20, 2023
Merged
Changes from 8 commits
Commits
Show all changes
24 commits
Select commit Hold shift + click to select a range
2cacdbc
Creation successful test improvements
tmashuang Mar 21, 2023
6aebcd6
Merge branch 'develop' into 17191-onboarding-unit-tests-creation-succ…
tmashuang Mar 22, 2023
ed5ea12
Merge branch 'develop' into 17191-onboarding-unit-tests-creation-succ…
tmashuang Mar 23, 2023
87b6c58
Merge branch 'develop' into 17191-onboarding-unit-tests-creation-succ…
tmashuang Mar 24, 2023
340d3a7
Merge branch 'develop' into 17191-onboarding-unit-tests-creation-succ…
tmashuang Mar 25, 2023
0d13fa9
Merge branch 'develop' into 17191-onboarding-unit-tests-creation-succ…
tmashuang Mar 28, 2023
d743368
Merge branch 'develop' into 17191-onboarding-unit-tests-creation-succ…
tmashuang Mar 29, 2023
b835906
Merge branch 'develop' into 17191-onboarding-unit-tests-creation-succ…
tmashuang Mar 30, 2023
888e8b0
Merge branch 'develop' into 17191-onboarding-unit-tests-creation-succ…
tmashuang Mar 31, 2023
fc9f297
Merge branch 'develop' into 17191-onboarding-unit-tests-creation-succ…
tmashuang Apr 2, 2023
ba1163d
Merge branch 'develop' into 17191-onboarding-unit-tests-creation-succ…
tmashuang Apr 3, 2023
36ee3ed
Merge branch 'develop' into 17191-onboarding-unit-tests-creation-succ…
tmashuang Apr 5, 2023
4232482
Merge branch 'develop' into 17191-onboarding-unit-tests-creation-succ…
tmashuang Apr 6, 2023
ed5cdfb
Merge branch 'develop' into 17191-onboarding-unit-tests-creation-succ…
tmashuang Apr 7, 2023
82a26b1
Merge branch 'develop' into 17191-onboarding-unit-tests-creation-succ…
tmashuang Apr 12, 2023
d9351c2
Merge branch 'develop' into 17191-onboarding-unit-tests-creation-succ…
tmashuang Apr 12, 2023
6937e4d
Merge branch 'develop' into 17191-onboarding-unit-tests-creation-succ…
tmashuang Apr 13, 2023
8f83164
Merge branch 'develop' into 17191-onboarding-unit-tests-creation-succ…
tmashuang Apr 17, 2023
671a713
Merge branch 'develop' into 17191-onboarding-unit-tests-creation-succ…
tmashuang Apr 17, 2023
72cc4ea
Merge branch 'develop' into 17191-onboarding-unit-tests-creation-succ…
tmashuang Apr 17, 2023
4d76133
Merge branch 'develop' into 17191-onboarding-unit-tests-creation-succ…
tmashuang Apr 18, 2023
3c1bee5
Merge branch 'develop' into 17191-onboarding-unit-tests-creation-succ…
tmashuang Apr 19, 2023
9f807ac
Merge branch 'develop' into 17191-onboarding-unit-tests-creation-succ…
tmashuang Apr 20, 2023
d0a3ebd
Merge branch 'develop' into 17191-onboarding-unit-tests-creation-succ…
tmashuang Apr 20, 2023
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
@@ -1,19 +1,30 @@
import React from 'react';
import { fireEvent } from '@testing-library/react';
import reactRouterDom from 'react-router-dom';
import configureMockStore from 'redux-mock-store';
import thunk from 'redux-thunk';
import { ONBOARDING_PRIVACY_SETTINGS_ROUTE } from '../../../helpers/constants/routes';
import {
ONBOARDING_PRIVACY_SETTINGS_ROUTE,
ONBOARDING_PIN_EXTENSION_ROUTE,
} from '../../../helpers/constants/routes';
import {
renderWithProvider,
setBackgroundConnection,
} from '../../../../test/jest';
import CreationSuccessful from './creation-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('Creation Successful Onboarding View', () => {
const mockStore = {
metamask: {
Expand All @@ -25,18 +36,25 @@ describe('Creation Successful Onboarding View', () => {
const store = configureMockStore([thunk])(mockStore);
setBackgroundConnection({ completeOnboarding: completeOnboardingStub });

const pushMock = jest.fn();
beforeAll(() => {
jest
.spyOn(reactRouterDom, 'useHistory')
.mockImplementation()
.mockReturnValue({ push: pushMock });
afterEach(() => {
jest.resetAllMocks();
});

it('should redirect to privacy-settings view when "Advanced configuration" button is clicked', () => {
const { getByText } = renderWithProvider(<CreationSuccessful />, store);
const privacySettingsButton = getByText('Advanced configuration');
fireEvent.click(privacySettingsButton);
expect(pushMock).toHaveBeenCalledWith(ONBOARDING_PRIVACY_SETTINGS_ROUTE);
expect(mockHistoryPush).toHaveBeenCalledWith(
ONBOARDING_PRIVACY_SETTINGS_ROUTE,
);
});

it('should route to pin extension route when "Got it" button is clicked', () => {
const { getByText } = renderWithProvider(<CreationSuccessful />, store);
const gotItButton = getByText('Got it!');
fireEvent.click(gotItButton);
expect(mockHistoryPush).toHaveBeenCalledWith(
ONBOARDING_PIN_EXTENSION_ROUTE,
);
});
});