|
1 | 1 | # Changelog
|
2 | 2 |
|
| 3 | +## 1.5.0 |
| 4 | + |
| 5 | +### Minor Changes |
| 6 | + |
| 7 | +- Special thank you to @kcarra for adding new mocked Providers for making testing easier! ([#2224](https://github.com/Shopify/hydrogen/pull/2224)) by [@blittle](https://github.com/blittle) |
| 8 | + |
| 9 | + 1. Add `ServerRequestProvider` mock for testing server components: |
| 10 | + |
| 11 | + ```ts |
| 12 | + import useServerHook from './useServerHook.server'; // Server hook to test |
| 13 | + import {test, vi} from 'vitest'; |
| 14 | + import {renderHook} from '@testing-library/react-hooks'; |
| 15 | + import {ShopifyProvider} from '@shopify/hydrogen'; |
| 16 | + import {MockedServerRequestProvider} from '@shopify/hydrogen/testing'; |
| 17 | + |
| 18 | + describe('useServerHook', () => { |
| 19 | + test('mocked ServerRequest Context', () => { |
| 20 | + const wrapper = ({children}: {children: React.ReactElement}) => ( |
| 21 | + <MockedServerRequestProvider> |
| 22 | + <ShopifyProvider shopifyConfig={mockShopifyConfig}> |
| 23 | + {children} |
| 24 | + </ShopifyProvider> |
| 25 | + </MockedServerRequestProvider> |
| 26 | + ); |
| 27 | + const {result} = renderHook(() => useServerHook(), {wrapper}); |
| 28 | + expect(result.current).toEqual({status: 'active'}); |
| 29 | + }); |
| 30 | + }); |
| 31 | + ``` |
| 32 | + |
| 33 | + 2. Add `ShopifyTestProviders` mock for easier testing client components and using client components in other contexts, like Storybook: |
| 34 | + |
| 35 | + ```ts |
| 36 | + import {ComponentMeta, ComponentStory} from '@storybook/react'; |
| 37 | + import React from 'react'; |
| 38 | + import BoxCardUI from './BoxCard.ui'; |
| 39 | + import {ShopifyTestProviders} from '@shopify/hydrogen/testing'; |
| 40 | + |
| 41 | + export default { |
| 42 | + title: 'Components/BoxCard', |
| 43 | + component: BoxCardUI, |
| 44 | + decorators: [], |
| 45 | + } as ComponentMeta<typeof BoxCardUI>; |
| 46 | + |
| 47 | + const Template: ComponentStory<typeof BoxCardUI> = (args) => { |
| 48 | + return ( |
| 49 | + <ShopifyTestProviders> |
| 50 | + <BoxCardUI {...args} /> // This component imports import{' '} |
| 51 | + {(Image, Link, Money)} from '@shopify/hydrogen' |
| 52 | + </ShopifyTestProviders> |
| 53 | + ); |
| 54 | + }; |
| 55 | + |
| 56 | + export const BoxCard = Template.bind({}); |
| 57 | + BoxCard.args = mockShopifyProduct; |
| 58 | + ``` |
| 59 | + |
| 60 | +* Updated the Storefront API version of Hydrogen to the `2022-10` release. ([#2208](https://github.com/Shopify/hydrogen/pull/2208)) by [@frehner](https://github.com/frehner) |
| 61 | + |
| 62 | + **This is a backwards-compatible change**; if you are still on the `2022-07` version, you may stay on that version without any issues. However, it is still recommended that you upgrade to `2022-10` as soon as possible. |
| 63 | + |
| 64 | + For more information about the Storefront API, refer to: |
| 65 | + |
| 66 | + - The [versioning documentation](https://shopify.dev/api/usage/versioning) |
| 67 | + - The [`2022-10` release notes](https://shopify.dev/api/release-notes/2022-10#graphql-storefont-api-changes). Take note that Hydrogen never used the `Money` fields internally, so the breaking change listed there does not affect Hydrogen. |
| 68 | + |
| 69 | +### Patch Changes |
| 70 | + |
| 71 | +- Experimental version of a new cart provider is ready for beta testing. ([#2219](https://github.com/Shopify/hydrogen/pull/2219)) by [@lordofthecactus](https://github.com/lordofthecactus) |
| 72 | + |
| 73 | + `CartProviderV2` fixes race conditions with our current cart provider. After beta, `CartProviderV2` will become `CartProvider` requiring no code changes. |
| 74 | + |
| 75 | + To try this new cart provider: |
| 76 | + |
| 77 | + ``` |
| 78 | + import {CartProviderV2} from '@shopify/hydrogen/experimental'; |
| 79 | + ``` |
| 80 | + |
3 | 81 | ## 1.4.4
|
4 | 82 |
|
5 | 83 | ### Patch Changes
|
@@ -335,7 +413,7 @@ If your Store is based on the "Demo Store" tempate, and you are using the `test:
|
335 | 413 | } from '@shopify/hydrogen/platforms';
|
336 | 414 |
|
337 | 415 | // Platform entry handler
|
338 |
| - export default function (request) { |
| 416 | + export default function(request) { |
339 | 417 | if (isAsset(new URL(request.url).pathname)) {
|
340 | 418 | return platformAssetHandler(request);
|
341 | 419 | }
|
|
0 commit comments