Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -20,8 +20,8 @@
},
"devDependencies": {
"@changesets/cli": "^2.27.11",
"@parcel/packager-ts": "latest",
"@parcel/transformer-typescript-types": "latest",
"@parcel/packager-ts": "^2.14.1",
"@parcel/transformer-typescript-types": "^2.14.1",
"@types/node": "catalog:",
"chalk": "^5.4.1",
"chokidar": "^4.0.3",
Expand Down
8 changes: 8 additions & 0 deletions packages/authentication/CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,13 @@
# @baseapp-frontend/authentication

## 4.2.2

### Patch Changes

- Unify test and storybook providers
- Updated dependencies
- @baseapp-frontend/utils@3.1.6

## 4.2.1

### Patch Changes
Expand Down
4 changes: 2 additions & 2 deletions packages/authentication/__mocks__/expo-constants.ts
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
module.exports = require('@baseapp-frontend/test/__mocks__/expo-constants.ts')
const Constants = require('@baseapp-frontend/test/__mocks__/expo-constants.ts')

export {}
export default Constants
4 changes: 2 additions & 2 deletions packages/authentication/__mocks__/expo-modules-core.ts
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
module.exports = require('@baseapp-frontend/test/__mocks__/expo-modules-core.ts')
const ExpoModulesCore = require('@baseapp-frontend/test/__mocks__/expo-modules-core.ts')

export {}
export default ExpoModulesCore
4 changes: 2 additions & 2 deletions packages/authentication/__mocks__/expo-secure-store.ts
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
module.exports = require('@baseapp-frontend/test/__mocks__/expo-secure-store.ts')
const ExpoSecureStore = require('@baseapp-frontend/test/__mocks__/expo-secure-store.ts')

export {}
export default ExpoSecureStore
4 changes: 2 additions & 2 deletions packages/authentication/__mocks__/fetch.ts
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
module.exports = require('@baseapp-frontend/test/__mocks__/fetch.ts')
const Fetch = require('@baseapp-frontend/test/__mocks__/fetch.ts')

export {}
export default Fetch
4 changes: 2 additions & 2 deletions packages/authentication/__mocks__/file.ts
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
module.exports = require('@baseapp-frontend/test/__mocks__/file.ts')
const File = require('@baseapp-frontend/test/__mocks__/file.ts')

export {}
export default File
4 changes: 2 additions & 2 deletions packages/authentication/__mocks__/react-native.ts
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
module.exports = require('@baseapp-frontend/test/__mocks__/react-native.ts')
const ReactNative = require('@baseapp-frontend/test/__mocks__/react-native.ts')

export {}
export default ReactNative
4 changes: 2 additions & 2 deletions packages/authentication/__mocks__/style.ts
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
module.exports = require('@baseapp-frontend/test/__mocks__/style.ts')
const Style = require('@baseapp-frontend/test/__mocks__/style.ts')

export {}
export default Style
1 change: 1 addition & 0 deletions packages/authentication/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ export * from './modules/access'
export * from './modules/mfa'
export * from './modules/profile'
export * from './modules/user'
export * from './modules/tests/utils'

export { default as AuthApi } from './services/auth'
export * from './services/auth'
Expand Down
1 change: 0 additions & 1 deletion packages/authentication/modules/profile/index.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
export { default as useCurrentProfile } from './useCurrentProfile'
export { default as InitialProfileProviderForTesting } from './useCurrentProfile/InitialProfileProviderForTesting'
export * from './useCurrentProfile/constants'
export type { MinimalProfile } from '../../types/profile'
5 changes: 5 additions & 0 deletions packages/authentication/modules/tests/utils/index.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
export { default as InitialProfileProviderForTesting } from './providers/InitialProfileProviderForTesting'
export type { InitialProfileProviderForTestingProps } from './providers/InitialProfileProviderForTesting/types'

export { default as withAuthenticationTestProviders } from './providers/withAuthenticationTestProviders'
export type { WithAuthenticationTestProvidersProps } from './providers/withAuthenticationTestProviders/types'
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ import { FC } from 'react'

import { useHydrateAtoms } from 'jotai/utils'

import { profileAtom } from '..'
import { profileAtom } from '../../../../profile/useCurrentProfile'
import { InitialProfileProviderForTestingProps } from './types'

/**
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,8 @@
import { type PropsWithChildren } from 'react'

import { type MinimalProfile } from '../../../../types/profile'
import { type MinimalProfile } from '../../../../../types/profile'

export interface InitialProfileProviderForTestingProps extends PropsWithChildren {
initialProfile: MinimalProfile | null
disabled?: boolean
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
import { FC } from 'react'

import { Provider as JotaiProvider } from 'jotai'

import InitialProfileProviderForTesting from '../InitialProfileProviderForTesting'
import { WithAuthenticationTestProvidersProps } from './types'

const withAuthenticationTestProviders =
<Props extends object>(Component: FC<Props>) =>
({
context,
InitialProfileProviderForTestingProps,
...props
}: Props & WithAuthenticationTestProvidersProps) => {
const currentProfile =
context?.parameters?.initialProfile || InitialProfileProviderForTestingProps?.initialProfile

return (
<JotaiProvider>
<InitialProfileProviderForTesting initialProfile={currentProfile || null}>
<Component {...(props as Props)} {...context} />
</InitialProfileProviderForTesting>
</JotaiProvider>
)
}

export default withAuthenticationTestProviders
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
import { PropsWithChildren } from 'react'

import { StoryContext } from '@storybook/react'

import { InitialProfileProviderForTestingProps } from '../InitialProfileProviderForTesting/types'

export interface WithAuthenticationTestProvidersProps extends PropsWithChildren {
InitialProfileProviderForTestingProps?: InitialProfileProviderForTestingProps
context?: StoryContext
}
5 changes: 3 additions & 2 deletions packages/authentication/package.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{
"name": "@baseapp-frontend/authentication",
"description": "Authentication modules.",
"version": "4.2.1",
"version": "4.2.2",
"main": "./index.ts",
"types": "dist/index.d.ts",
"sideEffects": false,
Expand All @@ -19,7 +19,8 @@
"jotai": "catalog:",
"js-cookie": "catalog:",
"react-hook-form": "catalog:",
"zod": "catalog:"
"zod": "catalog:",
"@storybook/react": "catalog:storybook"
},
"peerDependencies": {
"@baseapp-frontend/utils": "workspace:*",
Expand Down
2 changes: 1 addition & 1 deletion packages/authentication/services/auth.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { baseAppFetch } from '@baseapp-frontend/utils'
import { baseAppFetch } from '@baseapp-frontend/utils/functions/fetch/baseAppFetch'

import type {
ChangeExpiredPasswordRequest,
Expand Down
2 changes: 1 addition & 1 deletion packages/authentication/services/user.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { baseAppFetch } from '@baseapp-frontend/utils'
import { baseAppFetch } from '@baseapp-frontend/utils/functions/fetch/baseAppFetch'

import type { User, UserUpdateParams } from '../types/user'

Expand Down
1 change: 0 additions & 1 deletion packages/components/.storybook/decorators/index.ts
Original file line number Diff line number Diff line change
@@ -1,3 +1,2 @@
export { default as withTokenSetup } from './withTokenSetup'
export { default as withProviders } from './withProviders'
export { default as withMutationResolver } from './withMutationResolver'
48 changes: 0 additions & 48 deletions packages/components/.storybook/decorators/withProviders.tsx

This file was deleted.

6 changes: 4 additions & 2 deletions packages/components/.storybook/preview.ts
Original file line number Diff line number Diff line change
@@ -1,8 +1,10 @@
import { withStorybookProvidersWrapper } from '@baseapp-frontend/test/providers'

import type { Preview } from '@storybook/react'

import { withComponentCompleteTestProviders } from '../modules/tests/web'
import '../styles/tailwind/globals.css'
import { handlers } from './__mocks__/handlers'
import { withProviders } from './decorators'
import './overrides.css'

const { initialize, mswLoader } = require('msw-storybook-addon')
Expand All @@ -20,7 +22,7 @@ initialize({
})

const preview: Preview = {
decorators: [withProviders],
decorators: [withStorybookProvidersWrapper(withComponentCompleteTestProviders)],
loaders: [mswLoader],
parameters: {
controls: {
Expand Down
11 changes: 11 additions & 0 deletions packages/components/CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,16 @@
# @baseapp-frontend/components

## 1.0.31

### Patch Changes

- Unify test and storybook providers
- Updated dependencies
- @baseapp-frontend/authentication@4.2.2
- @baseapp-frontend/design-system@1.0.14
- @baseapp-frontend/graphql@1.2.7
- @baseapp-frontend/utils@3.1.6

## 1.0.30

### Patch Changes
Expand Down
4 changes: 2 additions & 2 deletions packages/components/__mocks__/expo-constants.ts
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
module.exports = require('@baseapp-frontend/test/__mocks__/expo-constants.ts')
const Constants = require('@baseapp-frontend/test/__mocks__/expo-constants.ts')

export {}
export default Constants
4 changes: 2 additions & 2 deletions packages/components/__mocks__/expo-modules-core.ts
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
module.exports = require('@baseapp-frontend/test/__mocks__/expo-modules-core.ts')
const ExpoModulesCore = require('@baseapp-frontend/test/__mocks__/expo-modules-core.ts')

export {}
export default ExpoModulesCore
4 changes: 2 additions & 2 deletions packages/components/__mocks__/expo-secure-store.ts
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
module.exports = require('@baseapp-frontend/test/__mocks__/expo-secure-store.ts')
const ExpoSecureStore = require('@baseapp-frontend/test/__mocks__/expo-secure-store.ts')

export {}
export default ExpoSecureStore
4 changes: 2 additions & 2 deletions packages/components/__mocks__/fetch.ts
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
module.exports = require('@baseapp-frontend/test/__mocks__/fetch.ts')
const Fetch = require('@baseapp-frontend/test/__mocks__/fetch.ts')

export {}
export default Fetch
4 changes: 2 additions & 2 deletions packages/components/__mocks__/file.ts
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
module.exports = require('@baseapp-frontend/test/__mocks__/file.ts')
const File = require('@baseapp-frontend/test/__mocks__/file.ts')

export {}
export default File
4 changes: 1 addition & 3 deletions packages/components/__mocks__/react-native.ts
Original file line number Diff line number Diff line change
@@ -1,3 +1 @@
module.exports = require('@baseapp-frontend/test/__mocks__/react-native.ts')

export {}
export * from '@baseapp-frontend/test/__mocks__/react-native'
4 changes: 2 additions & 2 deletions packages/components/__mocks__/style.ts
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
module.exports = require('@baseapp-frontend/test/__mocks__/style.ts')
const Style = require('@baseapp-frontend/test/__mocks__/style.ts')

export {}
export default Style
31 changes: 0 additions & 31 deletions packages/components/__test_utils__/withProviders/index.tsx

This file was deleted.

6 changes: 0 additions & 6 deletions packages/components/__test_utils__/withProviders/types.ts

This file was deleted.

1 change: 1 addition & 0 deletions packages/components/baseapp-frontend-imports.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,7 @@ import '@baseapp-frontend/design-system/providers/web'
import '@baseapp-frontend/design-system/styles/common'
import '@baseapp-frontend/design-system/styles/native'
import '@baseapp-frontend/design-system/styles/web'
import '@baseapp-frontend/design-system/tests/web'
import '@baseapp-frontend/design-system/utils/common'
import '@baseapp-frontend/design-system/utils/native'
import '@baseapp-frontend/design-system/utils/web'
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ import { graphql, useLazyLoadQuery } from 'react-relay'

import { CommentsForTestingQuery } from '../../../../../../../__generated__/CommentsForTestingQuery.graphql'
import { CommentsFragment$key } from '../../../../../../../__generated__/CommentsFragment.graphql'
import withProviders from '../../../../../../../__test_utils__/withProviders'
import { withComponentCompleteTestProviders } from '../../../../../../tests/web'
import Comments from '../../../index'
import { CommentsProps } from '../../../types'

Expand All @@ -27,4 +27,4 @@ const CommentsForTesting = (props?: Partial<CommentsProps>) => {
)
}

export default withProviders(CommentsForTesting)
export default withComponentCompleteTestProviders(CommentsForTesting)
Original file line number Diff line number Diff line change
@@ -1,10 +1,8 @@
import { User, UserApi } from '@baseapp-frontend/authentication'
import { createTestEnvironment } from '@baseapp-frontend/graphql'

import { Meta, StoryObj } from '@storybook/react'

import AccountPopover from '..'
import { withTokenSetup } from '../../../../../../../.storybook/decorators'
import { AccountPopoverProps } from '../types'
import { mockResolvers } from './mockResolvers'

Expand All @@ -27,18 +25,6 @@ const meta: Meta = {
],
},
},
decorators: [
withTokenSetup,
(Story, context) => {
const { queueOperationResolver } = context.parameters.relayMockEnvironment as ReturnType<
typeof createTestEnvironment
>

queueOperationResolver({ mockResolvers })

return <Story />
},
],
}

export default meta
Expand Down
Loading
Loading