password.stories.js 1.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748
  1. import useFetchMock from '../hooks/use-fetch-mock'
  2. import PasswordSection from '../../js/features/settings/components/password-section'
  3. import { setDefaultMeta, defaultSetupMocks } from './helpers/password'
  4. export const Success = args => {
  5. setDefaultMeta()
  6. useFetchMock(defaultSetupMocks)
  7. return <PasswordSection {...args} />
  8. }
  9. export const ManagedExternally = args => {
  10. setDefaultMeta()
  11. window.metaAttributesCache.set('ol-ExposedSettings', {
  12. isOverleaf: false,
  13. })
  14. window.metaAttributesCache.set('ol-isExternalAuthenticationSystemUsed', true)
  15. useFetchMock(defaultSetupMocks)
  16. return <PasswordSection {...args} />
  17. }
  18. export const NoExistingPassword = args => {
  19. setDefaultMeta()
  20. window.metaAttributesCache.set('ol-hasPassword', false)
  21. useFetchMock(defaultSetupMocks)
  22. return <PasswordSection {...args} />
  23. }
  24. export const Error = args => {
  25. setDefaultMeta()
  26. useFetchMock(fetchMock =>
  27. fetchMock.post(/\/user\/password\/update/, {
  28. status: 400,
  29. body: {
  30. message: 'Your old password is wrong',
  31. },
  32. })
  33. )
  34. return <PasswordSection {...args} />
  35. }
  36. export default {
  37. title: 'Account Settings / Password',
  38. component: PasswordSection,
  39. }