mirror of
https://github.com/kremalicious/metamask-extension.git
synced 2024-12-11 20:27:12 +01:00
cdc1bce688
* refactor class to functional component * update messages * fix: use classnames * feat: add hold to reveal modal * feat: add new zendesk url for secret recovery phrase and noncustodial wallet * update: clipboard to clear copied text after delay * fix: remove save to csv * feat: update styles for reveal seed page * fix: update reveal seed snapshot * add test to check for modal * fix: lint * fix: unused messages locale * fix: use new banner component * fix: use new button from design system * fix: update snapshot * fix: lint * revert text * fix: lint * fix: remove --copy-only * fix: marginBottom prop value * fix: iconName and prop error * --made the QR code slightly smaller so it's less likely to have a scrollbar --updated the snapshots * fix: error message not displaying * SRP hold to reveal using more DS components (#17583) * Updating to add DS components and remove CSS * Fixing rendered html and removing some unneeded props * fix: set block to true --------- Co-authored-by: Monte <monte.lai@consensys.net> * fix: add descriptions to messages * Update ui/components/ui/export-text-container/export-text-container.component.js fix: lint Co-authored-by: HowardBraham <HowardBraham@users.noreply.github.com> * fix: remove using displayWarning in requestRevealSeedWords * fix: update test to remove displayError * fix: update design system enums * fix: messages descriptions * fix: banner to banneralert * fix: update preview * add additional tests * fix: use jest instead of sinon * add test if long press isn't completed * add test if password is wrong --------- Co-authored-by: Howard Braham <howrad@gmail.com> Co-authored-by: George Marshall <george.marshall@consensys.net>
115 lines
3.3 KiB
JavaScript
115 lines
3.3 KiB
JavaScript
import React from 'react';
|
|
import configureMockState from 'redux-mock-store';
|
|
import { fireEvent, waitFor } from '@testing-library/react';
|
|
import thunk from 'redux-thunk';
|
|
import { renderWithProvider } from '../../../../../test/lib/render-helpers';
|
|
import mockState from '../../../../../test/data/mock-state.json';
|
|
import {
|
|
holdToRevealContent1,
|
|
holdToRevealContent2,
|
|
holdToRevealContent3,
|
|
holdToRevealContent4,
|
|
holdToRevealContent5,
|
|
holdToRevealTitle,
|
|
} from '../../../../../app/_locales/en/messages.json';
|
|
import HoldToRevealModal from '.';
|
|
|
|
const mockShowModal = jest.fn();
|
|
|
|
jest.mock('../../../../store/actions.ts', () => {
|
|
return {
|
|
showModal: () => mockShowModal,
|
|
};
|
|
});
|
|
|
|
describe('Hold to Reveal Modal', () => {
|
|
const mockStore = configureMockState([thunk])(mockState);
|
|
const onLongPressStub = jest.fn().mockResolvedValue();
|
|
const hideModalStub = jest.fn().mockResolvedValue();
|
|
|
|
global.platform = { openTab: jest.fn() };
|
|
|
|
it('should render the srp warning text and button', () => {
|
|
const { getByText } = renderWithProvider(
|
|
<HoldToRevealModal
|
|
onLongPressed={onLongPressStub}
|
|
hideModal={hideModalStub}
|
|
/>,
|
|
mockStore,
|
|
);
|
|
|
|
const holdButton = getByText('Hold to reveal SRP');
|
|
expect(holdButton).toBeInTheDocument();
|
|
|
|
const warningTitle = getByText(holdToRevealTitle.message);
|
|
expect(warningTitle).toBeInTheDocument();
|
|
const warningText1 = getByText(
|
|
holdToRevealContent1.message.replace(' $1', ''),
|
|
);
|
|
expect(warningText1).toBeInTheDocument();
|
|
|
|
const warningText2 = getByText(holdToRevealContent2.message);
|
|
expect(warningText2).toBeInTheDocument();
|
|
|
|
const warningText3 = getByText(
|
|
holdToRevealContent3.message.replace(' $1 $2', ''),
|
|
);
|
|
expect(warningText3).toBeInTheDocument();
|
|
|
|
const warningText4 = getByText(holdToRevealContent4.message);
|
|
expect(warningText4).toBeInTheDocument();
|
|
|
|
const warningText5 = getByText(holdToRevealContent5.message);
|
|
expect(warningText5).toBeInTheDocument();
|
|
|
|
fireEvent.click(holdButton);
|
|
|
|
expect(holdButton).toBeDefined();
|
|
|
|
fireEvent.mouseUp(holdButton);
|
|
|
|
expect(holdButton).toBeDefined();
|
|
});
|
|
|
|
it('should should execute onLongPressed after long press', async () => {
|
|
const { getByText } = renderWithProvider(
|
|
<HoldToRevealModal
|
|
onLongPressed={onLongPressStub}
|
|
hideModal={hideModalStub}
|
|
/>,
|
|
mockStore,
|
|
);
|
|
|
|
const holdButton = getByText('Hold to reveal SRP');
|
|
waitFor(() => {
|
|
expect(holdButton.firstChild).toHaveClass(
|
|
'hold-to-reveal-button__unlock-icon-container',
|
|
);
|
|
expect(onLongPressStub.callCount).toBe(1);
|
|
expect(hideModalStub.callCount).toBe(1);
|
|
});
|
|
});
|
|
|
|
it('should remain open if long pressed was not complete', async () => {
|
|
const { getByText } = renderWithProvider(
|
|
<HoldToRevealModal
|
|
onLongPressed={onLongPressStub}
|
|
hideModal={hideModalStub}
|
|
/>,
|
|
mockStore,
|
|
);
|
|
|
|
const holdButton = getByText('Hold to reveal SRP');
|
|
waitFor(
|
|
() => {
|
|
expect(holdButton.firstChild).toHaveClass(
|
|
'hold-to-reveal-button__unlock-icon-container',
|
|
);
|
|
expect(onLongPressStub.callCount).toBe(0);
|
|
expect(hideModalStub.callCount).toBe(0);
|
|
},
|
|
{ interval: 100 },
|
|
);
|
|
});
|
|
});
|