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

Add Network Modal onboarding unit test #18258

Merged
merged 25 commits into from
Apr 20, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
25 commits
Select commit Hold shift + click to select a range
c9a1fd3
Add Network Modal onboarding tests
tmashuang Mar 21, 2023
77e230a
Merge branch 'develop' into 17191/onboarding-unit-tests-add-network-m…
tmashuang Mar 22, 2023
141e8e0
Merge branch 'develop' into 17191/onboarding-unit-tests-add-network-m…
tmashuang Mar 23, 2023
8ceea11
Merge branch 'develop' into 17191/onboarding-unit-tests-add-network-m…
tmashuang Mar 24, 2023
d62e4c0
Merge branch 'develop' into 17191/onboarding-unit-tests-add-network-m…
tmashuang Mar 25, 2023
a2fc9fd
Merge branch 'develop' into 17191/onboarding-unit-tests-add-network-m…
tmashuang Mar 28, 2023
5c33152
Merge branch 'develop' into 17191/onboarding-unit-tests-add-network-m…
tmashuang Mar 29, 2023
f97c71a
Merge branch 'develop' into 17191/onboarding-unit-tests-add-network-m…
tmashuang Mar 30, 2023
060a402
Merge branch 'develop' into 17191/onboarding-unit-tests-add-network-m…
tmashuang Mar 31, 2023
1811325
Merge branch 'develop' into 17191/onboarding-unit-tests-add-network-m…
tmashuang Mar 31, 2023
2210fda
Merge branch 'develop' into 17191/onboarding-unit-tests-add-network-m…
tmashuang Apr 1, 2023
9f18af6
Merge branch 'develop' into 17191/onboarding-unit-tests-add-network-m…
tmashuang Apr 3, 2023
73bb00c
Merge branch 'develop' into 17191/onboarding-unit-tests-add-network-m…
tmashuang Apr 5, 2023
5fb9cc1
Merge branch 'develop' into 17191/onboarding-unit-tests-add-network-m…
tmashuang Apr 6, 2023
c773903
Merge branch 'develop' into 17191/onboarding-unit-tests-add-network-m…
tmashuang Apr 7, 2023
fbd8458
Merge branch 'develop' into 17191/onboarding-unit-tests-add-network-m…
tmashuang Apr 12, 2023
e6c089e
Merge branch 'develop' into 17191/onboarding-unit-tests-add-network-m…
tmashuang Apr 12, 2023
e2e36a4
Merge branch 'develop' into 17191/onboarding-unit-tests-add-network-m…
tmashuang Apr 13, 2023
2b89f7f
Merge branch 'develop' into 17191/onboarding-unit-tests-add-network-m…
tmashuang Apr 17, 2023
6835d7e
Merge branch 'develop' into 17191/onboarding-unit-tests-add-network-m…
tmashuang Apr 17, 2023
e4c5d69
Merge branch 'develop' into 17191/onboarding-unit-tests-add-network-m…
tmashuang Apr 17, 2023
d2904f3
Merge branch 'develop' into 17191/onboarding-unit-tests-add-network-m…
tmashuang Apr 18, 2023
42316ae
Merge branch 'develop' into 17191/onboarding-unit-tests-add-network-m…
tmashuang Apr 19, 2023
ef2ba89
Merge branch 'develop' into 17191/onboarding-unit-tests-add-network-m…
tmashuang Apr 20, 2023
935d0fd
Merge branch 'develop' into 17191/onboarding-unit-tests-add-network-m…
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
@@ -0,0 +1,241 @@
// Jest Snapshot v1, https://goo.gl/fbAQLP

exports[`Add Network Modal should render 1`] = `
<div>
<div
class="box box--padding-top-4 box--flex-direction-row"
>
<h4
class="box box--margin-top-1 box--margin-bottom-1 box--flex-direction-row typography typography--h4 typography--weight-bold typography--style-normal typography--align-center typography--color-text-default"
>
Add custom network
</h4>
</div>
<div
class="networks-tab__add-network-form networks-tab__restrict-height"
>
<div
class="actionable-message actionable-message--warning actionable-message--with-right-button networks-tab__add-network-form__alert actionable-message--with-icon"
>
<svg
viewBox="0 0 10 10"
xmlns="http://www.w3.org/2000/svg"
>
<path
d="M5 0C2.2 0 0 2.2 0 5s2.2 5 5 5 5-2.2 5-5-2.2-5-5-5zm0 2c.4 0 .7.3.7.7s-.3.7-.7.7-.7-.2-.7-.6.3-.8.7-.8zm.7 6H4.3V4.3h1.5V8z"
fill="var(--color-warning-default)"
/>
</svg>

<div
class="actionable-message__message"
>
A malicious network provider can lie about the state of the blockchain and record your network activity. Only add custom networks you trust.
</div>
</div>
<div
class="networks-tab__add-network-form-body"
>
<div
class="form-field"
>
<label
class="box box--flex-direction-row"
>
<div
class="form-field__heading"
>
<div
class="box form-field__heading-title box--display-flex box--flex-direction-row box--align-items-baseline"
>
<h6
class="box box--margin-top-1 box--margin-bottom-1 box--display-inline-block box--flex-direction-row typography typography--h6 typography--weight-bold typography--style-normal typography--color-text-default"
>
Network name
</h6>


</div>

</div>
<input
class="form-field__input"
type="text"
value=""
/>

</label>
</div>
<div
class="form-field"
>
<label
class="box box--flex-direction-row"
>
<div
class="form-field__heading"
>
<div
class="box form-field__heading-title box--display-flex box--flex-direction-row box--align-items-baseline"
>
<h6
class="box box--margin-top-1 box--margin-bottom-1 box--display-inline-block box--flex-direction-row typography typography--h6 typography--weight-bold typography--style-normal typography--color-text-default"
>
New RPC URL
</h6>


</div>

</div>
<input
class="form-field__input"
type="text"
value=""
/>

</label>
</div>
<div
class="form-field"
>
<label
class="box box--flex-direction-row"
>
<div
class="form-field__heading"
>
<div
class="box form-field__heading-title box--display-flex box--flex-direction-row box--align-items-baseline"
>
<h6
class="box box--margin-top-1 box--margin-bottom-1 box--display-inline-block box--flex-direction-row typography typography--h6 typography--weight-bold typography--style-normal typography--color-text-default"
>
Chain ID
</h6>

<div
class="info-tooltip"
>
<div>
<div
aria-describedby="tippy-tooltip-1"
class="info-tooltip__tooltip-container"
data-original-title="null"
data-tooltipped=""
style="display: inline;"
tabindex="0"
>
<svg
viewBox="0 0 10 10"
xmlns="http://www.w3.org/2000/svg"
>
<path
d="M5 0C2.2 0 0 2.2 0 5s2.2 5 5 5 5-2.2 5-5-2.2-5-5-5zm0 2c.4 0 .7.3.7.7s-.3.7-.7.7-.7-.2-.7-.6.3-.8.7-.8zm.7 6H4.3V4.3h1.5V8z"
fill="var(--color-icon-alternative)"
/>
</svg>
</div>
</div>
</div>
</div>

</div>
<input
class="form-field__input"
type="text"
value=""
/>


</label>
</div>
<div
class="form-field"
>
<label
class="box box--flex-direction-row"
>
<div
class="form-field__heading"
>
<div
class="box form-field__heading-title box--display-flex box--flex-direction-row box--align-items-baseline"
>
<h6
class="box box--margin-top-1 box--margin-bottom-1 box--display-inline-block box--flex-direction-row typography typography--h6 typography--weight-bold typography--style-normal typography--color-text-default"
>
Currency symbol
</h6>


</div>

</div>
<input
class="form-field__input"
type="text"
value=""
/>

</label>
</div>
<div
class="form-field"
>
<label
class="box box--flex-direction-row"
>
<div
class="form-field__heading"
>
<div
class="box form-field__heading-title box--display-flex box--flex-direction-row box--align-items-baseline"
>
<h6
class="box box--margin-top-1 box--margin-bottom-1 box--display-inline-block box--flex-direction-row typography typography--h6 typography--weight-bold typography--style-normal typography--color-text-default"
>
Block explorer URL
</h6>
<h6
class="box box--margin-top-1 box--margin-bottom-1 box--display-inline-block box--flex-direction-row typography typography--h6 typography--weight-normal typography--style-normal typography--color-text-alternative"
>
(Optional)
</h6>

</div>

</div>
<input
class="form-field__input"
type="text"
value=""
/>

</label>
</div>
</div>
<div
class="networks-tab__add-network-form-footer"
>
<button
class="button btn--rounded btn-secondary"
role="button"
tabindex="0"
>
Cancel
</button>
<button
class="button btn--rounded btn-primary"
disabled=""
role="button"
tabindex="0"
>
Save
</button>
</div>
</div>
</div>
`;

exports[`Add Network Modal should render 2`] = `<div />`;
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
import React from 'react';
import { fireEvent, waitFor } from '@testing-library/react';
import configureMockStore from 'redux-mock-store';
import thunk from 'redux-thunk';
import { renderWithProvider } from '../../../../test/lib/render-helpers';
import AddNetworkModal from '.';

const mockHideModal = jest.fn();
jest.mock('../../../store/actions', () => ({
...jest.requireActual('../../../store/actions'),
hideModal: () => mockHideModal,
}));

describe('Add Network Modal', () => {
it('should render', async () => {
const mockStore = configureMockStore()();
const { container } = renderWithProvider(<AddNetworkModal />, mockStore);

await waitFor(() => {
expect(container).toMatchSnapshot();
});
});

it('should handle callback', async () => {
const mockStore = configureMockStore([thunk])();
const { queryByText } = renderWithProvider(<AddNetworkModal />, mockStore);

const cancelButton = queryByText('Cancel');
fireEvent.click(cancelButton);

await waitFor(() => {
expect(mockHideModal).toHaveBeenCalledTimes(1);
});
});
});