Conversation
…add hook tests - Delete AvailabilityReducer.ts (dead code, zero references) - Re-export SkuAvailability from @commercelayer/core in public index - Add useAvailability.test.ts with 8 test cases covering initial state, fetch by skuCode, clear, error handling, isLoading state, and null return Closes #744
Storybook stories in the document package use internal helpers (CommerceLayer, OrderStorage) that import via '#components/*' and other path aliases defined in the react-components tsconfig. Because those files live in the document package, vite-tsconfig-paths could not match them to the react-components project scope and failed to resolve the imports at pre-bundling time. Fix by adding explicit 'resolve.alias' entries in viteFinal so all '#components/*', '#context/*', '#hooks/*', '#typings/*', '#utils/*', '#config/*', '#reducers/*' and '#components-utils/*' paths are reliably resolved to the react-components source tree regardless of which file triggers the import. Also includes: - Fix stories glob path (../stories → ../src/stories) - New availability MDX docs and 9 interactive stories - Add missing npm dependencies (@commercelayer/react-components, @commercelayer/js-auth, js-cookie, jwt-decode, @types/js-cookie)
commit: |
6 tasks
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Closes #744
Completes the Availability refactor to use hooks and core packages exclusively, plus adds Storybook stories to the
documentpackage.Changes
🗑️ Deleted
packages/react-components/src/reducers/AvailabilityReducer.ts— dead code with zero references; all types and logic have been superseded by@commercelayer/coreand@commercelayer/hooks📦 Exports
SkuAvailabilitytype from@commercelayer/corein the publicindex.ts, making it available to consumers of@commercelayer/react-components✅ Tests
packages/hooks/src/availability/useAvailability.test.tswith 8 unit tests covering:skuCode→ returns mockedSkuAvailabilityerroris set)isLoadingtransitions during fetchnullreturn for unknown SKUskuCodenorskuIdprovided📖 Stories (
packages/document)../stories/**→../src/stories/**)resolve.aliasentries in.storybook/main.tsso#components/*,#context/*,#hooks/*,#typings/*,#utils/*,#config/*,#reducers/*aliases resolve correctly for files outside thereact-componentspackage scopepackages/document/src/stories/availability/001.availability.mdx— full MDX documentation pagepackages/document/src/stories/availability/availability.stories.tsx— 9 interactive stories coveringAvailabilityContainer,AvailabilityTemplate,DeliveryLeadTime, andSkusContainerintegrationTest results
All 46
@commercelayer/react-componentstests pass ✅All 36
@commercelayer/hookstests pass ✅