Skip to content

Commit a637f3b

Browse files
Merge branch 'standard-product-support' into t/cc-shark/W-18767088/refactor-add-to-cart
Signed-off-by: Kyle Wright <30636085+sf-kyle-wright@users.noreply.github.com>
2 parents dd72f4f + 891af1f commit a637f3b

File tree

18 files changed

+1321
-2196
lines changed

18 files changed

+1321
-2196
lines changed

packages/commerce-sdk-react/CHANGELOG.md

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,6 @@
11
## v3.4.0-dev.0 (May 23, 2025)
2+
3+
- Optionally disable auth init in CommerceApiProvider [#2629](https://github.com/SalesforceCommerceCloud/pwa-kit/pull/2629)
24
- Now compatible with either React 17 and 18 [#2506](https://github.com/SalesforceCommerceCloud/pwa-kit/pull/2506)
35
- Gracefully handle missing SDK Clients in CommerceApiProvider [#2539](https://github.com/SalesforceCommerceCloud/pwa-kit/pull/2539)
46
- Refactor commerce-sdk-react to allow injecting ApiClients [#2519](https://github.com/SalesforceCommerceCloud/pwa-kit/pull/2519)

packages/commerce-sdk-react/src/provider.test.tsx

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -72,4 +72,20 @@ describe('provider', () => {
7272
expect(element).toBeInTheDocument()
7373
expect(element.textContent?.includes('/mobify/slas/private')).toBeTruthy()
7474
})
75+
76+
test('does not call Auth.ready() when disableAuthInit is true', () => {
77+
renderWithProviders(<h1>Auth not initialized!</h1>, {disableAuthInit: true})
78+
expect(screen.getByText('Auth not initialized!')).toBeInTheDocument()
79+
expect(Auth).toHaveBeenCalledTimes(1)
80+
const authInstance = (Auth as jest.Mock).mock.instances[0]
81+
expect(authInstance.ready).toHaveBeenCalledTimes(0)
82+
})
83+
84+
test('calls Auth.ready() when disableAuthInit is false', () => {
85+
renderWithProviders(<h1>Auth initialized!</h1>, {disableAuthInit: false})
86+
expect(screen.getByText('Auth initialized!')).toBeInTheDocument()
87+
expect(Auth).toHaveBeenCalledTimes(1)
88+
const authInstance = (Auth as jest.Mock).mock.instances[0]
89+
expect(authInstance.ready).toHaveBeenCalledTimes(1)
90+
})
7591
})

packages/commerce-sdk-react/src/provider.tsx

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -49,6 +49,7 @@ export interface CommerceApiProviderProps extends ApiClientConfigParams {
4949
refreshTokenRegisteredCookieTTL?: number
5050
refreshTokenGuestCookieTTL?: number
5151
apiClients?: ApiClients
52+
disableAuthInit?: boolean
5253
}
5354

5455
/**
@@ -132,7 +133,8 @@ const CommerceApiProvider = (props: CommerceApiProviderProps): ReactElement => {
132133
passwordlessLoginCallbackURI,
133134
refreshTokenRegisteredCookieTTL,
134135
refreshTokenGuestCookieTTL,
135-
apiClients
136+
apiClients,
137+
disableAuthInit = false
136138
} = props
137139

138140
// Set the logger based on provided configuration, or default to the console object if no logger is provided
@@ -270,7 +272,11 @@ const CommerceApiProvider = (props: CommerceApiProviderProps): ReactElement => {
270272
])
271273

272274
// Initialize the session
273-
useEffect(() => void auth.ready(), [auth])
275+
useEffect(() => {
276+
if (!disableAuthInit) {
277+
void auth.ready()
278+
}
279+
}, [auth, disableAuthInit])
274280

275281
return (
276282
<ConfigContext.Provider

packages/pwa-kit-create-app/CHANGELOG.md

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,17 +1,19 @@
11
## v3.11.0-dev.0 (May 23, 2025)
2+
- Change the default ECOM instance in the generated application [#2610](https://github.com/SalesforceCommerceCloud/pwa-kit/pull/2610)
3+
- Load active data scripts on demand only [#2623](https://github.com/SalesforceCommerceCloud/pwa-kit/pull/2623)
24

35
## v3.10.0 (May 22, 2025)
4-
- Add Data Cloud API configuration to `default.js`. [#2318] (https://github.com/SalesforceCommerceCloud/pwa-kit/pull/2229)
6+
- Add Data Cloud API configuration to `default.js`. [#2318](https://github.com/SalesforceCommerceCloud/pwa-kit/pull/2318)
57
- Fix dependencies vulnerabilities [#2338](https://github.com/SalesforceCommerceCloud/pwa-kit/pull/2338)
68

79
## v3.9.1 (Mar 05, 2025)
810
- Update PWA-Kit SDKs to v3.9.1 [#2301](https://github.com/SalesforceCommerceCloud/pwa-kit/pull/2301)
911

1012
## v3.9.0 (Feb 18, 2025)
1113

12-
- Update `default.js` and `ssr.js` template to support new passwordless, social, and reset password flows. [#2263] (https://github.com/SalesforceCommerceCloud/pwa-kit/pull/2263)
14+
- Update `default.js` and `ssr.js` template to support new passwordless, social, and reset password flows. [#2263](https://github.com/SalesforceCommerceCloud/pwa-kit/pull/2263)
1315
- Support Node 22 [#2218](https://github.com/SalesforceCommerceCloud/pwa-kit/pull/2218)
14-
- Update `default.js` template to include new login configurations [#2079] (https://github.com/SalesforceCommerceCloud/pwa-kit/pull/2079)
16+
- Update `default.js` template to include new login configurations [#2079](https://github.com/SalesforceCommerceCloud/pwa-kit/pull/2079)
1517
- Handle import error when ssr.js imports from template retail react app [#2270](https://github.com/SalesforceCommerceCloud/pwa-kit/pull/2270)
1618

1719
## v3.8.0 (Oct 28, 2024)

packages/pwa-kit-create-app/assets/bootstrap/js/overrides/app/ssr.js.hbs

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -289,7 +289,8 @@ const {handler} = runtime.createHandler(options, (app) => {
289289
directives: {
290290
'img-src': [
291291
// Default source for product images - replace with your CDN
292-
'*.commercecloud.salesforce.com'
292+
'*.commercecloud.salesforce.com',
293+
'*.demandware.net'
293294
],
294295
'script-src': [
295296
// Used by the service worker in /worker/main.js

0 commit comments

Comments
 (0)