Skip to content

Bugfix/issues 361#362

Open
mahendra-vml wants to merge 2 commits intoSitecore:devfrom
mahendra-vml:bugfix/issues-361
Open

Bugfix/issues 361#362
mahendra-vml wants to merge 2 commits intoSitecore:devfrom
mahendra-vml:bugfix/issues-361

Conversation

@mahendra-vml
Copy link

Description / Motivation

Issue: #361 (referenced by branch name bugfix/issues-361)

This PR refactors the withDatasourceCheck and withDatasourceCheck tests in sitecore-content-sdk/react to:

  • Resolve Error: useSitecore hook invoked within Server Component using withDatasourceCheck #361 by removing the useSitecore(); and update it as per props?.page;
  • Remove dependency on SitecoreProviderReactContext from tests
  • Replace mockContext helper with mockPage helper that creates Page objects directly
  • Simplify test setup by passing page prop directly to components instead of wrapping in Provider
  • Remove test for "not within SitecoreProvider" scenario (no longer applicable)
  • Export Page and PageMode types from the enhancer for test usage

Files Changed:

  • withDatasourceCheck.tsx - Added type exports
  • withDatasourceCheck.test.tsx - Refactored tests

Testing Details

  • Unit Test Added
  • Manual Test/Other (Please elaborate)

Types of changes

  • Bug fix (non-breaking change which fixes an issue)
  • New feature (non-breaking change which adds functionality)
  • Breaking change (fix or feature that would cause existing functionality to change)

Remove useSitecore dependency from withDatasourceCheck enhancer

Replace useSitecore hook with direct pageState and libraryMode props to decouple the enhancer from Sitecore context. Add PageMode and Page type definitions for compatibility. Update isEditing and isDesignLibrary checks to use props instead of context.
…itecoreProvider context

Remove SitecoreProviderReactContext dependency from tests and replace mockContext helper with mockPage helper that creates Page objects directly. Simplify test setup by passing page prop directly to components instead of wrapping in Provider. Remove test for "not within SitecoreProvider" scenario as it's no longer applicable. Export Page and PageMode types from enhancer for test usage.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Error: useSitecore hook invoked within Server Component using withDatasourceCheck

1 participant