-
Notifications
You must be signed in to change notification settings - Fork 305
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
fix(metadata-sidebar): Fix metadata sidebar ai capabilities (#3681)
* fix(metadata-sidebar): Check if AI Suggestion are enabled feature * fix(metadata-sidebar): Fix storybook test * fix(metadata-sidebar): Spread mockFeatures instead of duplication Co-authored-by: greg-in-a-box <103291617+greg-in-a-box@users.noreply.github.com> * feat(metadata-sidebar): Select only one button as only one is used * feat(metadata-sidebar): Add FeatureProvider to test-utils --------- Co-authored-by: greg-in-a-box <103291617+greg-in-a-box@users.noreply.github.com>
- Loading branch information
1 parent
305d3af
commit fd164ec
Showing
4 changed files
with
54 additions
and
24 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,22 +1,30 @@ | ||
import React from 'react'; | ||
import { render } from '@testing-library/react'; | ||
import { render, type RenderOptions } from '@testing-library/react'; | ||
|
||
// Data Providers | ||
import { TooltipProvider } from '@box/blueprint-web'; | ||
import { IntlProvider } from 'react-intl'; | ||
import { AutofillContextProvider } from '@box/metadata-editor'; | ||
import { FeatureProvider } from '../elements/common/feature-checking'; | ||
|
||
jest.unmock('react-intl'); | ||
|
||
const Wrapper = ({ children }) => ( | ||
<AutofillContextProvider isAiSuggestionsFeatureEnabled={false} fetchSuggestions={() => Promise.resolve([])}> | ||
<TooltipProvider> | ||
<IntlProvider locale="en">{children}</IntlProvider> | ||
</TooltipProvider> | ||
const Wrapper = ({ children, features = {}, isAiSuggestionsFeatureEnabled = false, fetchSuggestions = () => Promise.resolve([]) }) => ( | ||
<AutofillContextProvider isAiSuggestionsFeatureEnabled={isAiSuggestionsFeatureEnabled} fetchSuggestions={fetchSuggestions}> | ||
<FeatureProvider features={features}> | ||
<TooltipProvider> | ||
<IntlProvider locale="en">{children}</IntlProvider> | ||
</TooltipProvider> | ||
</FeatureProvider> | ||
</AutofillContextProvider> | ||
); | ||
|
||
const renderConnected = (element, options = {}) => render(element, { wrapper: Wrapper, ...options }); | ||
type RenderConnectedOptions = Omit<RenderOptions, 'wrapper'> & { | ||
wrapperProps?: Record<string, unknown>; | ||
}; | ||
|
||
const renderConnected = (element, options: RenderConnectedOptions = {}) => | ||
render(element, { wrapper: props => <Wrapper {...props} {...options.wrapperProps} />, ...options }); | ||
|
||
export * from '@testing-library/react'; | ||
export { renderConnected as render }; |