diff --git a/src/elements/content-sidebar/SidebarNavSign.tsx b/src/elements/content-sidebar/SidebarNavSign.tsx index 46a0981af3..6f91a8eb18 100644 --- a/src/elements/content-sidebar/SidebarNavSign.tsx +++ b/src/elements/content-sidebar/SidebarNavSign.tsx @@ -25,40 +25,27 @@ export function SidebarNavSign() { onClickSignMyself: onBoxClickSignMyself, status: boxSignStatus, targetingApi: boxSignTargetingApi, - isSignRemoveInterstitialEnabled, } = useFeatureConfig('boxSign'); return ( - <> - {isSignRemoveInterstitialEnabled ? ( - - - - - - - - - - - - - - ) : ( - - )} - + + + + + + + + + + + + + ); } diff --git a/src/elements/content-sidebar/__tests__/SidebarNavSign.test.tsx b/src/elements/content-sidebar/__tests__/SidebarNavSign.test.tsx index 35a1792279..940fca11c1 100644 --- a/src/elements/content-sidebar/__tests__/SidebarNavSign.test.tsx +++ b/src/elements/content-sidebar/__tests__/SidebarNavSign.test.tsx @@ -1,80 +1,75 @@ import * as React from 'react'; import { render, fireEvent } from '@testing-library/react'; +import { IntlProvider } from 'react-intl'; import SidebarNavSign from '../SidebarNavSign'; // @ts-ignore Module is written in Flow import FeatureProvider from '../../common/feature-checking/FeatureProvider'; +// @ts-ignore Module is written in Flow +import messages from '../messages'; +// @ts-ignore Module is written in Flow +import localize from '../../../../test/support/i18n.js'; + +jest.unmock('react-intl'); describe('elements/content-sidebar/SidebarNavSign', () => { const onClickRequestSignature = jest.fn(); const onClickSignMyself = jest.fn(); + const signLabel = localize(messages.boxSignRequestSignature.id); + const requestSignatureButtonText = localize(messages.boxSignRequestSignature.id); + const signMyselfButtonText = localize(messages.boxSignSignMyself.id); const renderComponent = (props = {}, features = {}) => render( , + { + wrapper: ({ children }: { children?: React.ReactNode }) => ( + {children} + ), + }, ); - test.each([true, false])('should render sign button', isRemoveInterstitialEnabled => { - const features = { - boxSign: { - isSignRemoveInterstitialEnabled: isRemoveInterstitialEnabled, - }, - }; + test('should render sign button', () => { + const wrapper = renderComponent(); - const wrapper = renderComponent({}, features); - expect(wrapper.getByTestId('sign-button')).toBeVisible(); + expect(wrapper.getByLabelText(signLabel)).toBeVisible(); }); - test('should call correct handler when sign button is clicked', () => { - const features = { - boxSign: { - isSignRemoveInterstitialEnabled: false, - onClick: onClickRequestSignature, - }, - }; - const { getByTestId } = renderComponent({}, features); - - fireEvent.click(getByTestId('sign-button')); + test('should open dropdown with 2 menu items when sign button is clicked', () => { + const wrapper = renderComponent(); - expect(onClickRequestSignature).toBeCalled(); - }); + fireEvent.click(wrapper.getByLabelText(signLabel)); - test('should open dropdown with 2 menu items when sign button is clicked', () => { - const features = { - boxSign: { - isSignRemoveInterstitialEnabled: true, - }, - }; - const { getByTestId } = renderComponent({}, features); - fireEvent.click(getByTestId('sign-button')); - expect(getByTestId('sign-request-signature-button')).toBeVisible(); - expect(getByTestId('sign-sign-myself-button')).toBeVisible(); + expect(wrapper.getByText(requestSignatureButtonText)).toBeVisible(); + expect(wrapper.getByText(signMyselfButtonText)).toBeVisible(); }); test('should call correct handler when request signature option is clicked', () => { const features = { boxSign: { - isSignRemoveInterstitialEnabled: true, onClick: onClickRequestSignature, }, }; - const { getByTestId } = renderComponent({}, features); - fireEvent.click(getByTestId('sign-button')); - fireEvent.click(getByTestId('sign-request-signature-button')); + const wrapper = renderComponent({}, features); + + fireEvent.click(wrapper.getByLabelText(signLabel)); + fireEvent.click(wrapper.getByText(requestSignatureButtonText)); + expect(onClickRequestSignature).toBeCalled(); }); test('should call correct handler when sign myself option is clicked', () => { const features = { boxSign: { - isSignRemoveInterstitialEnabled: true, onClickSignMyself, }, }; - const { getByTestId } = renderComponent({}, features); - fireEvent.click(getByTestId('sign-button')); - fireEvent.click(getByTestId('sign-sign-myself-button')); + const wrapper = renderComponent({}, features); + + fireEvent.click(wrapper.getByLabelText(signLabel)); + fireEvent.click(wrapper.getByText(signMyselfButtonText)); + expect(onClickSignMyself).toBeCalled(); }); });