split-test-badge.stories.js 3.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137
  1. import SplitTestBadge from '../js/shared/components/split-test-badge'
  2. import { ScopeDecorator } from './decorators/scope'
  3. import { SplitTestContext } from '../js/shared/context/split-test-context'
  4. const splitTestContextValue = {
  5. splitTestVariants: {
  6. 'storybook-test': 'active',
  7. },
  8. splitTestInfo: {
  9. 'storybook-test': {
  10. phase: 'alpha',
  11. badgeInfo: {
  12. url: '/alpha/participate',
  13. tooltipText: 'This is an alpha feature',
  14. },
  15. },
  16. },
  17. }
  18. export const Alpha = args => {
  19. splitTestContextValue.splitTestVariants = {
  20. 'storybook-test': 'active',
  21. }
  22. splitTestContextValue.splitTestInfo = {
  23. 'storybook-test': {
  24. phase: 'alpha',
  25. badgeInfo: {
  26. url: '/alpha/participate',
  27. tooltipText: 'This is an alpha feature',
  28. },
  29. },
  30. }
  31. return <SplitTestBadge {...args} />
  32. }
  33. export const AlphaNotDisplayed = args => {
  34. splitTestContextValue.splitTestVariants = {
  35. 'storybook-test': 'default',
  36. }
  37. splitTestContextValue.splitTestInfo = {
  38. 'storybook-test': {
  39. phase: 'alpha',
  40. badgeInfo: {
  41. url: '/alpha/participate',
  42. tooltipText: 'This is an alpha feature',
  43. },
  44. },
  45. }
  46. return <SplitTestBadge {...args} />
  47. }
  48. export const Beta = args => {
  49. splitTestContextValue.splitTestVariants = {
  50. 'storybook-test': 'active',
  51. }
  52. splitTestContextValue.splitTestInfo = {
  53. 'storybook-test': {
  54. phase: 'beta',
  55. badgeInfo: {
  56. url: '/beta/participate',
  57. tooltipText: 'This is a beta feature',
  58. },
  59. },
  60. }
  61. return <SplitTestBadge {...args} />
  62. }
  63. export const BetaNotDisplayed = args => {
  64. splitTestContextValue.splitTestVariants = {
  65. 'storybook-test': 'default',
  66. }
  67. splitTestContextValue.splitTestInfo = {
  68. 'storybook-test': {
  69. phase: 'beta',
  70. badgeInfo: {
  71. url: '/beta/participate',
  72. tooltipText: 'This is a beta feature',
  73. },
  74. },
  75. }
  76. return <SplitTestBadge {...args} />
  77. }
  78. export const Release = args => {
  79. splitTestContextValue.splitTestVariants = {
  80. 'storybook-test': 'active',
  81. }
  82. splitTestContextValue.splitTestInfo = {
  83. 'storybook-test': {
  84. phase: 'release',
  85. badgeInfo: {
  86. url: '/feedback/form',
  87. tooltipText: 'This is a new feature',
  88. },
  89. },
  90. }
  91. return <SplitTestBadge {...args} />
  92. }
  93. export const ReleaseNotDisplayed = args => {
  94. splitTestContextValue.splitTestVariants = {
  95. 'storybook-test': 'default',
  96. }
  97. splitTestContextValue.splitTestInfo = {
  98. 'storybook-test': {
  99. phase: 'release',
  100. badgeInfo: {
  101. url: '/feedback/form',
  102. tooltipText: 'This is a new feature',
  103. },
  104. },
  105. }
  106. return <SplitTestBadge {...args} />
  107. }
  108. export default {
  109. title: 'Shared / Components / Split Test Badge',
  110. component: SplitTestBadge,
  111. args: {
  112. splitTestName: 'storybook-test',
  113. displayOnVariants: ['active'],
  114. },
  115. decorators: [
  116. (Story, context) => (
  117. <SplitTestContext.Provider value={splitTestContextValue}>
  118. <Story />
  119. </SplitTestContext.Provider>
  120. ),
  121. ScopeDecorator,
  122. ],
  123. }