-
Notifications
You must be signed in to change notification settings - Fork 311
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
fix(content-sidebar): remove dependency on isSignRemoveInterstitialEnabled #3734
base: master
Are you sure you want to change the base?
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -33,6 +33,7 @@ import { | |
import { useFeatureConfig } from '../common/feature-checking'; | ||
import type { NavigateOptions, AdditionalSidebarTab } from './flowTypes'; | ||
import './SidebarNav.scss'; | ||
import type { SignSideBarProps } from './SidebarNavSign'; | ||
|
||
type Props = { | ||
additionalTabs?: Array<AdditionalSidebarTab>, | ||
|
@@ -49,6 +50,7 @@ type Props = { | |
isOpen?: boolean, | ||
onNavigate?: (SyntheticEvent<>, NavigateOptions) => void, | ||
onPanelChange?: (name: string, isInitialState: boolean) => void, | ||
signSideBarProps: SignSideBarProps, | ||
}; | ||
|
||
const SidebarNav = ({ | ||
|
@@ -66,8 +68,9 @@ const SidebarNav = ({ | |
isOpen, | ||
onNavigate, | ||
onPanelChange = noop, | ||
signSideBarProps, | ||
}: Props) => { | ||
const { enabled: hasBoxSign } = useFeatureConfig('boxSign'); | ||
const { enabled: hasBoxSign } = signSideBarProps || {}; | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. is there a permission via the user that enables this feature too ? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Yes, there is a user permission controlled by the admin that enables/disables signing. This is reflected in the |
||
const { disabledTooltip: boxAIDisabledTooltip, showOnlyNavButton: showOnlyBoxAINavButton } = | ||
useFeatureConfig('boxai.sidebar'); | ||
|
||
|
@@ -159,7 +162,7 @@ const SidebarNav = ({ | |
|
||
{hasBoxSign && ( | ||
<div className="bcs-SidebarNav-secondary"> | ||
<SidebarNavSign /> | ||
<SidebarNavSign {...signSideBarProps} /> | ||
</div> | ||
)} | ||
|
||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -25,11 +25,11 @@ export type Props = PlainButtonProps & { | |
|
||
export const PlaceholderTooltip = ({ children }: { children: React.ReactNode }) => children; | ||
|
||
export function SidebarNavSignButton({ blockedReason, intl, status, targetingApi, ...rest }: Props) { | ||
export function SidebarNavSignButton({ blockedReason, intl, targetingApi, ...rest }: Props) { | ||
const isSignDisabled = !!blockedReason; | ||
const isTargeted = targetingApi && targetingApi.canShow; | ||
const isTargeted = targetingApi?.canShow; | ||
const FtuxTooltip = !isSignDisabled && isTargeted ? TargetedClickThroughGuideTooltip : PlaceholderTooltip; | ||
const label = intl.formatMessage(status === 'active' ? messages.boxSignSignature : messages.boxSignRequest); | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. removed this check because status property is not being passed anymore from EUA |
||
const label = intl.formatMessage(messages.boxSignRequest); | ||
const buttonClassName = classnames('bcs-SidebarNavSignButton', { 'bdl-is-disabled': isSignDisabled }); | ||
|
||
let tooltipMessage = label; | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,80 +1,53 @@ | ||
import * as React from 'react'; | ||
import { render, fireEvent } from '@testing-library/react'; | ||
|
||
import { userEvent } from '@testing-library/user-event'; | ||
import { render, screen } from '../../../test-utils/testing-library'; | ||
import SidebarNavSign from '../SidebarNavSign'; | ||
// @ts-ignore Module is written in Flow | ||
import FeatureProvider from '../../common/feature-checking/FeatureProvider'; | ||
|
||
describe('elements/content-sidebar/SidebarNavSign', () => { | ||
const onClickRequestSignature = jest.fn(); | ||
const onClickSignMyself = jest.fn(); | ||
|
||
const renderComponent = (props = {}, features = {}) => | ||
render( | ||
<FeatureProvider features={features}> | ||
<SidebarNavSign {...props} /> | ||
</FeatureProvider>, | ||
); | ||
const defaultSignSideBarProps = { | ||
blockedReason: '', | ||
enabled: true, | ||
onClick: onClickRequestSignature, | ||
onClickSignMyself, | ||
targetingApi: null, | ||
}; | ||
|
||
const renderComponent = () => render(<SidebarNavSign {...defaultSignSideBarProps} />, {}); | ||
|
||
test.each([true, false])('should render sign button', isRemoveInterstitialEnabled => { | ||
const features = { | ||
boxSign: { | ||
isSignRemoveInterstitialEnabled: isRemoveInterstitialEnabled, | ||
}, | ||
}; | ||
test('should render sign button', async () => { | ||
renderComponent(); | ||
|
||
const wrapper = renderComponent({}, features); | ||
expect(wrapper.getByTestId('sign-button')).toBeVisible(); | ||
expect(screen.getByRole('button', { name: 'Request Signature' })).toBeInTheDocument(); | ||
}); | ||
|
||
test('should call correct handler when sign button is clicked', () => { | ||
const features = { | ||
boxSign: { | ||
isSignRemoveInterstitialEnabled: false, | ||
onClick: onClickRequestSignature, | ||
}, | ||
}; | ||
const { getByTestId } = renderComponent({}, features); | ||
test('should open dropdown with 2 menu items when sign button is clicked', async () => { | ||
renderComponent(); | ||
|
||
fireEvent.click(getByTestId('sign-button')); | ||
await userEvent.click(screen.getByRole('button', { name: 'Request Signature' })); | ||
|
||
expect(onClickRequestSignature).toBeCalled(); | ||
expect(screen.getByRole('menuitem', { name: 'Request Signature' })).toBeVisible(); | ||
expect(screen.getByRole('menuitem', { name: 'Sign Myself' })).toBeVisible(); | ||
}); | ||
|
||
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(); | ||
}); | ||
test('should call correct handler when request signature option is clicked', async () => { | ||
renderComponent(); | ||
|
||
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')); | ||
expect(onClickRequestSignature).toBeCalled(); | ||
await userEvent.click(screen.getByRole('button', { name: 'Request Signature' })); | ||
await userEvent.click(screen.getByRole('menuitem', { name: 'Request Signature' })); | ||
|
||
expect(onClickRequestSignature).toHaveBeenCalled(); | ||
}); | ||
|
||
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')); | ||
expect(onClickSignMyself).toBeCalled(); | ||
test('should call correct handler when sign myself option is clicked', async () => { | ||
renderComponent(); | ||
|
||
await userEvent.click(screen.getByRole('button', { name: 'Request Signature' })); | ||
await userEvent.click(screen.getByRole('menuitem', { name: 'Sign Myself' })); | ||
|
||
expect(onClickSignMyself).toHaveBeenCalled(); | ||
}); | ||
}); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
looks like this is alphabetize, can we alphabetize this prop too
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
updated