mirror of
https://github.com/kremalicious/metamask-extension.git
synced 2024-12-02 14:15:06 +01:00
ff96836871
* Add updated version of the Snaps list UI Add more changes to match the designs of snaps list Add next design iteration for snaps list Update icons, sizes and pointer behaviour Add redesign for snap settings page Refactor and improve designs Fix unit tests and refactor code Fix e2e test Fix lint Update margin values Add CSS override for connected sites list and update margins Update paddings as requested Fix vertical alignment of links Fix tooltip position on the enable button Add usage of getSnapName function for displaying snap names Fix e2e tests and update date format for snap install date Improve unit test for snap-settings-card Change installation info logic Update mocked state for snap Add tests for ViewSnap component, refactor and update mocked state Add check for version info Change Snaps icon in Settings Refactor Snaps list to use selector Add handling in case of missing version history * Fix icon ref * Remove console logs * Remove onClick from selector * Add code fencing for imports in selectors.js
82 lines
2.5 KiB
JavaScript
82 lines
2.5 KiB
JavaScript
import * as React from 'react';
|
||
import configureMockStore from 'redux-mock-store';
|
||
import thunk from 'redux-thunk';
|
||
import { renderWithProvider } from '../../../../../test/lib/render-helpers';
|
||
import mockState from '../../../../../test/data/mock-state.json';
|
||
import ViewSnap from './view-snap';
|
||
|
||
jest.mock('../../../../store/actions.ts', () => {
|
||
return {
|
||
disableSnap: jest.fn(),
|
||
enableSnap: jest.fn(),
|
||
removeSnap: jest.fn(),
|
||
removePermissionsFor: jest.fn(),
|
||
updateCaveat: jest.fn(),
|
||
};
|
||
});
|
||
|
||
jest.mock('react-router-dom', () => {
|
||
const original = jest.requireActual('react-router-dom');
|
||
return {
|
||
...original,
|
||
useLocation: jest.fn(() => ({
|
||
pathname: `/settings/snaps-view/${encodeURIComponent(
|
||
'npm:@metamask/test-snap-bip44',
|
||
)}`,
|
||
})),
|
||
};
|
||
});
|
||
|
||
const mockStore = configureMockStore([thunk])(mockState);
|
||
|
||
describe('ViewSnap', () => {
|
||
it('should properly display Snap View elements', async () => {
|
||
const { getByText, container, getByRole } = renderWithProvider(
|
||
<ViewSnap />,
|
||
mockStore,
|
||
);
|
||
|
||
// Snap name & Snap authorship component
|
||
expect(getByText('BIP-44 Test Snap')).toBeDefined();
|
||
expect(container.getElementsByClassName('snaps-authorship')?.length).toBe(
|
||
1,
|
||
);
|
||
// Snap description
|
||
expect(
|
||
getByText('An example Snap that signs messages using BLS.'),
|
||
).toBeDefined();
|
||
// Snap version info
|
||
expect(getByText('v5.1.2')).toBeDefined();
|
||
// Enable Snap
|
||
expect(getByText('Enable snap')).toBeDefined();
|
||
expect(
|
||
getByText(
|
||
'Your installed snap will only have access to its permissions and run if it’s enabled.',
|
||
),
|
||
).toBeDefined();
|
||
expect(container.getElementsByClassName('toggle-button')?.length).toBe(1);
|
||
// Permissions
|
||
expect(getByText('Permissions')).toBeDefined();
|
||
expect(
|
||
container.getElementsByClassName('snap-permissions-list')?.length,
|
||
).toBe(1);
|
||
// Connected sites
|
||
expect(getByText('Connected sites')).toBeDefined();
|
||
expect(
|
||
container.getElementsByClassName('connected-sites-list__content-rows')
|
||
?.length,
|
||
).toBe(1);
|
||
// Remove snap
|
||
expect(getByText('Remove snap')).toBeDefined();
|
||
expect(
|
||
getByText(
|
||
'This action will delete the snap, its data and revoke your given permissions.',
|
||
),
|
||
).toBeDefined();
|
||
expect(getByText('Remove BIP-44 Test Snap')).toBeDefined();
|
||
expect(getByRole('button')).toHaveClass(
|
||
'button btn--rounded btn-danger view-snap__remove-button',
|
||
);
|
||
});
|
||
});
|