mirror of
https://github.com/yu-i-i/overleaf-cep.git
synced 2025-07-26 05:00:06 +02:00

[web] Clean up localized currency format test (`local-ccy-format-v2`) GitOrigin-RevId: 30d671479522b87ee9205994508b745d2b0ae4c3
34 lines
1.1 KiB
TypeScript
34 lines
1.1 KiB
TypeScript
import type { Meta } from '@storybook/react'
|
|
import _ from 'lodash'
|
|
import { SplitTestContext } from '../../frontend/js/shared/context/split-test-context'
|
|
|
|
export const splitTestsArgTypes = {
|
|
// to be able to use this utility, you need to add the argTypes for each split test in this object
|
|
// Check the original implementation for an example: https://github.com/overleaf/internal/pull/17809
|
|
}
|
|
|
|
export const withSplitTests = (
|
|
story: Meta,
|
|
splitTests: (keyof typeof splitTestsArgTypes)[] = []
|
|
): Meta => {
|
|
return {
|
|
...story,
|
|
argTypes: { ...story.argTypes, ..._.pick(splitTestsArgTypes, splitTests) },
|
|
decorators: [
|
|
(Story, { args }) => {
|
|
const splitTestVariants = _.pick(args, splitTests)
|
|
const value = { splitTestVariants, splitTestInfo: {} }
|
|
return (
|
|
<SplitTestContext.Provider value={value}>
|
|
<Story />
|
|
</SplitTestContext.Provider>
|
|
)
|
|
},
|
|
...(story.decorators
|
|
? Array.isArray(story.decorators)
|
|
? story.decorators
|
|
: [story.decorators]
|
|
: []),
|
|
],
|
|
}
|
|
}
|