Skip to content

Conversation

@priscilladeroode
Copy link
Contributor

@priscilladeroode priscilladeroode commented Mar 24, 2025

Acceptance Criteria

As a developer, I want to standardize the way providers (e.g., theme, context, state management) are applied in both testing and Storybook environments so that I can ensure consistency in how components are rendered across different use cases.

Identify the necessary providers used in tests and Storybook.

Create a shared wrapper that includes all required providers.
Update Storybook configuration to use the shared wrapper for rendering components.

Update test utilities to use the shared wrapper.

Ensure that Storybook stories and tests function correctly with the unified provider setup.

Summary by CodeRabbit

  • Chores & Dependency Updates

    • Locked dependency versions and updated package releases across authentication, components, design‐system, GraphQL, provider, test, utils, and wagtail for improved stability.
  • Test & Storybook Enhancements

    • Unified and streamlined provider wrappers to offer a more consistent testing and documentation experience.
  • New Utilities

    • Introduced a utility function to compose higher-order components for a more modular provider setup.

@changeset-bot
Copy link

changeset-bot bot commented Mar 24, 2025

⚠️ No Changeset found

Latest commit: 28557d5

Merging this PR will not cause a version bump for any packages. If these changes should not result in a new version, you're good to go. If these changes should result in a version bump, you need to add a changeset.

This PR includes no changesets

When changesets are added to this PR, you'll see the packages that this PR includes changesets for and the associated semver types

Click here to learn what changesets are, and how to add one.

Click here if you're a maintainer who wants to add a changeset to this PR

@coderabbitai
Copy link

coderabbitai bot commented Mar 24, 2025

Walkthrough

This PR unifies and refines provider setups across test and Storybook configurations and standardizes dependency versioning. Multiple package.json files and changelogs have been updated, while numerous module exports have been converted from CommonJS to ES Module syntax. New test utility and provider components have been added and old, redundant ones removed. In addition, import paths and configuration files (tsconfig, tsup) have been adjusted to include the tests directory. Overall, the changes streamline the testing, storybook providers, and build process.

Changes

Files Change Summary
package.json
packages/authentication/package.json
packages/components/package.json
packages/design-system/package.json
packages/graphql/package.json
packages/provider/package.json
packages/test/package.json
packages/utils/package.json
packages/wagtail/package.json
Updated dependency versions and version numbers; fixed Parcel dependency constraints; added new dependencies (e.g. @storybook/react)
packages/*/__mocks__/* (e.g. expo-constants, expo-modules-core, expo-secure-store, fetch, file, react-native, style) Converted exports from CommonJS (module.exports) to ES Module syntax (export default or export *), including added variable declarations where needed
packages/authentication/index.ts
packages/authentication/modules/tests/utils/*
packages/components/.storybook/decorators/*
packages/components/__test_utils__/withProviders/*
packages/components/modules/**/* (various tests and story files)
packages/graphql/index.ts
Refactored provider setups and test utilities to unify Storybook and testing providers; replaced legacy HOCs (e.g. withProviders) with composed, modern variants (e.g. withComponentCompleteTestProviders, withDesignSystemTestProviders, withGraphqlTestProviders, withWagtailProviders)
packages/authentication/modules/profile/index.ts
packages/authentication/services/{auth,user}.ts
packages/components/modules/navigations/web/**/* (tests and stories)
packages/utils/__mocks__/*
Adjusted import paths, removed obsolete exports, and updated prop structures (e.g. encapsulating initialProfile within a prop object)
packages/components/modules/tests/web/*
packages/design-system/tests/{common,native,web}/**/*
packages/graphql/tests/utils/*
Added new test utility and provider files to support a unified testing environment and improve modularity in Storybook and test harness contexts
packages/design-system/tsconfig.build.json
packages/design-system/tsup.config.ts
packages/utils/functions/expo/index.ts
packages/utils/functions/compose/index.ts
Updated TypeScript configuration and build entry patterns to include tests; introduced new utility functions (e.g. compose) and dynamic module loading adjustments
packages/*/CHANGELOG.md Added new version entries and changelog updates documenting dependency unification and minor version bumps

Sequence Diagram(s)

sequenceDiagram
  participant C as Component
  participant HOC as Unified Provider HOC
  participant Auth as AuthProvider
  participant GraphQL as GraphQLProvider
  participant DS as DesignSystemProvider

  C->>HOC: Wrapped via withComponentCompleteTestProviders
  HOC->>Auth: Inject authentication context
  HOC->>GraphQL: Inject GraphQL context
  HOC->>DS: Inject design system context
  DS-->>C: Render with all providers in place
Loading

Possibly related PRs

  • BA-1733: active chats tab #131: Modifies dependency versions for @parcel/packager-ts and @parcel/transformer-typescript-types with different version constraints.
  • BA-2012: stable versions #166: Also updates dependency versions in package.json for the same Parcel packages, focusing on stability improvements.

Suggested labels

approved

Poem

Hey, I’m a rabbit, hopping with glee,
Changes all around, as clear as can be.
Exports and providers now in splendid array,
Dependencies updated—hooray, hooray!
In this code garden, we bound and play.
With each small tweak, we leap a new day!
🥕🐇

Warning

There were issues while running some tools. Please review the errors and either fix the tool's configuration or disable the tool if it's a critical failure.

🔧 ESLint

If the error stems from missing dependencies, add them to the package.json file. For unrecoverable errors (e.g., due to private dependencies), disable the tool in the CodeRabbit configuration.

packages/authentication/__mocks__/expo-constants.ts

Oops! Something went wrong! :(

ESLint: 8.57.1

Error: Cannot read config file: /packages/authentication/.eslintrc.js
Error: Cannot find module '@baseapp-frontend/config/.eslintrc.js'
Require stack:

  • /packages/authentication/.eslintrc.js
  • /node_modules/.pnpm/@eslint+eslintrc@2.1.4/node_modules/@eslint/eslintrc/dist/eslintrc.cjs
  • /node_modules/.pnpm/eslint@8.57.1/node_modules/eslint/lib/cli-engine/cli-engine.js
  • /node_modules/.pnpm/eslint@8.57.1/node_modules/eslint/lib/eslint/eslint.js
  • /node_modules/.pnpm/eslint@8.57.1/node_modules/eslint/lib/eslint/index.js
  • /node_modules/.pnpm/eslint@8.57.1/node_modules/eslint/lib/cli.js
  • /node_modules/.pnpm/eslint@8.57.1/node_modules/eslint/bin/eslint.js
    at Module._resolveFilename (node:internal/modules/cjs/loader:1248:15)
    at Module._load (node:internal/modules/cjs/loader:1074:27)
    at TracingChannel.traceSync (node:diagnostics_channel:315:14)
    at wrapModuleLoad (node:internal/modules/cjs/loader:217:24)
    at Module.require (node:internal/modules/cjs/loader:1339:12)
    at require (node:internal/modules/helpers:135:16)
    at Object. (/packages/authentication/.eslintrc.js:1:18)
    at Module._compile (node:internal/modules/cjs/loader:1546:14)
    at Module._extensions..js (node:internal/modules/cjs/loader:1691:10)
    at Module.load (node:internal/modules/cjs/loader:1317:32)
packages/authentication/__mocks__/expo-modules-core.ts

Oops! Something went wrong! :(

ESLint: 8.57.1

Error: Cannot read config file: /packages/authentication/.eslintrc.js
Error: Cannot find module '@baseapp-frontend/config/.eslintrc.js'
Require stack:

  • /packages/authentication/.eslintrc.js
  • /node_modules/.pnpm/@eslint+eslintrc@2.1.4/node_modules/@eslint/eslintrc/dist/eslintrc.cjs
  • /node_modules/.pnpm/eslint@8.57.1/node_modules/eslint/lib/cli-engine/cli-engine.js
  • /node_modules/.pnpm/eslint@8.57.1/node_modules/eslint/lib/eslint/eslint.js
  • /node_modules/.pnpm/eslint@8.57.1/node_modules/eslint/lib/eslint/index.js
  • /node_modules/.pnpm/eslint@8.57.1/node_modules/eslint/lib/cli.js
  • /node_modules/.pnpm/eslint@8.57.1/node_modules/eslint/bin/eslint.js
    at Module._resolveFilename (node:internal/modules/cjs/loader:1248:15)
    at Module._load (node:internal/modules/cjs/loader:1074:27)
    at TracingChannel.traceSync (node:diagnostics_channel:315:14)
    at wrapModuleLoad (node:internal/modules/cjs/loader:217:24)
    at Module.require (node:internal/modules/cjs/loader:1339:12)
    at require (node:internal/modules/helpers:135:16)
    at Object. (/packages/authentication/.eslintrc.js:1:18)
    at Module._compile (node:internal/modules/cjs/loader:1546:14)
    at Module._extensions..js (node:internal/modules/cjs/loader:1691:10)
    at Module.load (node:internal/modules/cjs/loader:1317:32)
packages/authentication/__mocks__/expo-secure-store.ts

Oops! Something went wrong! :(

ESLint: 8.57.1

Error: Cannot read config file: /packages/authentication/.eslintrc.js
Error: Cannot find module '@baseapp-frontend/config/.eslintrc.js'
Require stack:

  • /packages/authentication/.eslintrc.js
  • /node_modules/.pnpm/@eslint+eslintrc@2.1.4/node_modules/@eslint/eslintrc/dist/eslintrc.cjs
  • /node_modules/.pnpm/eslint@8.57.1/node_modules/eslint/lib/cli-engine/cli-engine.js
  • /node_modules/.pnpm/eslint@8.57.1/node_modules/eslint/lib/eslint/eslint.js
  • /node_modules/.pnpm/eslint@8.57.1/node_modules/eslint/lib/eslint/index.js
  • /node_modules/.pnpm/eslint@8.57.1/node_modules/eslint/lib/cli.js
  • /node_modules/.pnpm/eslint@8.57.1/node_modules/eslint/bin/eslint.js
    at Module._resolveFilename (node:internal/modules/cjs/loader:1248:15)
    at Module._load (node:internal/modules/cjs/loader:1074:27)
    at TracingChannel.traceSync (node:diagnostics_channel:315:14)
    at wrapModuleLoad (node:internal/modules/cjs/loader:217:24)
    at Module.require (node:internal/modules/cjs/loader:1339:12)
    at require (node:internal/modules/helpers:135:16)
    at Object. (/packages/authentication/.eslintrc.js:1:18)
    at Module._compile (node:internal/modules/cjs/loader:1546:14)
    at Module._extensions..js (node:internal/modules/cjs/loader:1691:10)
    at Module.load (node:internal/modules/cjs/loader:1317:32)
  • 74 others
✨ Finishing Touches
  • 📝 Generate Docstrings

🪧 Tips

Chat

There are 3 ways to chat with CodeRabbit:

  • Review comments: Directly reply to a review comment made by CodeRabbit. Example:
    • I pushed a fix in commit <commit_id>, please review it.
    • Generate unit testing code for this file.
    • Open a follow-up GitHub issue for this discussion.
  • Files and specific lines of code (under the "Files changed" tab): Tag @coderabbitai in a new review comment at the desired location with your query. Examples:
    • @coderabbitai generate unit testing code for this file.
    • @coderabbitai modularize this function.
  • PR comments: Tag @coderabbitai in a new PR comment to ask questions about the PR branch. For the best results, please provide a very specific query, as very limited context is provided in this mode. Examples:
    • @coderabbitai gather interesting stats about this repository and render them as a table. Additionally, render a pie chart showing the language distribution in the codebase.
    • @coderabbitai read src/utils.ts and generate unit testing code.
    • @coderabbitai read the files in the src/scheduler package and generate a class diagram using mermaid and a README in the markdown format.
    • @coderabbitai help me debug CodeRabbit configuration file.

Note: Be mindful of the bot's finite context window. It's strongly recommended to break down tasks such as reading entire modules into smaller chunks. For a focused discussion, use review comments to chat about specific files and their changes, instead of using the PR comments.

CodeRabbit Commands (Invoked using PR comments)

  • @coderabbitai pause to pause the reviews on a PR.
  • @coderabbitai resume to resume the paused reviews.
  • @coderabbitai review to trigger an incremental review. This is useful when automatic reviews are disabled for the repository.
  • @coderabbitai full review to do a full review from scratch and review all the files again.
  • @coderabbitai summary to regenerate the summary of the PR.
  • @coderabbitai generate docstrings to generate docstrings for this PR.
  • @coderabbitai resolve resolve all the CodeRabbit review comments.
  • @coderabbitai plan to trigger planning for file edits and PR creation.
  • @coderabbitai configuration to show the current CodeRabbit configuration for the repository.
  • @coderabbitai help to get help.

Other keywords and placeholders

  • Add @coderabbitai ignore anywhere in the PR description to prevent this PR from being reviewed.
  • Add @coderabbitai summary to generate the high-level summary at a specific location in the PR description.
  • Add @coderabbitai anywhere in the PR title to generate the title automatically.

CodeRabbit Configuration File (.coderabbit.yaml)

  • You can programmatically configure CodeRabbit by adding a .coderabbit.yaml file to the root of your repository.
  • Please see the configuration documentation for more information.
  • If your editor has YAML language server enabled, you can add the path at the top of this file to enable auto-completion and validation: # yaml-language-server: $schema=https://coderabbit.ai/integrations/schema.v2.json

Documentation and Community

  • Visit our Documentation for detailed information on how to use CodeRabbit.
  • Join our Discord Community to get help, request features, and share feedback.
  • Follow us on X/Twitter for updates and announcements.

Copy link

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 0

🔭 Outside diff range comments (2)
packages/design-system/tests/commom/index.ts (1)

1-2: ⚠️ Potential issue

File is incomplete - missing exports

The file contains a comment indicating it should export common design-system tests, but there are no actual exports implemented. Based on the PR objectives to unify test and Storybook providers, this file should likely export shared provider components or utility functions.

Additionally, note that the directory name has a typo: "commom" instead of "common".

Consider implementing the necessary exports for the common test utilities:

// exports common design-system tests
export { withDesignSystemTestProviders } from './providers';
packages/design-system/tests/native/index.ts (1)

1-2: ⚠️ Potential issue

File is empty but claims to export providers

The file contains a comment indicating it should export native design-system providers, but there are no actual exports implemented. This appears to be either an incomplete implementation or a placeholder.

Either implement the necessary exports or add a TODO comment with a ticket reference explaining why this is empty. If this is intentional, consider adding more context in the comment.

🧹 Nitpick comments (10)
packages/utils/constants/compose.ts (1)

1-6: Improve type safety and add documentation to the compose utility

While the implementation is functional and directly supports the PR objective of creating a shared wrapper for providers, the use of any types reduces type safety.

Consider refactoring with stronger typing and documentation:

- import { FC } from 'react'
+ import { ComponentType, FC } from 'react'

- export const compose =
-   (...hocs: any[]) =>
-   (Component: FC<any>) =>
-     hocs.reduceRight((AccumulatedComponent, hoc) => hoc(AccumulatedComponent), Component)
+ /**
+  * Composes multiple higher-order components into a single higher-order component.
+  * The composition applies HOCs from right to left (last to first in the argument list).
+  * 
+  * @param hocs - Array of higher-order components to compose
+  * @returns A function that takes a component and returns the composed component
+  * 
+  * @example
+  * const EnhancedComponent = compose(
+  *   withTheme,
+  *   withRouter,
+  *   withRedux
+  * )(BaseComponent);
+  */
+ export const compose =
+   <P extends object>(...hocs: Array<(Component: ComponentType<any>) => ComponentType<any>>) =>
+   (Component: ComponentType<P>): ComponentType<P> =>
+     hocs.reduceRight((AccumulatedComponent, hoc) => hoc(AccumulatedComponent), Component)
packages/authentication/package.json (1)

22-23: Consider moving Storybook to devDependencies

While adding Storybook as a dependency aligns with the PR objectives, it appears this package doesn't actively use Storybook (as indicated by the "No storybook found" message in the storybook script on line 13).

Since Storybook is a development tool rather than a runtime dependency, consider moving it to the devDependencies section:

  "dependencies": {
    "@hookform/resolvers": "catalog:",
    "@tanstack/react-query": "catalog:",
    "jotai": "catalog:",
    "js-cookie": "catalog:",
    "react-hook-form": "catalog:",
-   "zod": "catalog:",
-   "@storybook/react": "catalog:storybook"
+   "zod": "catalog:"
  },
  "peerDependencies": {
    "@baseapp-frontend/utils": "workspace:*",
    "react": "catalog:react18"
  },
  "devDependencies": {
    "@baseapp-frontend/config": "workspace:*",
    "@baseapp-frontend/eslint-plugin": "workspace:*",
    "@baseapp-frontend/test": "workspace:*",
    "@baseapp-frontend/tsconfig": "workspace:*",
    "@faker-js/faker": "catalog:test",
    "@testing-library/jest-dom": "catalog:test",
    "@testing-library/react": "catalog:test",
    "@testing-library/user-event": "catalog:test",
+   "@storybook/react": "catalog:storybook",
    "@types/jest": "catalog:test",
packages/utils/functions/expo/index.ts (1)

19-23: Remove commented-out code.

The commented-out code is now redundant since it's been replaced by the try-catch implementation above.

-  // const Constants = require('expo-constants').default
-
-  // if (!Constants?.expoConfig?.extra) return undefined
-
-  // return (Constants.expoConfig.extra as T)[key]
packages/components/modules/tests/web/utils/withComponentCompleteTestProviders/index.tsx (1)

8-15: Excellent use of composition pattern for provider wrapping.

The compose utility effectively combines multiple provider HOCs into a single reusable wrapper. This approach is clean, maintainable, and directly addresses the PR's goal of creating a shared wrapper for all required providers.

Consider adding JSDoc comments to document the purpose and usage of this function.

+/**
+ * Combines all test providers into a single HOC
+ * This wrapper provides context for components, authentication, GraphQL, and design system
+ * @returns A higher-order component that wraps a component with all necessary test providers
+ */
const withComponentCompleteTestProviders = compose(
  withComponentTestProviders,
  withAuthenticationTestProviders,
  withGraphqlTestProviders,
  withDesignSystemTestProviders,
)
packages/test/providers/withStorybookProvidersWrapper/index.tsx (1)

6-9: Consider adding JSDoc comments for improved documentation

Since this function serves as an important bridging utility between test providers and Storybook, it would benefit from JSDoc comments explaining its purpose, parameters, and return value. This would help other developers understand how to use it correctly.

+/**
+ * Higher-order component that wraps a Storybook story with a provided test provider.
+ * @param provider - A function that wraps a React component with providers
+ * @returns A function that applies the provider to a Storybook story
+ */
const withTestProviders =
  (provider: (Component: FC<any>) => any) => (Story: StoryFn, context: StoryContext) => {
    const StoryWithProviders = provider(Story)
    return <StoryWithProviders context={context} />
  }
packages/authentication/modules/tests/utils/providers/withAuthenticationTestProviders/index.tsx (1)

21-21: Consider using type-safe prop forwarding

The type assertion {...(props as Props)} could potentially be unsafe. Consider using a more type-safe approach for prop forwarding if possible, such as destructuring and explicitly passing the required props.

packages/graphql/tests/utils/providers/withGraphqlTestProviders/index.tsx (2)

11-13: Consider adding a null check for context parameters

The code extracts values from context?.parameters without checking if parameters exists. While the optional chaining on context? helps avoid errors when context is null, it doesn't protect against cases where context exists but parameters is undefined.

- const queryName = context?.parameters?.queryName || undefined
- const mockResolvers = context?.parameters?.mockResolvers || undefined
- const mockData = context?.parameters?.mockData || {}
+ const queryName = context?.parameters?.queryName || undefined
+ const mockResolvers = context?.parameters?.mockResolvers || undefined
+ const mockData = context?.parameters?.mockData || {}

23-25: Be cautious about directly mutating the context object

The code directly mutates the context object by setting context.parameters.environment. This could potentially cause issues if the object is frozen or intended to be immutable.

Consider using a safer approach:

- if (context && !context.parameters.environment) {
-   context.parameters.environment = relayMockEnvironment
- }
+ if (context && context.parameters && !context.parameters.environment) {
+   // Consider creating a new context object instead of mutating
+   context.parameters = {
+     ...context.parameters,
+     environment: relayMockEnvironment
+   }
+ }
packages/design-system/tests/web/utils/providers/withDesignSystemTestProviders/index.tsx (2)

18-18: Consider memoizing the emotion cache

Creating a new Emotion cache on each render is inefficient. Consider using useMemo or moving the cache creation outside the component to avoid recreating it on every render.

- const emotionCache = createCache({ key: 'test-key' })
+ // Move outside component or use useMemo
+ const emotionCache = createCache({ key: 'test-key' })

// Alternative with useMemo inside component:
+ import { useMemo } from 'react'
+ // ...
+ const emotionCache = useMemo(() => createCache({ key: 'test-key' }), [])

16-17: Avoid type assertions when possible

Using type assertions (as) can hide type errors. Consider restructuring the code to avoid the type assertion.

- const { ThemeTestProviderProps, ReactSuspenseWithLoadingProps, ...restProps } = props as Props &
-   WithDesignSystemProviderProps
+ const { ThemeTestProviderProps, ReactSuspenseWithLoadingProps, ...restProps } = props
📜 Review details

Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between 21ae41b and 76b0bc3.

⛔ Files ignored due to path filters (2)
  • packages/components/__generated__/ActivityLogsFragment.graphql.ts is excluded by !**/__generated__/**
  • pnpm-lock.yaml is excluded by !**/pnpm-lock.yaml
📒 Files selected for processing (84)
  • package.json (1 hunks)
  • packages/authentication/__mocks__/expo-constants.ts (1 hunks)
  • packages/authentication/index.ts (1 hunks)
  • packages/authentication/modules/profile/index.ts (0 hunks)
  • packages/authentication/modules/tests/utils/index.ts (1 hunks)
  • packages/authentication/modules/tests/utils/providers/InitialProfileProviderForTesting/index.tsx (1 hunks)
  • packages/authentication/modules/tests/utils/providers/InitialProfileProviderForTesting/types.ts (1 hunks)
  • packages/authentication/modules/tests/utils/providers/withAuthenticationTestProviders/index.tsx (1 hunks)
  • packages/authentication/modules/tests/utils/providers/withAuthenticationTestProviders/types.ts (1 hunks)
  • packages/authentication/package.json (1 hunks)
  • packages/authentication/services/auth.ts (1 hunks)
  • packages/authentication/services/user.ts (1 hunks)
  • packages/components/.storybook/decorators/index.ts (0 hunks)
  • packages/components/.storybook/decorators/withProviders.tsx (0 hunks)
  • packages/components/.storybook/preview.ts (2 hunks)
  • packages/components/__mocks__/expo-constants.ts (1 hunks)
  • packages/components/__mocks__/expo-modules-core.ts (1 hunks)
  • packages/components/__mocks__/expo-secure-store.ts (1 hunks)
  • packages/components/__mocks__/fetch.ts (1 hunks)
  • packages/components/__mocks__/file.ts (1 hunks)
  • packages/components/__mocks__/react-native.ts (1 hunks)
  • packages/components/__mocks__/style.ts (1 hunks)
  • packages/components/__test_utils__/withProviders/index.tsx (0 hunks)
  • packages/components/__test_utils__/withProviders/types.ts (0 hunks)
  • packages/components/baseapp-frontend-imports.d.ts (1 hunks)
  • packages/components/modules/comments/web/Comments/__tests__/__utils__/CommentsForTesting/index.tsx (2 hunks)
  • packages/components/modules/navigations/web/Header/AccountMenu/AccountPopover/__storybook__/stories.tsx (0 hunks)
  • packages/components/modules/navigations/web/Header/AccountMenu/AccountPopover/__tests__/AccountPopover.cy.tsx (3 hunks)
  • packages/components/modules/navigations/web/Header/AccountMenu/AccountPopover/__tests__/AccountPopoverForTesting/index.tsx (1 hunks)
  • packages/components/modules/navigations/web/Header/AccountMenu/AccountPopover/__tests__/__mocks__/profiles.ts (1 hunks)
  • packages/components/modules/navigations/web/Header/AccountMenu/AccountPopover/__tests__/withProviders/index.tsx (0 hunks)
  • packages/components/modules/navigations/web/Header/AccountMenu/AccountPopover/__tests__/withProviders/types.ts (0 hunks)
  • packages/components/modules/navigations/web/Header/__storybook__/stories.tsx (1 hunks)
  • packages/components/modules/navigations/web/NavMini/__storybook__/stories.tsx (1 hunks)
  • packages/components/modules/navigations/web/NavVertical/__storybook__/stories.tsx (1 hunks)
  • packages/components/modules/navigations/web/NavigationLayout/__storybook__/stories.tsx (1 hunks)
  • packages/components/modules/notifications/web/NotificationsList/__storybook__/stories.tsx (1 hunks)
  • packages/components/modules/notifications/web/NotificationsPopover/__tests__/NotificationsPopoverForTesting/index.tsx (1 hunks)
  • packages/components/modules/profiles/web/ProfileMembers/__tests__/__utils__/MembersForTesting/index.tsx (1 hunks)
  • packages/components/modules/tests/web/index.ts (1 hunks)
  • packages/components/modules/tests/web/utils/withComponentCompleteTestProviders/index.tsx (1 hunks)
  • packages/components/modules/tests/web/utils/withComponentTestProviders/index.tsx (1 hunks)
  • packages/components/modules/tests/web/utils/withComponentTestProviders/types.ts (1 hunks)
  • packages/components/package.json (1 hunks)
  • packages/design-system/.storybook/decorators/index.ts (0 hunks)
  • packages/design-system/.storybook/decorators/withProviders.tsx (0 hunks)
  • packages/design-system/.storybook/preview.ts (1 hunks)
  • packages/design-system/__mocks__/expo-constants.ts (1 hunks)
  • packages/design-system/package.json (1 hunks)
  • packages/design-system/providers/web/SnackbarProvider/__storybook__/stories.tsx (1 hunks)
  • packages/design-system/tests/commom/index.ts (1 hunks)
  • packages/design-system/tests/native/index.ts (1 hunks)
  • packages/design-system/tests/web/utils/__mocks__/theme.ts (1 hunks)
  • packages/design-system/tests/web/utils/index.ts (1 hunks)
  • packages/design-system/tests/web/utils/providers/ReactSuspenseWithLoading/index.tsx (1 hunks)
  • packages/design-system/tests/web/utils/providers/ReactSuspenseWithLoading/types.d.ts (1 hunks)
  • packages/design-system/tests/web/utils/providers/ThemeTestProvider/index.tsx (1 hunks)
  • packages/design-system/tests/web/utils/providers/ThemeTestProvider/types.ts (1 hunks)
  • packages/design-system/tests/web/utils/providers/withDesignSystemTestProviders/index.tsx (1 hunks)
  • packages/design-system/tests/web/utils/providers/withDesignSystemTestProviders/types.ts (1 hunks)
  • packages/design-system/tsconfig.build.json (1 hunks)
  • packages/design-system/tsup.config.ts (1 hunks)
  • packages/graphql/index.ts (1 hunks)
  • packages/graphql/package.json (1 hunks)
  • packages/graphql/providers/index.ts (0 hunks)
  • packages/graphql/tests/utils/index.ts (1 hunks)
  • packages/graphql/tests/utils/providers/withGraphqlTestProviders/index.tsx (1 hunks)
  • packages/graphql/tests/utils/providers/withGraphqlTestProviders/types.ts (1 hunks)
  • packages/test/package.json (1 hunks)
  • packages/test/providers/index.ts (1 hunks)
  • packages/test/providers/withStorybookProvidersWrapper/index.tsx (1 hunks)
  • packages/utils/__mocks__/expo-constants.ts (1 hunks)
  • packages/utils/__mocks__/expo-modules-core.ts (1 hunks)
  • packages/utils/__mocks__/expo-secure-store.ts (1 hunks)
  • packages/utils/__mocks__/fetch.ts (1 hunks)
  • packages/utils/__mocks__/file.ts (1 hunks)
  • packages/utils/__mocks__/react-native.ts (1 hunks)
  • packages/utils/__mocks__/style.ts (1 hunks)
  • packages/utils/constants/compose.ts (1 hunks)
  • packages/utils/functions/expo/index.ts (1 hunks)
  • packages/utils/index.ts (1 hunks)
  • packages/wagtail/.storybook/decorators/withProviders.tsx (1 hunks)
  • packages/wagtail/.storybook/preview.ts (2 hunks)
  • packages/wagtail/__mocks__/expo-constants.ts (1 hunks)
💤 Files with no reviewable changes (11)
  • packages/components/.storybook/decorators/index.ts
  • packages/components/modules/navigations/web/Header/AccountMenu/AccountPopover/storybook/stories.tsx
  • packages/authentication/modules/profile/index.ts
  • packages/graphql/providers/index.ts
  • packages/components/modules/navigations/web/Header/AccountMenu/AccountPopover/tests/withProviders/types.ts
  • packages/components/.storybook/decorators/withProviders.tsx
  • packages/components/modules/navigations/web/Header/AccountMenu/AccountPopover/tests/withProviders/index.tsx
  • packages/components/test_utils/withProviders/types.ts
  • packages/design-system/.storybook/decorators/index.ts
  • packages/design-system/.storybook/decorators/withProviders.tsx
  • packages/components/test_utils/withProviders/index.tsx
🧰 Additional context used
🧬 Code Definitions (11)
packages/graphql/tests/utils/providers/withGraphqlTestProviders/types.ts (1)
packages/graphql/tests/utils/providers/RelayTestProvider/types.ts (1)
  • RelayTestProviderProps (5-7)
packages/wagtail/.storybook/preview.ts (1)
packages/wagtail/.storybook/decorators/withProviders.tsx (1)
  • withWagtailProviders (7-7)
packages/design-system/tests/web/utils/providers/ReactSuspenseWithLoading/types.d.ts (1)
packages/design-system/tests/web/utils/index.ts (1)
  • ReactSuspenseWithLoadingProps (7-7)
packages/authentication/modules/tests/utils/providers/withAuthenticationTestProviders/types.ts (2)
packages/authentication/modules/tests/utils/index.ts (2)
  • WithAuthenticationTestProvidersProps (5-5)
  • InitialProfileProviderForTestingProps (2-2)
packages/authentication/modules/tests/utils/providers/InitialProfileProviderForTesting/types.ts (1)
  • InitialProfileProviderForTestingProps (5-8)
packages/design-system/tests/web/utils/providers/withDesignSystemTestProviders/types.ts (2)
packages/design-system/tests/web/utils/providers/ThemeTestProvider/types.ts (1)
  • ThemeTestProviderProps (5-8)
packages/design-system/tests/web/utils/providers/ReactSuspenseWithLoading/types.d.ts (1)
  • ReactSuspenseWithLoadingProps (3-6)
packages/design-system/tests/web/utils/providers/ReactSuspenseWithLoading/index.tsx (2)
packages/design-system/tests/web/utils/index.ts (1)
  • ReactSuspenseWithLoadingProps (7-7)
packages/design-system/tests/web/utils/providers/ReactSuspenseWithLoading/types.d.ts (1)
  • ReactSuspenseWithLoadingProps (3-6)
packages/design-system/tests/web/utils/providers/withDesignSystemTestProviders/index.tsx (5)
packages/design-system/tests/web/utils/index.ts (3)
  • WithDesignSystemProviderProps (10-10)
  • ThemeTestProviderProps (4-4)
  • ReactSuspenseWithLoadingProps (7-7)
packages/design-system/tests/web/utils/providers/withDesignSystemTestProviders/types.ts (1)
  • WithDesignSystemProviderProps (6-9)
packages/design-system/tests/web/utils/providers/ThemeTestProvider/types.ts (1)
  • ThemeTestProviderProps (5-8)
packages/utils/index.ts (1)
  • NotificationProvider (28-28)
packages/design-system/tests/web/utils/providers/ReactSuspenseWithLoading/types.d.ts (1)
  • ReactSuspenseWithLoadingProps (3-6)
packages/components/modules/navigations/web/Header/AccountMenu/AccountPopover/__tests__/AccountPopover.cy.tsx (1)
packages/components/modules/navigations/web/Header/AccountMenu/AccountPopover/__tests__/__mocks__/profiles.ts (1)
  • mockUserProfileData (179-179)
packages/wagtail/.storybook/decorators/withProviders.tsx (1)
packages/utils/constants/compose.ts (1)
  • compose (3-6)
packages/graphql/tests/utils/providers/withGraphqlTestProviders/index.tsx (1)
packages/graphql/tests/utils/providers/withGraphqlTestProviders/types.ts (1)
  • WithGraphqlTestProvidersProps (5-7)
packages/components/modules/tests/web/utils/withComponentTestProviders/index.tsx (1)
packages/components/modules/tests/web/utils/withComponentTestProviders/types.ts (1)
  • WithComponentTestProvidersProps (3-5)
🔇 Additional comments (87)
packages/utils/index.ts (1)

1-1: LGTM! New utility export for component composition

The addition of this export makes the new compose utility function available throughout the application, which directly supports the PR objective of standardizing providers across testing and Storybook environments.

packages/components/baseapp-frontend-imports.d.ts (1)

49-49: Good addition for test provider consistency!

Adding this import aligns perfectly with the PR's goal of unifying test and Storybook providers. This makes the web test utilities from the design system package available for auto-imports in the editor, which will help developers use the standardized test providers more easily.

packages/design-system/providers/web/SnackbarProvider/__storybook__/stories.tsx (1)

14-19:

❓ Verification inconclusive

Simplification reflects the new unified provider approach.

The removal of the explicit SnackbarProvider wrapper aligns with the PR's goal of using a shared provider wrapper. This simplifies the component and removes duplicated provider setup, assuming the SnackbarProvider is now being applied globally through the new standardized provider setup in Storybook.


🏁 Script executed:

#!/bin/bash
# Verify that SnackbarProvider is included in the shared provider setup for Storybook
echo "Checking for SnackbarProvider in Storybook setup..."
rg -l "SnackbarProvider" --glob "*.{ts,tsx}" packages/*/.storybook/

Length of output: 253


Please verify that the global SnackbarProvider is properly configured in your Storybook setup.

The updated code in packages/design-system/providers/web/SnackbarProvider/__storybook__/stories.tsx removes the explicit provider wrapper in favor of a unified global provider. However, our automated search couldn’t find any reference to a SnackbarProvider in the Storybook configuration directories (e.g., under packages/design-system/.storybook/). This might indicate that the global provider setup does not yet include the SnackbarProvider, which could affect how notifications are handled.

  • Action Required: Double-check that the shared Storybook provider setup is correctly applying the SnackbarProvider globally.
  • Recommendation: If the SnackbarProvider is missing, please update your global provider configuration or adjust the new unified provider approach accordingly.
packages/components/__mocks__/style.ts (1)

1-2: Great modernization to ES Module syntax!

Converting from CommonJS to ES Module syntax (module.exports = to export * from) standardizes the export patterns across the codebase. This improves code consistency and aligns with modern JavaScript practices.

packages/utils/__mocks__/expo-constants.ts (1)

1-2: Good conversion to ES Module syntax!

Updating from CommonJS to ES Module syntax (module.exports = to export * from) creates consistency across the codebase and follows modern JavaScript best practices. The removal of the .ts extension in the import path is also correct, as it's not needed with ES Module imports.

packages/authentication/__mocks__/expo-constants.ts (1)

1-1: Modernized module export syntax.

Great job updating from CommonJS to ES modules syntax. This change aligns with modern JavaScript practices and provides better tree-shaking capabilities.

packages/components/__mocks__/fetch.ts (1)

1-1: Modernized module export syntax.

Excellent update from CommonJS (module.exports) to ES modules syntax. This change:

  1. Creates consistency across the codebase
  2. Aligns with the PR objective of unifying test providers
  3. Enables better static analysis and tree-shaking

The removal of the file extension in the import path is also good practice.

packages/wagtail/__mocks__/expo-constants.ts (1)

1-1: Modernized module export syntax.

This update to ES modules syntax is consistent with the changes across other packages and helps standardize the codebase.

packages/utils/__mocks__/style.ts (1)

1-1: Modernized module export syntax.

Excellent conversion from CommonJS to ES modules. This systematic approach across all packages will make imports more consistent and easier to maintain.

packages/utils/__mocks__/file.ts (1)

1-1: Good migration to ES modules syntax.

This change correctly updates the export mechanism from CommonJS to ES module syntax, aligning with modern JavaScript/TypeScript practices. The update improves consistency across the codebase and supports the PR objective of standardizing providers across testing and Storybook environments.

packages/components/__mocks__/expo-secure-store.ts (1)

1-1: Good migration to ES modules syntax.

This change correctly updates the export mechanism from CommonJS to ES module syntax, which is a more modern approach. The file extension has also been properly removed from the import path, aligning with best practices where TypeScript can resolve the file without the extension.

packages/utils/__mocks__/fetch.ts (1)

1-1: Good migration to ES modules syntax.

This change correctly updates the export mechanism from CommonJS to ES module syntax. The consistent approach across mock files demonstrates a systematic modernization of the codebase, which supports the PR objective of creating unified providers for testing and Storybook environments.

packages/design-system/__mocks__/expo-constants.ts (1)

1-1: Good migration to ES modules syntax.

This change correctly updates the export mechanism from CommonJS to ES module syntax. The centralization of mock implementations through re-exports from a common location helps maintain consistency and reduces duplication across the codebase.

packages/design-system/package.json (1)

48-52: LGTM - Appropriate export configuration for test utilities

This change adds a new export path for test-related files following the same pattern as other exports in the package. This is necessary to make the test providers and utilities accessible to other packages, aligning with the PR objective of unifying test and Storybook providers.

packages/utils/__mocks__/expo-secure-store.ts (1)

1-1: Modernized export syntax - Good improvement

Converting from CommonJS (module.exports) to ES Module syntax (export * from) improves code consistency and aligns with modern JavaScript practices. The removal of the file extension in the import path is also correct per TypeScript import resolution standards.

packages/utils/__mocks__/react-native.ts (1)

1-1: Modernized export syntax - Good improvement

Converting from CommonJS (module.exports) to ES Module syntax (export * from) improves code consistency and aligns with modern JavaScript practices. The removal of the file extension in the import path is also correct per TypeScript import resolution standards.

packages/utils/__mocks__/expo-modules-core.ts (1)

1-1: Modernized export syntax - Good improvement

Converting from CommonJS (module.exports) to ES Module syntax (export * from) improves code consistency and aligns with modern JavaScript practices. The removal of the file extension in the import path is also correct per TypeScript import resolution standards.

packages/components/__mocks__/expo-modules-core.ts (1)

1-1: Improved module export syntax

The change from CommonJS module.exports to ES module export * syntax is a positive improvement that modernizes the codebase. This aligns with the PR objective of standardizing providers across test utilities and Storybook.

packages/components/__mocks__/file.ts (1)

1-1: Good conversion to ES module syntax

Updating from CommonJS to ES module syntax is a good practice and aligns with modern JavaScript standards. The removal of the file extension in the import path is also appropriate as TypeScript resolves module paths without extensions.

packages/components/__mocks__/react-native.ts (1)

1-1: Consistent export pattern applied

This change maintains consistency with the other mock files by converting to ES module syntax. This standardization helps with the PR goal of unifying provider patterns across test and Storybook environments.

packages/components/__mocks__/expo-constants.ts (1)

1-1: Standardized export approach

The conversion to ES module syntax completes the standardization pattern across these mock files. This makes the codebase more consistent and maintainable, supporting the PR's objective of standardizing provider implementations.

packages/test/providers/index.ts (1)

3-3: Export added for Storybook providers wrapper

The addition of withStorybookProvidersWrapper aligns well with the PR objective to standardize providers across test and Storybook environments.

packages/test/package.json (1)

22-23: Added Storybook dependency

The addition of @storybook/react as a dependency is appropriate for implementing Storybook provider wrappers as part of unifying test and Storybook providers.

packages/authentication/services/user.ts (1)

1-1: Import path updated to be more specific

The import path for baseAppFetch has been updated to use a more specific path. This change doesn't affect functionality but improves code organization.

This change is consistent with similar updates in packages/authentication/services/auth.ts as mentioned in the AI summary.

packages/components/modules/navigations/web/Header/AccountMenu/AccountPopover/__tests__/__mocks__/profiles.ts (1)

10-10: Replaced dynamic URL with static value for consistent test data

Replacing faker.internet.url() with a static string 'first-profile' for the urlPath property makes tests more predictable and less flaky. This change aligns with the PR objective of standardizing test providers and ensuring consistency.

packages/graphql/index.ts (1)

3-3: LGTM - Added test utilities export

Exporting the test utilities from the package root index file makes them accessible to consumers, supporting the goal of unifying test and Storybook providers across the application.

packages/design-system/tsconfig.build.json (1)

10-10: LGTM - Included test utilities in build process

Adding "tests" to the include array ensures that test utilities are compiled and included in the built package, making them available for reuse across the codebase. This is essential for the shared provider approach being implemented.

packages/design-system/tests/web/utils/providers/ReactSuspenseWithLoading/types.d.ts (1)

1-6: LGTM - Well-defined TypeScript interface for React Suspense wrapper

The interface is well-structured with appropriate React types and optional properties that provide flexibility. This supports the PR goal of creating a unified wrapper for providers in test and Storybook environments.

packages/authentication/index.ts (1)

5-5: LGTM: Enhanced export for test utilities

This new export makes the test utilities available from the authentication package, which aligns with the PR's goal of standardizing providers across tests and Storybook environments.

packages/authentication/modules/tests/utils/providers/InitialProfileProviderForTesting/types.ts (2)

3-3: Import path updated correctly

The import path for MinimalProfile has been updated to reflect the correct relative location.


7-7: LGTM: Added disabled prop for provider control

Adding the optional disabled property allows conditional application of the provider, which is beneficial for testing scenarios where you might want to isolate component behavior from the provider.

packages/design-system/tests/web/utils/providers/ThemeTestProvider/types.ts (1)

1-8: Well-structured provider props interface

The ThemeTestProviderProps interface is well-designed with:

  • PropsWithChildren extension for React component compatibility
  • Optional customTheme for theme customization
  • Optional disabled flag for conditional rendering

This aligns perfectly with the PR objective of creating a shared wrapper for providers.

packages/authentication/services/auth.ts (1)

1-1: Import path specificity improved

The import path has been updated to be more specific, which improves maintainability by making dependencies clearer and more explicit. This change is consistent with modern JavaScript best practices for precise imports.

packages/components/modules/tests/web/utils/withComponentTestProviders/types.ts (1)

1-5: Well-structured interface for test providers

The interface definition follows good TypeScript practices with properly typed optional properties. This aligns perfectly with the PR objective of standardizing providers across testing and Storybook environments by allowing QueryClient configuration when needed.

packages/graphql/tests/utils/providers/withGraphqlTestProviders/types.ts (1)

1-7: Good approach with interface extension

This interface properly extends RelayTestProviderProps while adding Storybook context support. The inheritance structure promotes code reuse and ensures that GraphQL test providers maintain compatibility with both testing and Storybook environments, which aligns with the PR's unification goal.

packages/graphql/package.json (1)

23-24: Required dependency for Storybook integration

Adding the Storybook React dependency is necessary to support the new type imports and functionality. This change enables the standardization of providers across testing and Storybook environments as intended in the PR objectives.

packages/authentication/modules/tests/utils/providers/InitialProfileProviderForTesting/index.tsx (1)

5-5: Improved import path clarity

The change from a relative import to a more specific path makes the code more maintainable and less prone to breakage if files are moved around. This type of refactoring supports the PR's goal of standardizing providers by ensuring consistent and reliable imports.

packages/components/modules/notifications/web/NotificationsList/__storybook__/stories.tsx (1)

34-36: Good addition of query name parameter for LoadingNotificationsList story.

This addition of the queryName parameter helps identify which GraphQL query should be mocked or intercepted for this loading story. This change aligns well with the PR objective of standardizing provider usage across testing and Storybook environments.

packages/utils/functions/expo/index.ts (1)

8-18: Good improvement in error handling for expo-constants.

The try-catch implementation for dynamically requiring expo-constants makes this utility more resilient in web and Storybook environments. This ensures components can be rendered consistently without crashing when Expo-specific functionality isn't available.

packages/design-system/tests/web/utils/providers/withDesignSystemTestProviders/types.ts (1)

1-9: Well-structured interface for design system provider props.

The interface correctly extends PropsWithChildren and defines the expected properties for theme and loading state management. This provides good type safety for the design system test providers and aligns with the PR goal of creating standardized provider wrappers.

packages/components/modules/tests/web/utils/withComponentCompleteTestProviders/index.tsx (1)

1-7: Good imports for unified test providers.

The imports provide a comprehensive set of test providers from different packages, which aligns with the PR objective of identifying and unifying all necessary providers for tests and Storybook.

packages/components/.storybook/preview.ts (1)

1-2: Good implementation of the unified provider approach

The changes effectively implement the PR's goal of standardizing providers across testing and Storybook environments. Using the withStorybookProvidersWrapper to wrap withComponentCompleteTestProviders provides a consistent approach that can be reused across the codebase, ensuring that components are rendered with the same context in both tests and Storybook.

Also applies to: 5-5, 25-25

packages/wagtail/.storybook/preview.ts (1)

1-2: Consistent implementation of the unified provider pattern

The changes in this file follow the same pattern established in the components package, using withStorybookProvidersWrapper to wrap the package-specific providers. The use of withWagtailProviders (which is a composition of withGraphqlTestProviders and withDesignSystemTestProviders) demonstrates a modular approach to provider composition, making the code more maintainable and consistent with the standardization goal of this PR.

Also applies to: 5-5, 23-23

packages/components/modules/profiles/web/ProfileMembers/__tests__/__utils__/MembersForTesting/index.tsx (1)

2-2: Good adoption of the standardized provider pattern

The changes effectively replace the custom provider wrapper with the standardized withComponentCompleteTestProviders, ensuring that this test utility uses the same provider setup as other components in the codebase. This implementation supports the PR goal of unifying providers across test environments.

Also applies to: 8-8

packages/authentication/modules/tests/utils/providers/withAuthenticationTestProviders/types.ts (1)

1-10: Well-designed type interface for authentication providers

This new interface properly defines the props for the authentication test providers, including support for both test and Storybook environments through the context prop of type StoryContext. The interface extends PropsWithChildren correctly to allow wrapping child components, and includes optional configuration for initial profile testing.

The type definition enhances type safety and maintainability while supporting the PR's goal of standardizing providers across different environments.

packages/design-system/tests/web/utils/providers/ThemeTestProvider/index.tsx (1)

1-21: Clean and well-structured test provider implementation.

This ThemeTestProvider component is well-designed with appropriate defaults and a clean implementation. It properly handles the disabled case and allows for theme customization via props.

packages/design-system/tests/web/utils/providers/ReactSuspenseWithLoading/index.tsx (1)

1-18: Well-implemented Suspense wrapper for testing.

The ReactSuspenseWithLoading component follows good practices by:

  1. Providing a sensible default fallback (LoadingState)
  2. Including a disabled option for testing flexibility
  3. Correctly implementing React.Suspense

This will be useful for handling loading states consistently across tests.

packages/components/modules/tests/web/index.ts (1)

1-3: Clean exports with good organization.

This index file correctly exports the test providers and their types, making them easily accessible for tests throughout the codebase. The explicit export of types ensures good TypeScript support for consumers.

packages/components/package.json (1)

63-68: Good addition of test exports to package.json.

Adding the test utilities to the package exports makes them available to consumers in a consistent way, aligning with the PR objective of creating shared providers for tests and Storybook.

The export paths follow the same pattern as other exports in the package, maintaining consistency in the codebase.

packages/test/providers/withStorybookProvidersWrapper/index.tsx (1)

1-11: Well-structured and clean HOC implementation

This higher-order component is well-designed for wrapping Storybook stories with test providers. It accepts a provider function and returns a function that applies that provider to a Story, which is exactly what's needed to unify providers between test and Storybook environments.

package.json (1)

23-24: Good dependency versioning practice

Changing from "latest" to specific version ranges (^2.14.1) is a good practice. This prevents unexpected breaking changes from automatic updates while still allowing compatible minor and patch updates, improving build stability and reproducibility.

packages/components/modules/navigations/web/Header/__storybook__/stories.tsx (1)

5-5: Good standardization of theme imports

Importing defaultTheme from a centralized utility rather than a local mock aligns with the PR objective of unifying providers across test and Storybook environments. This change helps ensure consistent theming across different rendering contexts.

packages/components/modules/navigations/web/NavigationLayout/__storybook__/stories.tsx (2)

5-5: Good standardization of theme imports

Importing defaultTheme from the centralized utils package instead of a local mock ensures consistency with other components and aligns with the PR objective of unifying providers across environments.


32-32: Consistent use of defaultTheme across layout variations

The implementation correctly applies the standardized defaultTheme across all layout variations (default, mini, horizontal, and centered), maintaining consistent theming while allowing layout-specific customizations.

Also applies to: 96-97, 109-110, 122-123

packages/components/modules/navigations/web/NavMini/__storybook__/stories.tsx (1)

2-2: Import change aligns with provider standardization objectives

The updated import path for defaultTheme is part of the broader effort to standardize provider usage across test and Storybook environments. Using the theme from the design system's test utilities instead of a mock ensures consistent theming between tests and stories.

packages/authentication/modules/tests/utils/providers/withAuthenticationTestProviders/index.tsx (1)

8-25: Well-structured HOC implementation for authentication test providers

This higher-order component correctly sets up the authentication providers needed for tests. It appropriately retrieves the profile from either context parameters or direct props, providing flexibility for different usage scenarios.

packages/components/modules/tests/web/utils/withComponentTestProviders/index.tsx (2)

7-13: Good configuration for test QueryClient

The default QueryClient is properly configured with retries disabled, which is ideal for testing environments to avoid unnecessary delays or flaky tests.


15-25: Well-implemented HOC with flexibility for custom query clients

This HOC follows good practices by:

  1. Using TypeScript generics to maintain type safety
  2. Providing a default QueryClient while allowing custom overrides
  3. Properly forwarding props to the wrapped component

The implementation aligns perfectly with the PR goal of standardizing providers across test environments.

packages/design-system/tsup.config.ts (1)

9-11: Essential build config update to support test utilities export

This change to the build configuration is necessary to make test utilities available for import by other packages. By including the test directories in the build process, you enable the standardization of providers between test and Storybook environments - a core objective of this PR.

The multi-line format also improves readability and makes future path additions easier.

packages/graphql/tests/utils/index.ts (1)

1-5: Clean and efficient export pattern for GraphQL test utilities

This new file follows a well-organized pattern by centrally exporting the GraphQL test utilities and their associated types. The implementation aligns well with the PR objective of unifying test and Storybook providers.

packages/components/modules/comments/web/Comments/__tests__/__utils__/CommentsForTesting/index.tsx (2)

5-5: Appropriate replacement of the test provider import

The change from a custom provider to the standardized withComponentCompleteTestProviders aligns with the PR objective of unifying test and Storybook providers.


30-30: Consistent update to use the unified test provider

The export statement has been correctly updated to use the new withComponentCompleteTestProviders higher-order component, maintaining the same functionality while standardizing the approach.

packages/design-system/tests/web/utils/__mocks__/theme.ts (3)

1-1: Improved import specificity

The change from a module-level import to a more specific relative path improves maintainability and makes dependencies clearer.


8-8: Consistent import path update

The import path has been updated to use relative paths instead of module-level imports, following the same pattern as the other import changes in this file.


10-10: Cleaner export pattern

The addition of the export keyword directly to the defaultTheme constant declaration simplifies the export pattern, eliminating the need for a separate export statement at the end of the file.

packages/components/modules/navigations/web/NavVertical/__storybook__/stories.tsx (1)

2-2: Standardized theme import for Storybook

The import of defaultTheme has been updated to use the shared utility from the design system's test directory instead of a local mock. This change supports the PR's goal of standardizing providers across test and Storybook environments.

packages/graphql/tests/utils/providers/withGraphqlTestProviders/index.tsx (1)

7-32: Good implementation of the GraphQL test providers HOC

The HOC implementation is well-structured, providing a clean way to wrap components with GraphQL test providers. It handles environment creation and operation resolvers appropriately.

packages/authentication/modules/tests/utils/index.ts (1)

1-5: Clean export structure for authentication test utilities

The index file properly exports both the components and their corresponding TypeScript types, following best practices for module organization.

packages/design-system/tests/web/utils/providers/withDesignSystemTestProviders/index.tsx (1)

13-33: Well-structured HOC with nested providers

The higher-order component effectively wraps the original component with multiple providers in the correct order, following React's composition pattern.

packages/design-system/.storybook/preview.ts (1)

1-1: Good implementation of unified provider approach for Storybook

The changes correctly implement the PR objective of unifying test and Storybook providers. The new approach uses composition to combine providers through the withStorybookProvidersWrapper utility.

Also applies to: 7-7, 10-10

packages/wagtail/.storybook/decorators/withProviders.tsx (3)

1-5: Good restructuring of imports!

The import changes have simplified the code by using higher-level providers from other packages instead of importing and setting up lower-level components directly. This aligns with the PR objective of standardizing providers across test and Storybook environments.


7-7: Well implemented provider composition pattern

Using the compose utility function to combine withGraphqlTestProviders and withDesignSystemTestProviders is a clean approach that follows functional programming best practices. This simplifies the provider setup and makes it more maintainable.


9-9: Consistent export pattern

Exporting withWagtailProviders as the default export maintains the same usage pattern as before while implementing the new standardized approach.

packages/components/modules/notifications/web/NotificationsPopover/__tests__/NotificationsPopoverForTesting/index.tsx (3)

1-2: Good import simplification

Using a centralized import path for test providers improves maintainability and follows the PR's goal of standardizing provider usage. The import is now cleaner and more maintainable.


4-5: Clean implementation of the new provider pattern

The implementation clearly applies the centralized test provider to the NotificationsPopover component, making it consistent with other components in the codebase and aligning with the PR objective to unify provider wrappers.


7-7: Consistent export pattern

Directly exporting the wrapped component simplifies the code and maintains a consistent pattern across the codebase.

packages/components/modules/navigations/web/Header/AccountMenu/AccountPopover/__tests__/AccountPopover.cy.tsx (3)

37-42: Good prop structure refactoring

The change from directly passing initialProfile to using a structured InitialProfileProviderForTestingProps object improves the component API by grouping related props. This makes the component more maintainable as it's clearer which props relate to which provider.


57-61: Consistent prop structure implementation

This change maintains consistency with the updated component API, using the same structured prop pattern established earlier in the file.


129-129: Consistent prop structure application

The prop structure change has been consistently applied throughout all test cases, which ensures test reliability and maintainability.

packages/design-system/tests/web/utils/index.ts (5)

1-2: Appropriate use of 'use client' directive

The 'use client' directive indicates this code is meant to run on the client side in a React Server Components environment, which is correct for UI component testing utilities.


3-4: Good export structure for theme provider

Cleanly exports both the component and its TypeScript type, which provides good type safety for consumers of this module.


6-7: Well-organized suspense provider exports

Follows the same clear pattern of exporting both the component and its TypeScript type.


9-10: Consistent export pattern for design system providers

Maintains the same export pattern, creating a predictable API for consumers.


12-12: Good re-export of theme mocks

Re-exporting the theme mocks makes them accessible from this centralized location, reducing import paths throughout the codebase.

packages/components/modules/navigations/web/Header/AccountMenu/AccountPopover/__tests__/AccountPopoverForTesting/index.tsx (3)

2-2: Good addition of the unified test provider package.

This new import aligns with the PR objective of unifying providers across testing and Storybook environments by leveraging the centralized withComponentCompleteTestProviders utility.


4-4: Implementation successfully refactored to use the unified provider wrapper.

The implementation now uses the higher-order component approach with withComponentCompleteTestProviders instead of manually wrapping with providers. This simplifies the code and ensures consistent provider application across tests.


6-6: Export statement appropriately simplified.

The export statement has been streamlined to directly export the wrapped component, eliminating the previous dependency on withProviders. This change completes the refactoring to use the unified provider approach.

@anicioalexandre anicioalexandre added needs changes PR was reviewed, and changes are required. needs review PR needs to be reviewed. and removed needs changes PR was reviewed, and changes are required. labels Mar 26, 2025
@priscilladeroode priscilladeroode force-pushed the BA-2287-fe-unify-test-and-storybook-providers branch from 5d34518 to 6293227 Compare April 2, 2025 03:57
Copy link

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 0

🧹 Nitpick comments (6)
packages/wagtail/.storybook/decorators/withProviders.tsx (2)

1-1: Remove unused import FC from React

The FC type from React is imported but not used anywhere in the file. This unused import should be removed to keep the code clean.

-import { FC } from 'react'

1-10: Excellent refactoring of provider implementation

This refactor successfully transforms the complex provider implementation into a simpler, more maintainable composition of reusable providers. The change aligns perfectly with the PR objective of standardizing providers across testing and Storybook environments.

Consider adding a brief comment explaining what these providers do to help future developers understand their purpose and the composition order.

import { withDesignSystemTestProviders } from '@baseapp-frontend/design-system/tests/web/utils'
import { withGraphqlTestProviders } from '@baseapp-frontend/graphql'
import { compose } from '@baseapp-frontend/utils/dist/constants/compose'

+/**
+ * Combines GraphQL and Design System providers for Wagtail components in Storybook
+ * Order: Design System providers applied first, then GraphQL providers
+ */
export const withWagtailProviders = compose(withGraphqlTestProviders, withDesignSystemTestProviders)

export default withWagtailProviders
packages/authentication/modules/tests/utils/providers/withAuthenticationTestProviders/index.tsx (4)

8-14: Consider adding JSDoc documentation for this HOC.

This Higher-Order Component plays an important role in providing authentication context for tests. Adding JSDoc comments would help other developers understand its purpose, parameters, and usage examples.

+/**
+ * HOC that wraps components with authentication-related providers for testing purposes.
+ * Provides Jotai state management and initial profile context.
+ * 
+ * @template Props - The props type of the wrapped component
+ * @param {FC<Props>} Component - The component to wrap with authentication providers
+ * @returns {FC<Props & WithAuthenticationTestProvidersProps>} - The wrapped component with providers
+ */
const withAuthenticationTestProviders =
  <Props extends object>(Component: FC<Props>) =>
  ({
    context,
    InitialProfileProviderForTestingProps,
    ...props
  }: Props & WithAuthenticationTestProvidersProps) => {

15-17: Add a default fallback for currentProfile.

The currentProfile is extracted using optional chaining, but there's no fallback if both sources are undefined. Consider adding a default value to prevent potential issues.

const currentProfile =
-  context?.parameters?.initialProfile || InitialProfileProviderForTestingProps?.initialProfile
+  context?.parameters?.initialProfile || InitialProfileProviderForTestingProps?.initialProfile || null

9-14: Consider adding a displayName for debugging purposes.

Adding a displayName to the wrapped component would make debugging easier by providing a clear name in React DevTools.

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

     return (
       <JotaiProvider>
         <InitialProfileProviderForTesting initialProfile={currentProfile}>
           <Component {...(props as Props)} {...context} />
         </InitialProfileProviderForTesting>
       </JotaiProvider>
     )
   }
+  WrappedWithAuthenticationProviders.displayName = `withAuthenticationTestProviders(${
+    Component.displayName || Component.name || 'Component'
+  })`;
+  
+  return WrappedWithAuthenticationProviders;
}

21-21: Type casting could be improved.

The props as Props cast might be unnecessary if the types are properly defined. Consider revisiting the type definitions to make this more type-safe.

- <Component {...(props as Props)} {...context} />
+ <Component {...props} {...context} />
📜 Review details

Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between 5d34518 and 6293227.

⛔ Files ignored due to path filters (1)
  • pnpm-lock.yaml is excluded by !**/pnpm-lock.yaml
📒 Files selected for processing (84)
  • package.json (1 hunks)
  • packages/authentication/__mocks__/expo-constants.ts (1 hunks)
  • packages/authentication/index.ts (1 hunks)
  • packages/authentication/modules/profile/index.ts (0 hunks)
  • packages/authentication/modules/tests/utils/index.ts (1 hunks)
  • packages/authentication/modules/tests/utils/providers/InitialProfileProviderForTesting/index.tsx (1 hunks)
  • packages/authentication/modules/tests/utils/providers/InitialProfileProviderForTesting/types.ts (1 hunks)
  • packages/authentication/modules/tests/utils/providers/withAuthenticationTestProviders/index.tsx (1 hunks)
  • packages/authentication/modules/tests/utils/providers/withAuthenticationTestProviders/types.ts (1 hunks)
  • packages/authentication/package.json (1 hunks)
  • packages/authentication/services/auth.ts (1 hunks)
  • packages/authentication/services/user.ts (1 hunks)
  • packages/components/.storybook/decorators/index.ts (0 hunks)
  • packages/components/.storybook/decorators/withProviders.tsx (0 hunks)
  • packages/components/.storybook/preview.ts (2 hunks)
  • packages/components/__mocks__/expo-constants.ts (1 hunks)
  • packages/components/__mocks__/expo-modules-core.ts (1 hunks)
  • packages/components/__mocks__/expo-secure-store.ts (1 hunks)
  • packages/components/__mocks__/fetch.ts (1 hunks)
  • packages/components/__mocks__/file.ts (1 hunks)
  • packages/components/__mocks__/react-native.ts (1 hunks)
  • packages/components/__mocks__/style.ts (1 hunks)
  • packages/components/__test_utils__/withProviders/index.tsx (0 hunks)
  • packages/components/__test_utils__/withProviders/types.ts (0 hunks)
  • packages/components/baseapp-frontend-imports.d.ts (1 hunks)
  • packages/components/modules/comments/web/Comments/__tests__/__utils__/CommentsForTesting/index.tsx (2 hunks)
  • packages/components/modules/navigations/web/Header/AccountMenu/AccountPopover/__storybook__/stories.tsx (0 hunks)
  • packages/components/modules/navigations/web/Header/AccountMenu/AccountPopover/__tests__/AccountPopover.cy.tsx (3 hunks)
  • packages/components/modules/navigations/web/Header/AccountMenu/AccountPopover/__tests__/AccountPopoverForTesting/index.tsx (1 hunks)
  • packages/components/modules/navigations/web/Header/AccountMenu/AccountPopover/__tests__/__mocks__/profiles.ts (1 hunks)
  • packages/components/modules/navigations/web/Header/AccountMenu/AccountPopover/__tests__/withProviders/index.tsx (0 hunks)
  • packages/components/modules/navigations/web/Header/AccountMenu/AccountPopover/__tests__/withProviders/types.ts (0 hunks)
  • packages/components/modules/navigations/web/Header/__storybook__/stories.tsx (1 hunks)
  • packages/components/modules/navigations/web/NavMini/__storybook__/stories.tsx (1 hunks)
  • packages/components/modules/navigations/web/NavVertical/__storybook__/stories.tsx (1 hunks)
  • packages/components/modules/navigations/web/NavigationLayout/__storybook__/stories.tsx (1 hunks)
  • packages/components/modules/notifications/web/NotificationsList/__storybook__/stories.tsx (1 hunks)
  • packages/components/modules/notifications/web/NotificationsPopover/__tests__/NotificationsPopoverForTesting/index.tsx (1 hunks)
  • packages/components/modules/profiles/web/ProfileMembers/__tests__/__utils__/MembersForTesting/index.tsx (1 hunks)
  • packages/components/modules/tests/web/index.ts (1 hunks)
  • packages/components/modules/tests/web/utils/withComponentCompleteTestProviders/index.tsx (1 hunks)
  • packages/components/modules/tests/web/utils/withComponentTestProviders/index.tsx (1 hunks)
  • packages/components/modules/tests/web/utils/withComponentTestProviders/types.ts (1 hunks)
  • packages/components/package.json (1 hunks)
  • packages/design-system/.storybook/decorators/index.ts (0 hunks)
  • packages/design-system/.storybook/decorators/withProviders.tsx (0 hunks)
  • packages/design-system/.storybook/preview.ts (1 hunks)
  • packages/design-system/__mocks__/expo-constants.ts (1 hunks)
  • packages/design-system/package.json (1 hunks)
  • packages/design-system/providers/web/SnackbarProvider/__storybook__/stories.tsx (1 hunks)
  • packages/design-system/tests/commom/index.ts (1 hunks)
  • packages/design-system/tests/native/index.ts (1 hunks)
  • packages/design-system/tests/web/utils/__mocks__/theme.ts (1 hunks)
  • packages/design-system/tests/web/utils/index.ts (1 hunks)
  • packages/design-system/tests/web/utils/providers/ReactSuspenseWithLoading/index.tsx (1 hunks)
  • packages/design-system/tests/web/utils/providers/ReactSuspenseWithLoading/types.d.ts (1 hunks)
  • packages/design-system/tests/web/utils/providers/ThemeTestProvider/index.tsx (1 hunks)
  • packages/design-system/tests/web/utils/providers/ThemeTestProvider/types.ts (1 hunks)
  • packages/design-system/tests/web/utils/providers/withDesignSystemTestProviders/index.tsx (1 hunks)
  • packages/design-system/tests/web/utils/providers/withDesignSystemTestProviders/types.ts (1 hunks)
  • packages/design-system/tsconfig.build.json (1 hunks)
  • packages/design-system/tsup.config.ts (1 hunks)
  • packages/graphql/index.ts (1 hunks)
  • packages/graphql/package.json (1 hunks)
  • packages/graphql/providers/index.ts (0 hunks)
  • packages/graphql/tests/utils/index.ts (1 hunks)
  • packages/graphql/tests/utils/providers/withGraphqlTestProviders/index.tsx (1 hunks)
  • packages/graphql/tests/utils/providers/withGraphqlTestProviders/types.ts (1 hunks)
  • packages/test/package.json (1 hunks)
  • packages/test/providers/index.ts (1 hunks)
  • packages/test/providers/withStorybookProvidersWrapper/index.tsx (1 hunks)
  • packages/utils/__mocks__/expo-constants.ts (1 hunks)
  • packages/utils/__mocks__/expo-modules-core.ts (1 hunks)
  • packages/utils/__mocks__/expo-secure-store.ts (1 hunks)
  • packages/utils/__mocks__/fetch.ts (1 hunks)
  • packages/utils/__mocks__/file.ts (1 hunks)
  • packages/utils/__mocks__/react-native.ts (1 hunks)
  • packages/utils/__mocks__/style.ts (1 hunks)
  • packages/utils/constants/compose.ts (1 hunks)
  • packages/utils/functions/expo/index.ts (1 hunks)
  • packages/utils/index.ts (1 hunks)
  • packages/wagtail/.storybook/decorators/withProviders.tsx (1 hunks)
  • packages/wagtail/.storybook/preview.ts (2 hunks)
  • packages/wagtail/__mocks__/expo-constants.ts (1 hunks)
💤 Files with no reviewable changes (11)
  • packages/components/.storybook/decorators/index.ts
  • packages/authentication/modules/profile/index.ts
  • packages/components/modules/navigations/web/Header/AccountMenu/AccountPopover/storybook/stories.tsx
  • packages/design-system/.storybook/decorators/index.ts
  • packages/components/modules/navigations/web/Header/AccountMenu/AccountPopover/tests/withProviders/types.ts
  • packages/graphql/providers/index.ts
  • packages/design-system/.storybook/decorators/withProviders.tsx
  • packages/components/test_utils/withProviders/index.tsx
  • packages/components/.storybook/decorators/withProviders.tsx
  • packages/components/modules/navigations/web/Header/AccountMenu/AccountPopover/tests/withProviders/index.tsx
  • packages/components/test_utils/withProviders/types.ts
🚧 Files skipped from review as they are similar to previous changes (71)
  • packages/design-system/tests/native/index.ts
  • packages/test/providers/index.ts
  • packages/components/modules/navigations/web/Header/AccountMenu/AccountPopover/tests/mocks/profiles.ts
  • packages/design-system/tests/commom/index.ts
  • packages/authentication/index.ts
  • packages/graphql/index.ts
  • packages/components/modules/tests/web/utils/withComponentTestProviders/types.ts
  • packages/graphql/tests/utils/providers/withGraphqlTestProviders/types.ts
  • packages/test/package.json
  • packages/authentication/modules/tests/utils/providers/InitialProfileProviderForTesting/index.tsx
  • packages/authentication/modules/tests/utils/providers/withAuthenticationTestProviders/types.ts
  • packages/components/.storybook/preview.ts
  • packages/design-system/tests/web/utils/providers/ThemeTestProvider/types.ts
  • packages/utils/constants/compose.ts
  • packages/authentication/services/auth.ts
  • package.json
  • packages/components/mocks/fetch.ts
  • packages/utils/mocks/expo-constants.ts
  • packages/design-system/tsup.config.ts
  • packages/utils/index.ts
  • packages/authentication/package.json
  • packages/authentication/services/user.ts
  • packages/design-system/tests/web/utils/providers/withDesignSystemTestProviders/types.ts
  • packages/components/modules/profiles/web/ProfileMembers/tests/utils/MembersForTesting/index.tsx
  • packages/design-system/providers/web/SnackbarProvider/storybook/stories.tsx
  • packages/design-system/tests/web/utils/providers/ThemeTestProvider/index.tsx
  • packages/components/mocks/expo-secure-store.ts
  • packages/components/baseapp-frontend-imports.d.ts
  • packages/wagtail/mocks/expo-constants.ts
  • packages/authentication/modules/tests/utils/providers/InitialProfileProviderForTesting/types.ts
  • packages/components/modules/tests/web/index.ts
  • packages/utils/mocks/style.ts
  • packages/graphql/tests/utils/index.ts
  • packages/components/modules/navigations/web/NavigationLayout/storybook/stories.tsx
  • packages/utils/mocks/expo-secure-store.ts
  • packages/components/mocks/expo-modules-core.ts
  • packages/design-system/mocks/expo-constants.ts
  • packages/authentication/mocks/expo-constants.ts
  • packages/graphql/package.json
  • packages/components/package.json
  • packages/utils/functions/expo/index.ts
  • packages/design-system/.storybook/preview.ts
  • packages/design-system/tsconfig.build.json
  • packages/design-system/tests/web/utils/providers/ReactSuspenseWithLoading/index.tsx
  • packages/components/modules/tests/web/utils/withComponentTestProviders/index.tsx
  • packages/components/mocks/file.ts
  • packages/design-system/tests/web/utils/providers/ReactSuspenseWithLoading/types.d.ts
  • packages/components/mocks/expo-constants.ts
  • packages/components/modules/comments/web/Comments/tests/utils/CommentsForTesting/index.tsx
  • packages/test/providers/withStorybookProvidersWrapper/index.tsx
  • packages/components/modules/navigations/web/Header/storybook/stories.tsx
  • packages/design-system/tests/web/utils/providers/withDesignSystemTestProviders/index.tsx
  • packages/design-system/tests/web/utils/mocks/theme.ts
  • packages/components/modules/notifications/web/NotificationsPopover/tests/NotificationsPopoverForTesting/index.tsx
  • packages/components/mocks/style.ts
  • packages/authentication/modules/tests/utils/index.ts
  • packages/design-system/package.json
  • packages/components/modules/tests/web/utils/withComponentCompleteTestProviders/index.tsx
  • packages/wagtail/.storybook/preview.ts
  • packages/utils/mocks/file.ts
  • packages/utils/mocks/fetch.ts
  • packages/utils/mocks/expo-modules-core.ts
  • packages/components/modules/navigations/web/Header/AccountMenu/AccountPopover/tests/AccountPopover.cy.tsx
  • packages/graphql/tests/utils/providers/withGraphqlTestProviders/index.tsx
  • packages/components/modules/navigations/web/Header/AccountMenu/AccountPopover/tests/AccountPopoverForTesting/index.tsx
  • packages/components/modules/navigations/web/NavMini/storybook/stories.tsx
  • packages/components/mocks/react-native.ts
  • packages/components/modules/navigations/web/NavVertical/storybook/stories.tsx
  • packages/design-system/tests/web/utils/index.ts
  • packages/components/modules/notifications/web/NotificationsList/storybook/stories.tsx
  • packages/utils/mocks/react-native.ts
🔇 Additional comments (6)
packages/wagtail/.storybook/decorators/withProviders.tsx (3)

3-5: LGTM! Good provider imports

These imports correctly bring in the necessary provider components from the design system and GraphQL packages, along with the compose utility function. This aligns well with the PR objective of standardizing providers across test and Storybook environments.


7-7: Well implemented provider composition

The composition of providers using the compose utility creates a clean, maintainable approach to wrapping components with multiple providers. This implementation aligns perfectly with the PR objective of creating a shared wrapper for all required providers.

Note that the order of composition matters - withDesignSystemTestProviders will be applied first, then withGraphqlTestProviders.

Is this the intended order of provider application? Please verify that components rendered with this composition receive the providers in the correct order for proper context inheritance.


9-9: LGTM! Clean default export

The default export makes this composed provider easy to import and use in Storybook configurations.

packages/authentication/modules/tests/utils/providers/withAuthenticationTestProviders/index.tsx (3)

1-6: Good job importing necessary dependencies.

The imports are well organized with React imports first, followed by third-party libraries, and then local imports.


1-28: Good implementation of the provider HOC pattern.

This implementation aligns well with the PR objective of creating a shared wrapper for providers. The HOC pattern makes it easy to apply these providers consistently across tests and Storybook, which should help standardize component rendering across environments.


18-24:

❓ Verification inconclusive

Ensure props are passed correctly to the wrapped component.

The component spreads both {...props as Props} and {...context} to the wrapped Component. This could lead to prop name collisions if context contains properties that overlap with the Component's expected props.

Consider restructuring to be more explicit about which props from context should be passed to the Component. For example:

return (
  <JotaiProvider>
    <InitialProfileProviderForTesting initialProfile={currentProfile}>
-     <Component {...(props as Props)} {...context} />
+     <Component 
+       {...(props as Props)}
+       // Only spread specific needed props from context, or
+       // Be more explicit about which context props you need
+     />
    </InitialProfileProviderForTesting>
  </JotaiProvider>
)

🏁 Script executed:

#!/bin/bash
# Search for context usage in component props to understand the expected structure
rg --type typescript -A 2 -B 2 "context\s*[,}]" --glob "packages/authentication/**/*.tsx"

Length of output: 126


#!/bin/bash
# Re-run the search using the correct file type (tsx) to detect context usage in spread props.
rg --type tsx -A 2 -B 2 "context\s*[,}]" packages/authentication/**/*.tsx

@priscilladeroode priscilladeroode force-pushed the BA-2287-fe-unify-test-and-storybook-providers branch from 6293227 to 8764e32 Compare April 2, 2025 04:06
@priscilladeroode priscilladeroode force-pushed the BA-2287-fe-unify-test-and-storybook-providers branch from 8764e32 to 84bcb9c Compare April 3, 2025 19:46
@sonarqubecloud
Copy link

sonarqubecloud bot commented Apr 3, 2025

Copy link

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 1

🧹 Nitpick comments (13)
packages/wagtail/__mocks__/expo-constants.ts (1)

1-3: Transition from CommonJS to ES Module syntax looks good but consider full ES Module syntax

The code is transitioning from CommonJS to ES Module syntax, which aligns with the PR's objective of standardizing providers. However, it's using a mixed approach with CommonJS require for importing and ES Module export default for exporting.

For complete standardization, consider using full ES Module syntax:

-const Constants = require('@baseapp-frontend/test/__mocks__/expo-constants.ts')
+import Constants from '@baseapp-frontend/test/__mocks__/expo-constants.ts'

export default Constants

This would provide better consistency and compatibility with modern JavaScript/TypeScript practices, especially if other files in the project are moving toward ES Modules.

packages/authentication/__mocks__/style.ts (2)

1-3: Consider using consistent module syntax

While the change from CommonJS to ES module exports is good, the file still uses CommonJS-style imports (require()) mixed with ES module exports (export default). Consider using ES module imports for consistency:

-const Style = require('@baseapp-frontend/test/__mocks__/style.ts')
+import Style from '@baseapp-frontend/test/__mocks__/style.ts'

export default Style

This would make the module syntax consistent throughout the file and follow modern JavaScript practices.


1-1: Consider removing the file extension from import path

The import statement includes the .ts file extension in the path, which is generally not necessary in TypeScript imports and might cause issues in certain build configurations:

-const Style = require('@baseapp-frontend/test/__mocks__/style.ts')
+const Style = require('@baseapp-frontend/test/__mocks__/style')

This would make the import more resilient to potential file extension changes and align with TypeScript best practices.

packages/design-system/tests/web/utils/providers/ReactSuspenseWithLoading/index.tsx (2)

3-3: Consider using a more maintainable import path.

The deeply nested relative import (../../../../../components/web/displays) could become fragile if the directory structure changes. Consider using path aliases or a more direct import method if this is a common pattern in your codebase.


6-16: Add JSDoc comments for better documentation.

Consider adding JSDoc comments to explain the component's purpose and how to use it, especially since it's going to be shared between test and Storybook environments.

+/**
+ * A wrapper component that conditionally applies React.Suspense with a loading fallback.
+ * When disabled is true, children are rendered directly without Suspense.
+ * 
+ * @param {ReactNode} children - The content to render
+ * @param {ComponentType} CustomFallback - Optional custom component to show during loading
+ * @param {boolean} disabled - Whether to disable the Suspense wrapper
+ */
const ReactSuspenseWithLoading: FC<ReactSuspenseWithLoadingProps> = ({
  children,
  CustomFallback = LoadingState,
  disabled = false,
}) => {
packages/utils/functions/compose/index.ts (2)

4-5: Consider improving type safety by using generics.

The current implementation uses any types which could lead to type-related issues. Consider using TypeScript generics to provide better type safety while maintaining flexibility:

- export const compose =
-   (...hocs: any[]) =>
-   (Component: FC<any>) =>
+ export const compose = 
+   <P extends object>(...hocs: Array<(Component: FC<any>) => FC<any>>) =>
+   (Component: FC<P>): FC<P> =>

3-6: Add JSDoc comments to document the utility function.

Adding JSDoc comments would improve code documentation and provide better IDE intellisense support for developers using this function.

+/**
+ * Composes multiple higher-order components (HOCs) into a single HOC.
+ * HOCs are applied from right to left (the rightmost HOC is applied first).
+ * 
+ * @param hocs - Array of higher-order components to compose
+ * @returns A single HOC that applies all the input HOCs in sequence
+ * @example
+ * // Instead of writing:
+ * // export default withTheme(withRouter(withAuth(MyComponent)))
+ * // You can write:
+ * // export default compose(withTheme, withRouter, withAuth)(MyComponent)
+ */
 export const compose =
   (...hocs: any[]) =>
   (Component: FC<any>) =>
     hocs.reduceRight((AccumulatedComponent, hoc) => hoc(AccumulatedComponent), Component)
packages/components/modules/tests/web/utils/withComponentTestProviders/index.tsx (2)

7-13: Consider isolating the QueryClient between test runs.

Creating a static QueryClient instance could potentially cause test state to bleed between tests if they run in parallel. For better test isolation, consider creating a new instance per component render.

-const defaultQueryClient = new QueryClient({
-  defaultOptions: {
-    queries: {
-      retry: false,
-    },
-  },
-})

 const withComponentTestProviders =
   <Props extends object>(Component: FC<Props>) =>
   (props: Props & WithComponentTestProvidersProps) => {
     const { queryClient, ...restProps } = props
+    const defaultQueryClient = new QueryClient({
+      defaultOptions: {
+        queries: {
+          retry: false,
+        },
+      },
+    })

1-28: Add JSDoc documentation for better code usability.

Adding JSDoc comments would improve the understanding of this HOC's purpose and usage, especially since it's part of a shared utility for tests and Storybook.

+/**
+ * Higher-order component that wraps a component with QueryClientProvider for testing purposes.
+ * This is part of the unified provider system for tests and Storybook.
+ * 
+ * @param Component - The React component to wrap
+ * @returns A new component wrapped with QueryClientProvider
+ */
 const withComponentTestProviders =
   <Props extends object>(Component: FC<Props>) =>
   (props: Props & WithComponentTestProvidersProps) => {
packages/authentication/__mocks__/fetch.ts (1)

1-3: LGTM, but consider using consistent module syntax.

The change from CommonJS to ES Module export aligns with the PR objectives of standardizing configurations. However, the code mixes CommonJS (require) with ES Module syntax (export default). While this works with transpilation, consider using consistent ES Module syntax throughout:

import Fetch from '@baseapp-frontend/test/__mocks__/fetch.ts';
export default Fetch;
packages/utils/__mocks__/fetch.ts (1)

1-3: LGTM, but consider using consistent module syntax.

The restructuring of the fetch mock improves code organization by separating import and export statements. However, like the other mock files, this mixes CommonJS (require) with ES Module syntax (export default). While functional, consider using consistent ES Module syntax for improved maintainability:

import Fetch from '@baseapp-frontend/test/__mocks__/fetch.ts';
export default Fetch;
packages/wagtail/__mocks__/expo-secure-store.ts (1)

1-3: Consider using consistent ES Module syntax for both import and export.

The file currently uses CommonJS syntax (require) for importing but ES Module syntax (export default) for exporting. While this mixed approach works in environments that support both syntaxes, it would be more consistent to use ES Module syntax throughout:

- const ExpoSecureStore = require('@baseapp-frontend/test/__mocks__/expo-secure-store.ts')
+ import ExpoSecureStore from '@baseapp-frontend/test/__mocks__/expo-secure-store.ts'

export default ExpoSecureStore

This change would align with the PR's goal of standardizing across the codebase and follow modern JavaScript best practices.

packages/wagtail/.storybook/decorators/withProviders.tsx (1)

1-1: Unused import can be removed.

The FC type is imported from React but not used in this file. Consider removing it to keep imports clean.

-import { FC } from 'react'
📜 Review details

Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between 8764e32 and 28557d5.

⛔ Files ignored due to path filters (1)
  • pnpm-lock.yaml is excluded by !**/pnpm-lock.yaml
📒 Files selected for processing (106)
  • package.json (1 hunks)
  • packages/authentication/CHANGELOG.md (1 hunks)
  • packages/authentication/__mocks__/expo-constants.ts (1 hunks)
  • packages/authentication/__mocks__/expo-modules-core.ts (1 hunks)
  • packages/authentication/__mocks__/expo-secure-store.ts (1 hunks)
  • packages/authentication/__mocks__/fetch.ts (1 hunks)
  • packages/authentication/__mocks__/file.ts (1 hunks)
  • packages/authentication/__mocks__/react-native.ts (1 hunks)
  • packages/authentication/__mocks__/style.ts (1 hunks)
  • packages/authentication/index.ts (1 hunks)
  • packages/authentication/modules/profile/index.ts (0 hunks)
  • packages/authentication/modules/tests/utils/index.ts (1 hunks)
  • packages/authentication/modules/tests/utils/providers/InitialProfileProviderForTesting/index.tsx (1 hunks)
  • packages/authentication/modules/tests/utils/providers/InitialProfileProviderForTesting/types.ts (1 hunks)
  • packages/authentication/modules/tests/utils/providers/withAuthenticationTestProviders/index.tsx (1 hunks)
  • packages/authentication/modules/tests/utils/providers/withAuthenticationTestProviders/types.ts (1 hunks)
  • packages/authentication/package.json (2 hunks)
  • packages/authentication/services/auth.ts (1 hunks)
  • packages/authentication/services/user.ts (1 hunks)
  • packages/components/.storybook/decorators/index.ts (0 hunks)
  • packages/components/.storybook/decorators/withProviders.tsx (0 hunks)
  • packages/components/.storybook/preview.ts (2 hunks)
  • packages/components/CHANGELOG.md (1 hunks)
  • packages/components/__mocks__/expo-constants.ts (1 hunks)
  • packages/components/__mocks__/expo-modules-core.ts (1 hunks)
  • packages/components/__mocks__/expo-secure-store.ts (1 hunks)
  • packages/components/__mocks__/fetch.ts (1 hunks)
  • packages/components/__mocks__/file.ts (1 hunks)
  • packages/components/__mocks__/react-native.ts (1 hunks)
  • packages/components/__mocks__/style.ts (1 hunks)
  • packages/components/__test_utils__/withProviders/index.tsx (0 hunks)
  • packages/components/__test_utils__/withProviders/types.ts (0 hunks)
  • packages/components/baseapp-frontend-imports.d.ts (1 hunks)
  • packages/components/modules/comments/web/Comments/__tests__/__utils__/CommentsForTesting/index.tsx (2 hunks)
  • packages/components/modules/navigations/web/Header/AccountMenu/AccountPopover/__storybook__/stories.tsx (0 hunks)
  • packages/components/modules/navigations/web/Header/AccountMenu/AccountPopover/__tests__/AccountPopover.cy.tsx (3 hunks)
  • packages/components/modules/navigations/web/Header/AccountMenu/AccountPopover/__tests__/AccountPopoverForTesting/index.tsx (1 hunks)
  • packages/components/modules/navigations/web/Header/AccountMenu/AccountPopover/__tests__/__mocks__/profiles.ts (1 hunks)
  • packages/components/modules/navigations/web/Header/AccountMenu/AccountPopover/__tests__/withProviders/index.tsx (0 hunks)
  • packages/components/modules/navigations/web/Header/AccountMenu/AccountPopover/__tests__/withProviders/types.ts (0 hunks)
  • packages/components/modules/navigations/web/Header/__storybook__/stories.tsx (1 hunks)
  • packages/components/modules/navigations/web/NavMini/__storybook__/stories.tsx (1 hunks)
  • packages/components/modules/navigations/web/NavVertical/__storybook__/stories.tsx (1 hunks)
  • packages/components/modules/navigations/web/NavigationLayout/__storybook__/stories.tsx (1 hunks)
  • packages/components/modules/notifications/web/NotificationsList/__storybook__/stories.tsx (1 hunks)
  • packages/components/modules/notifications/web/NotificationsPopover/__tests__/NotificationsPopoverForTesting/index.tsx (1 hunks)
  • packages/components/modules/profiles/web/ProfileMembers/__tests__/__utils__/MembersForTesting/index.tsx (1 hunks)
  • packages/components/modules/tests/web/index.ts (1 hunks)
  • packages/components/modules/tests/web/utils/withComponentCompleteTestProviders/index.tsx (1 hunks)
  • packages/components/modules/tests/web/utils/withComponentTestProviders/index.tsx (1 hunks)
  • packages/components/modules/tests/web/utils/withComponentTestProviders/types.ts (1 hunks)
  • packages/components/package.json (2 hunks)
  • packages/design-system/.storybook/decorators/index.ts (0 hunks)
  • packages/design-system/.storybook/decorators/withProviders.tsx (0 hunks)
  • packages/design-system/.storybook/preview.ts (1 hunks)
  • packages/design-system/CHANGELOG.md (1 hunks)
  • packages/design-system/__mocks__/expo-constants.ts (1 hunks)
  • packages/design-system/__mocks__/expo-secure-store.ts (1 hunks)
  • packages/design-system/__mocks__/react-native.ts (1 hunks)
  • packages/design-system/package.json (2 hunks)
  • packages/design-system/providers/web/SnackbarProvider/__storybook__/stories.tsx (1 hunks)
  • packages/design-system/tests/commom/index.ts (1 hunks)
  • packages/design-system/tests/native/index.ts (1 hunks)
  • packages/design-system/tests/web/utils/__mocks__/theme.ts (1 hunks)
  • packages/design-system/tests/web/utils/index.ts (1 hunks)
  • packages/design-system/tests/web/utils/providers/ReactSuspenseWithLoading/index.tsx (1 hunks)
  • packages/design-system/tests/web/utils/providers/ReactSuspenseWithLoading/types.d.ts (1 hunks)
  • packages/design-system/tests/web/utils/providers/ThemeTestProvider/index.tsx (1 hunks)
  • packages/design-system/tests/web/utils/providers/ThemeTestProvider/types.ts (1 hunks)
  • packages/design-system/tests/web/utils/providers/withDesignSystemTestProviders/index.tsx (1 hunks)
  • packages/design-system/tests/web/utils/providers/withDesignSystemTestProviders/types.ts (1 hunks)
  • packages/design-system/tsconfig.build.json (1 hunks)
  • packages/design-system/tsup.config.ts (1 hunks)
  • packages/graphql/CHANGELOG.md (1 hunks)
  • packages/graphql/index.ts (1 hunks)
  • packages/graphql/package.json (2 hunks)
  • packages/graphql/providers/index.ts (0 hunks)
  • packages/graphql/tests/utils/index.ts (1 hunks)
  • packages/graphql/tests/utils/providers/withGraphqlTestProviders/index.tsx (1 hunks)
  • packages/graphql/tests/utils/providers/withGraphqlTestProviders/types.ts (1 hunks)
  • packages/provider/CHANGELOG.md (1 hunks)
  • packages/provider/package.json (1 hunks)
  • packages/test/CHANGELOG.md (1 hunks)
  • packages/test/package.json (2 hunks)
  • packages/test/providers/index.ts (1 hunks)
  • packages/test/providers/withStorybookProvidersWrapper/index.tsx (1 hunks)
  • packages/utils/CHANGELOG.md (1 hunks)
  • packages/utils/__mocks__/expo-constants.ts (1 hunks)
  • packages/utils/__mocks__/expo-modules-core.ts (1 hunks)
  • packages/utils/__mocks__/expo-secure-store.ts (1 hunks)
  • packages/utils/__mocks__/fetch.ts (1 hunks)
  • packages/utils/__mocks__/file.ts (1 hunks)
  • packages/utils/__mocks__/react-native.ts (1 hunks)
  • packages/utils/__mocks__/style.ts (1 hunks)
  • packages/utils/functions/compose/index.ts (1 hunks)
  • packages/utils/functions/expo/index.ts (1 hunks)
  • packages/utils/index.ts (1 hunks)
  • packages/utils/package.json (1 hunks)
  • packages/wagtail/.storybook/decorators/withProviders.tsx (1 hunks)
  • packages/wagtail/.storybook/preview.ts (2 hunks)
  • packages/wagtail/CHANGELOG.md (1 hunks)
  • packages/wagtail/__mocks__/expo-constants.ts (1 hunks)
  • packages/wagtail/__mocks__/expo-modules-core.ts (1 hunks)
  • packages/wagtail/__mocks__/expo-secure-store.ts (1 hunks)
  • packages/wagtail/__mocks__/react-native.ts (1 hunks)
  • packages/wagtail/package.json (1 hunks)
💤 Files with no reviewable changes (11)
  • packages/components/.storybook/decorators/index.ts
  • packages/components/modules/navigations/web/Header/AccountMenu/AccountPopover/storybook/stories.tsx
  • packages/graphql/providers/index.ts
  • packages/design-system/.storybook/decorators/withProviders.tsx
  • packages/components/test_utils/withProviders/types.ts
  • packages/components/.storybook/decorators/withProviders.tsx
  • packages/components/modules/navigations/web/Header/AccountMenu/AccountPopover/tests/withProviders/types.ts
  • packages/components/test_utils/withProviders/index.tsx
  • packages/components/modules/navigations/web/Header/AccountMenu/AccountPopover/tests/withProviders/index.tsx
  • packages/authentication/modules/profile/index.ts
  • packages/design-system/.storybook/decorators/index.ts
✅ Files skipped from review due to trivial changes (7)
  • packages/wagtail/package.json
  • packages/authentication/CHANGELOG.md
  • packages/design-system/CHANGELOG.md
  • packages/provider/package.json
  • packages/utils/package.json
  • packages/utils/CHANGELOG.md
  • packages/components/CHANGELOG.md
🚧 Files skipped from review as they are similar to previous changes (66)
  • packages/design-system/tests/native/index.ts
  • packages/test/providers/index.ts
  • packages/components/modules/navigations/web/Header/AccountMenu/AccountPopover/tests/mocks/profiles.ts
  • packages/design-system/tests/commom/index.ts
  • packages/authentication/index.ts
  • packages/components/modules/profiles/web/ProfileMembers/tests/utils/MembersForTesting/index.tsx
  • packages/authentication/modules/tests/utils/providers/withAuthenticationTestProviders/types.ts
  • packages/authentication/package.json
  • packages/authentication/modules/tests/utils/providers/InitialProfileProviderForTesting/types.ts
  • packages/components/mocks/expo-modules-core.ts
  • packages/test/package.json
  • packages/utils/index.ts
  • packages/components/modules/navigations/web/NavigationLayout/storybook/stories.tsx
  • packages/components/.storybook/preview.ts
  • packages/design-system/providers/web/SnackbarProvider/storybook/stories.tsx
  • packages/utils/functions/expo/index.ts
  • packages/design-system/tests/web/utils/providers/ReactSuspenseWithLoading/types.d.ts
  • packages/components/modules/notifications/web/NotificationsList/storybook/stories.tsx
  • packages/graphql/tests/utils/providers/withGraphqlTestProviders/types.ts
  • packages/components/baseapp-frontend-imports.d.ts
  • packages/components/modules/tests/web/index.ts
  • packages/components/mocks/fetch.ts
  • packages/test/providers/withStorybookProvidersWrapper/index.tsx
  • packages/design-system/tests/web/utils/providers/withDesignSystemTestProviders/types.ts
  • packages/components/modules/tests/web/utils/withComponentTestProviders/types.ts
  • packages/authentication/services/auth.ts
  • packages/utils/mocks/file.ts
  • packages/graphql/index.ts
  • packages/design-system/tests/web/utils/providers/ThemeTestProvider/index.tsx
  • packages/design-system/mocks/expo-constants.ts
  • packages/authentication/modules/tests/utils/index.ts
  • packages/design-system/tsup.config.ts
  • packages/utils/mocks/expo-modules-core.ts
  • packages/authentication/mocks/expo-constants.ts
  • packages/authentication/services/user.ts
  • package.json
  • packages/authentication/modules/tests/utils/providers/withAuthenticationTestProviders/index.tsx
  • packages/components/mocks/file.ts
  • packages/components/modules/tests/web/utils/withComponentCompleteTestProviders/index.tsx
  • packages/graphql/tests/utils/providers/withGraphqlTestProviders/index.tsx
  • packages/components/modules/navigations/web/NavMini/storybook/stories.tsx
  • packages/utils/mocks/expo-secure-store.ts
  • packages/components/modules/comments/web/Comments/tests/utils/CommentsForTesting/index.tsx
  • packages/design-system/tests/web/utils/providers/ThemeTestProvider/types.ts
  • packages/components/mocks/expo-constants.ts
  • packages/design-system/tests/web/utils/mocks/theme.ts
  • packages/graphql/tests/utils/index.ts
  • packages/design-system/package.json
  • packages/wagtail/.storybook/preview.ts
  • packages/components/modules/navigations/web/NavVertical/storybook/stories.tsx
  • packages/components/modules/notifications/web/NotificationsPopover/tests/NotificationsPopoverForTesting/index.tsx
  • packages/components/package.json
  • packages/utils/mocks/expo-constants.ts
  • packages/authentication/modules/tests/utils/providers/InitialProfileProviderForTesting/index.tsx
  • packages/utils/mocks/style.ts
  • packages/components/mocks/expo-secure-store.ts
  • packages/components/modules/navigations/web/Header/storybook/stories.tsx
  • packages/utils/mocks/react-native.ts
  • packages/design-system/tests/web/utils/index.ts
  • packages/design-system/.storybook/preview.ts
  • packages/design-system/tests/web/utils/providers/withDesignSystemTestProviders/index.tsx
  • packages/components/modules/navigations/web/Header/AccountMenu/AccountPopover/tests/AccountPopoverForTesting/index.tsx
  • packages/design-system/tsconfig.build.json
  • packages/components/mocks/react-native.ts
  • packages/graphql/package.json
  • packages/components/modules/navigations/web/Header/AccountMenu/AccountPopover/tests/AccountPopover.cy.tsx
🧰 Additional context used
🧬 Code Definitions (2)
packages/design-system/tests/web/utils/providers/ReactSuspenseWithLoading/index.tsx (2)
packages/design-system/tests/web/utils/index.ts (1)
  • ReactSuspenseWithLoadingProps (7-7)
packages/design-system/tests/web/utils/providers/ReactSuspenseWithLoading/types.d.ts (1)
  • ReactSuspenseWithLoadingProps (3-6)
packages/components/modules/tests/web/utils/withComponentTestProviders/index.tsx (1)
packages/components/modules/tests/web/utils/withComponentTestProviders/types.ts (1)
  • WithComponentTestProvidersProps (3-5)
🔇 Additional comments (21)
packages/test/CHANGELOG.md (1)

3-7: Clear and Consistent Changelog Entry for Version 2.1.2

This new entry documents the unification of test and Storybook providers succinctly and in line with the PR objectives. The version bump and concise patch note help maintain transparency with consumers of this package.

packages/wagtail/CHANGELOG.md (1)

3-11: Well-Documented Update in Wagtail Changelog for Version 1.0.29

The entry clearly lists the unification of test and Storybook providers along with the updated dependencies, making it easy for users to track changes. It aligns nicely with the overarching effort to streamline provider setups.

packages/provider/CHANGELOG.md (1)

3-9: Provider Package Changelog Update is Consistent

The version bump to 2.0.13 with an updated dependency on @baseapp-frontend/utils (from 3.1.5 to 3.1.6) is clearly recorded. Since this package is not directly affected by the unification of test and Storybook providers, the entry remains focused and appropriate.

packages/graphql/CHANGELOG.md (1)

3-10: GraphQL Package Changelog Entry Accurately Reflects Changes

The changelog for version 1.2.7 repeatedly notes the unification of test and Storybook providers and updates the dependency to @baseapp-frontend/utils@3.1.6. This entry is clear, informative, and consistent with the other package updates within this coordinated effort.

packages/authentication/__mocks__/style.ts (1)

1-3: LGTM on updating to ES module exports

The change from CommonJS module.exports to ES module export default aligns with the PR objectives of standardizing providers across test and Storybook environments. This syntax modernization is a positive step.

packages/design-system/tests/web/utils/providers/ReactSuspenseWithLoading/index.tsx (1)

1-18: Well-structured React Suspense wrapper component.

The implementation provides a clean abstraction over React's Suspense with sensible defaults. This component will help standardize loading state handling across both testing and Storybook environments, aligning with the PR's goal of unifying providers.

packages/utils/functions/compose/index.ts (2)

1-6: Solid implementation of a compose utility for HOCs.

The implementation correctly uses reduceRight to apply HOCs from right to left, which is the conventional way HOCs are composed in React.


1-6: This utility aligns well with the PR objective of unifying providers.

The compose function will help standardize how providers are applied across different environments (tests and Storybook), meeting the PR goal of creating a shared wrapper for all required providers.

packages/components/modules/tests/web/utils/withComponentTestProviders/index.tsx (2)

1-5: Good organization of imports.

The imports are well-organized with React imports first, followed by external dependencies, and then local imports with appropriate spacing.


15-25: Well-implemented HOC with proper type handling.

The higher-order component implementation correctly preserves the original component's props types while adding the additional provider props. The use of generics with Props extends object and the proper destructuring of the provider-specific props are good practices.

packages/design-system/__mocks__/expo-secure-store.ts (1)

1-3: Approved: Successfully updated to ES Module syntax

The change from CommonJS to ES Module syntax for exporting the mock is consistent with the PR's goal of standardizing providers across test and Storybook environments.

packages/authentication/__mocks__/expo-secure-store.ts (1)

1-3: Approved: Consistent implementation with design-system package

This change follows the same pattern as the design-system package, maintaining consistency across packages while updating to ES Module syntax. Good job centralizing the mock implementation.

packages/authentication/__mocks__/expo-modules-core.ts (1)

1-3: Approved: Consistent mock export pattern

This update to ES Module syntax follows the consistent pattern applied to other mock files, supporting the PR objective of unifying provider approaches across environments.

packages/authentication/__mocks__/file.ts (1)

1-3: Approved: Standardized export approach

The change completes the pattern of standardizing mock exports to ES Module syntax. This enhancement improves consistency and compatibility across test and Storybook environments.

packages/authentication/__mocks__/react-native.ts (1)

1-3: Improved module export syntax.

The change from CommonJS module.exports to ES Module syntax with named import and default export aligns with modern JavaScript practices and the standardization effort described in the PR objectives.

packages/wagtail/__mocks__/react-native.ts (1)

1-3: Modernized module export pattern.

This change is consistent with the transition from CommonJS to ES Module syntax seen across other mock files, supporting the PR's goal of standardizing providers across test and Storybook environments.

packages/wagtail/__mocks__/expo-modules-core.ts (1)

1-3: Unified export pattern with ES Module syntax.

The conversion from CommonJS to ES Module syntax aligns with the standardization efforts across the codebase, making the mock imports consistent with modern JavaScript practices.

packages/components/__mocks__/style.ts (1)

1-3: Standardized mock export using ES Module syntax.

This change follows the same pattern seen in other mock files, creating consistency in how mocks are exported and imported. The transition to ES Module syntax aligns with modern JavaScript practices.

packages/wagtail/.storybook/decorators/withProviders.tsx (3)

3-5: Good refactoring to reuse existing provider components.

The imports bring in reusable provider components from the design system and graphql packages, which aligns with the PR objective of unifying test and Storybook providers.


9-9: Updated default export aligns with new implementation.

The default export now uses the new function name, maintaining consistency.


7-7:

❓ Verification inconclusive

Excellent use of composition pattern.

Using composition to combine providers is a clean pattern that makes the code more maintainable. This successfully implements the shared wrapper mentioned in the PR objectives.

One recommendation: verify that the order of composition (graphql first, then design system) is correct, as the order can matter depending on provider dependencies.


🏁 Script executed:

#!/bin/bash
# Check implementations of both providers to verify correct composition order
echo "Checking withGraphqlTestProviders implementation:"
fd -t f -e ts -e tsx "withGraphqlTestProviders" --exec cat {} \;

echo -e "\nChecking withDesignSystemTestProviders implementation:"
fd -t f -e ts -e tsx "withDesignSystemTestProviders" --exec cat {} \;

Length of output: 374


Re-check Composition Order for Providers

Excellent application of the composition pattern in combining providers. The use of the shared wrapper in packages/wagtail/.storybook/decorators/withProviders.tsx cleanly integrates both GraphQL and Design System test providers, aligning well with the PR objectives.

However, our initial search for the implementations of withGraphqlTestProviders and withDesignSystemTestProviders did not return any content. Please double-check manually that:

  • The implementation of withGraphqlTestProviders indeed initializes required context before the Design System provider.
  • The ordering (GraphQL first, then Design System) satisfies the dependency needs internally.

Verifying that the composition order is intentional and based on provider dependencies will ensure maintainability and avoid potential side effects.

@priscilladeroode priscilladeroode merged commit cffe402 into master Apr 4, 2025
8 checks passed
@nossila nossila deleted the BA-2287-fe-unify-test-and-storybook-providers branch May 26, 2025 21:14
@coderabbitai coderabbitai bot mentioned this pull request Jul 8, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

needs review PR needs to be reviewed.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants