1
0
mirror of https://github.com/kremalicious/metamask-extension.git synced 2024-12-23 09:52:26 +01:00
metamask-extension/ui/components/app/whats-new-popup/whats-new-popup.test.js

139 lines
3.3 KiB
JavaScript
Raw Normal View History

import React from 'react';
import { screen } from '@testing-library/react';
import { renderWithProvider } from '../../../../test/jest';
import configureStore from '../../../store/store';
import mockState from '../../../../test/data/mock-state.json';
import WhatsNewPopup from './whats-new-popup';
const render = () => {
const store = configureStore({
metamask: {
...mockState.metamask,
announcements: {
1: {
date: '2021-03-17',
id: 1,
image: {
height: '230px',
placeImageBelowDescription: true,
src: 'images/mobile-link-qr.svg',
width: '230px',
},
isShown: false,
},
3: {
date: '2021-03-08',
id: 3,
isShown: false,
},
4: {
date: '2021-05-11',
id: 4,
image: {
src: 'images/source-logos-bsc.svg',
width: '100%',
},
isShown: false,
},
5: {
date: '2021-06-09',
id: 5,
isShown: false,
},
6: {
date: '2021-05-26',
id: 6,
isShown: false,
},
7: {
date: '2021-09-17',
id: 7,
isShown: false,
},
8: {
date: '2021-11-01',
id: 8,
isShown: false,
},
9: {
date: '2021-12-07',
id: 9,
image: {
src: 'images/txinsights.png',
width: '80%',
},
isShown: false,
},
10: {
date: '2022-04-18',
id: 10,
image: {
src: 'images/token-detection.svg',
width: '100%',
},
isShown: true,
},
11: {
date: '2022-04-18',
id: 11,
isShown: true,
},
12: {
date: '2022-05-18',
id: 12,
image: {
src: 'images/darkmode-banner.png',
width: '100%',
},
isShown: false,
},
13: {
date: '2022-07-12',
id: 13,
isShown: true,
},
Whats new blockaid popup (#20071) * deprecate opensea security alerts check Signedoff-by: Olusegun Akintayo <akintayo.segun@gmail.com> set metrics to [] Signed-off-by: Olusegun Akintayo <akintayo.segun@gmail.com> fix jest tests Signed-off-by: Olusegun Akintayo <akintayo.segun@gmail.com> Remove sec provider spec Signed-off-by: Olusegun Akintayo <akintayo.segun@gmail.com> lint fix Signed-off-by: Olusegun Akintayo <akintayo.segun@gmail.com> What's new for blockaid...with placeholder texts Signed-off-by: Olusegun Akintayo <akintayo.segun@gmail.com> i18n Signed-off-by: Olusegun Akintayo <akintayo.segun@gmail.com> lint fixes Rebase to develop Add image to whatsnew blockaid. Signed-off-by: Olusegun Akintayo <akintayo.segun@gmail.com> Fixed i18n Fixed snapshot for ui/pages/settings/experimental-tab/experimental-tab.test.js Signed-off-by: Olusegun Akintayo <akintayo.segun@gmail.com> Fix i18n messages Signed-off-by: Olusegun Akintayo <akintayo.segun@gmail.com> lint fixes Signed-off-by: Olusegun Akintayo <akintayo.segun@gmail.com> Add unit tests Lint fixes use new image that works for both dark and light mode 22 is taken Signed-off-by: Olusegun Akintayo <akintayo.segun@gmail.com> * comment out blockaid Signed-off-by: Olusegun Akintayo <akintayo.segun@gmail.com> * rever change in builds.yml Signed-off-by: Olusegun Akintayo <akintayo.segun@gmail.com> * reverted changes in test/e2e/tests/security-provider.spec.js * fix unit test Signed-off-by: Olusegun Akintayo <akintayo.segun@gmail.com> --------- Signed-off-by: Olusegun Akintayo <akintayo.segun@gmail.com>
2023-08-02 17:14:02 +02:00
23: {
date: '2022-07-24',
id: 23,
isShown: false,
},
},
},
});
return renderWithProvider(<WhatsNewPopup />, store);
};
describe('WhatsNewPopup', () => {
beforeEach(() => {
const mockIntersectionObserver = jest.fn();
mockIntersectionObserver.mockReturnValue({
observe: () => null,
unobserve: () => null,
disconnect: () => null,
});
window.IntersectionObserver = mockIntersectionObserver;
});
it("renders WhatsNewPopup component and shows What's new text", () => {
render();
expect(screen.getByText("What's new")).toBeInTheDocument();
});
it('renders WhatsNewPopup component and shows close button', () => {
render();
expect(screen.getByTestId('popover-close')).toBeInTheDocument();
});
Whats new blockaid popup (#20071) * deprecate opensea security alerts check Signedoff-by: Olusegun Akintayo <akintayo.segun@gmail.com> set metrics to [] Signed-off-by: Olusegun Akintayo <akintayo.segun@gmail.com> fix jest tests Signed-off-by: Olusegun Akintayo <akintayo.segun@gmail.com> Remove sec provider spec Signed-off-by: Olusegun Akintayo <akintayo.segun@gmail.com> lint fix Signed-off-by: Olusegun Akintayo <akintayo.segun@gmail.com> What's new for blockaid...with placeholder texts Signed-off-by: Olusegun Akintayo <akintayo.segun@gmail.com> i18n Signed-off-by: Olusegun Akintayo <akintayo.segun@gmail.com> lint fixes Rebase to develop Add image to whatsnew blockaid. Signed-off-by: Olusegun Akintayo <akintayo.segun@gmail.com> Fixed i18n Fixed snapshot for ui/pages/settings/experimental-tab/experimental-tab.test.js Signed-off-by: Olusegun Akintayo <akintayo.segun@gmail.com> Fix i18n messages Signed-off-by: Olusegun Akintayo <akintayo.segun@gmail.com> lint fixes Signed-off-by: Olusegun Akintayo <akintayo.segun@gmail.com> Add unit tests Lint fixes use new image that works for both dark and light mode 22 is taken Signed-off-by: Olusegun Akintayo <akintayo.segun@gmail.com> * comment out blockaid Signed-off-by: Olusegun Akintayo <akintayo.segun@gmail.com> * rever change in builds.yml Signed-off-by: Olusegun Akintayo <akintayo.segun@gmail.com> * reverted changes in test/e2e/tests/security-provider.spec.js * fix unit test Signed-off-by: Olusegun Akintayo <akintayo.segun@gmail.com> --------- Signed-off-by: Olusegun Akintayo <akintayo.segun@gmail.com>
2023-08-02 17:14:02 +02:00
it('renders WhatsNewPopup component and shows blockaid messages', () => {
render();
expect(
screen.getByTestId('whats-new-description-item-0'),
).toBeInTheDocument();
expect(
screen.getByTestId('whats-new-description-item-1'),
).toBeInTheDocument();
expect(
screen.getByTestId('whats-new-description-item-2'),
).toBeInTheDocument();
});
});