1
0
mirror of https://github.com/kremalicious/metamask-extension.git synced 2024-11-23 10:30:04 +01:00
metamask-extension/ui/pages/settings/snaps/view-snap/view-snap.test.js
Olaf Tomalka 95c37e1ba3
feat: add yaml feature management (#18125)
* feat: add yaml feature management

Add yaml feature file per build type.
Also add method to parse yaml and set
enabled features env to true. The build
process will then replace any process.env[feature]
that exists on the config by its value

* chore: add example for desktop

* Added initial draft of build features

* [TMP] Sync between computers

* Is able to succesfully build stable extension with snaps feature

* Removing var context from builds.yml

* Add asssets to builds.yml

* Minor bug fixes and removing debug logs

* [WIP] Test changes

* Removed TODOs

* Fix regession bug

Also
* remove debug logs
* merge Variables.set and Variables.setMany with an overload

* Fix build, lint and a bunch of issues

* Update LavaMoat policies

* Re-add desktop build type

* Fix some tests

* Fix desktop build

* Define some env variables used by MV3

* Fix lint

* Fix remove-fenced-code tests

* Fix README typo

* Move new code

* Fix missing asset copy

* Move Jest env setup

* Fix path for test after rebase

* Fix code fences

* Fix fencing and LavaMoat policies

* Fix MMI code-fencing after rebase

* Fix MMI code fencing after merge

* Fix more MMI code fencing

---------

Co-authored-by: cryptotavares <joao.tavares@consensys.net>
Co-authored-by: Frederik Bolding <frederik.bolding@gmail.com>
Co-authored-by: Brad Decker <bhdecker84@gmail.com>
2023-04-25 16:32:51 +02:00

82 lines
2.5 KiB
JavaScript
Raw Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

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 its 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',
);
});
});