@envive-ai/react-hooks 0.2.7-arthur-2 → 0.2.8-arthur-2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/{NewOrgConfig-CInGtTV6.cjs → NewOrgConfig-BYo4V8-u.cjs} +2 -2
- package/dist/{NewOrgConfig-BVByiYPp.js → NewOrgConfig-kYrS59aR.js} +2 -2
- package/dist/{SystemSettingsContext-ei5B0dxO.js → SystemSettingsContext-BY1BFgAQ.js} +2 -2
- package/dist/{SystemSettingsContext-150LTxIk.cjs → SystemSettingsContext-EDpRMMt2.cjs} +2 -2
- package/dist/{TrackComponentVisibleEvent-CuwSLbug.js → TrackComponentVisibleEvent-BHVBHQhu.js} +2 -2
- package/dist/{TrackComponentVisibleEvent-C7-nnBks.cjs → TrackComponentVisibleEvent-B_2kXqvV.cjs} +2 -2
- package/dist/{amplitudeContext-C-0-DDk3.cjs → amplitudeContext-CjkMpI_a.cjs} +11 -8
- package/dist/{amplitudeContext-BBQ1ATA3.js → amplitudeContext-D58WY1aS.js} +11 -8
- package/dist/{app-XEFPotoH.cjs → app-BbPSHefQ.cjs} +4 -3
- package/dist/{app-C_Y-57U5.js → app-CflxT_xI.js} +4 -3
- package/dist/application/models/index.cjs +1 -1
- package/dist/application/models/index.d.cts +4 -4
- package/dist/application/models/index.d.ts +4 -4
- package/dist/application/models/index.js +1 -1
- package/dist/application/utils/index.cjs +9 -9
- package/dist/application/utils/index.d.cts +4 -4
- package/dist/application/utils/index.d.ts +6 -6
- package/dist/application/utils/index.js +9 -9
- package/dist/{atomStore-8ppNkJ_n.cjs → atomStore-CmZbgQHc.cjs} +1 -1
- package/dist/{atomStore-BLYJ2ZoQ.js → atomStore-DEcDhiLp.js} +1 -1
- package/dist/atoms/app/index.cjs +5 -5
- package/dist/atoms/app/index.d.cts +11 -11
- package/dist/atoms/app/index.d.ts +11 -11
- package/dist/atoms/app/index.js +5 -5
- package/dist/atoms/atomStore/index.cjs +1 -1
- package/dist/atoms/atomStore/index.js +1 -1
- package/dist/atoms/chat/index.cjs +10 -10
- package/dist/atoms/chat/index.d.cts +30 -30
- package/dist/atoms/chat/index.d.ts +30 -30
- package/dist/atoms/chat/index.js +10 -10
- package/dist/atoms/globalSearch/index.d.cts +6 -6
- package/dist/atoms/globalSearch/index.d.ts +6 -6
- package/dist/atoms/org/index.cjs +1 -1
- package/dist/atoms/org/index.d.cts +21 -21
- package/dist/atoms/org/index.d.ts +21 -21
- package/dist/atoms/org/index.js +1 -1
- package/dist/atoms/search/index.cjs +12 -12
- package/dist/atoms/search/index.d.cts +5 -5
- package/dist/atoms/search/index.d.ts +5 -5
- package/dist/atoms/search/index.js +12 -12
- package/dist/atoms/search/utils.d.cts +1 -1
- package/dist/{cdnContext-CTC-zBtx.js → cdnContext-B8zWuGGT.js} +2 -2
- package/dist/{cdnContext-Bzqk0s2M.cjs → cdnContext-DzifgoNo.cjs} +2 -2
- package/dist/{chat-Ckd1b_z_.cjs → chat-CLo8FBCb.cjs} +7 -7
- package/dist/{chat-Bzay7QnI.js → chat-Qkx5llOV.js} +7 -7
- package/dist/{chatElementDisplayLocation-D4XF0UfI.d.ts → chatElementDisplayLocation-BO3fY4hq.d.ts} +2 -1
- package/dist/{chatElementDisplayLocation-B7vr33eG.d.cts → chatElementDisplayLocation-Igta1TL1.d.cts} +2 -1
- package/dist/{chatSearch-Bev4ZI8Z.cjs → chatSearch-CP7QtVyA.cjs} +4 -4
- package/dist/{chatSearch-DNaGtQyx.js → chatSearch-CjMcB3fG.js} +4 -4
- package/dist/{chatState-CcCvgmSM.js → chatState-BUN8ehpy.js} +3 -3
- package/dist/{chatState-OkYPVghN.cjs → chatState-BUlDJ4NK.cjs} +3 -3
- package/dist/{commerce-api-ml5fkEuk.js → commerce-api-CxnUXpTq.js} +7 -7
- package/dist/{commerce-api-sQtLuwTh.cjs → commerce-api-DNnrOYWX.cjs} +7 -7
- package/dist/contexts/amplitudeContext/index.cjs +9 -9
- package/dist/contexts/amplitudeContext/index.js +9 -9
- package/dist/contexts/cdnContext/index.cjs +3 -3
- package/dist/contexts/cdnContext/index.js +3 -3
- package/dist/contexts/chatContext/index.cjs +17 -17
- package/dist/contexts/chatContext/index.d.cts +2 -2
- package/dist/contexts/chatContext/index.js +17 -17
- package/dist/contexts/enviveConfigContext/index.cjs +3 -3
- package/dist/contexts/enviveConfigContext/index.d.cts +2 -2
- package/dist/contexts/enviveConfigContext/index.d.ts +2 -2
- package/dist/contexts/enviveConfigContext/index.js +3 -3
- package/dist/contexts/enviveCssContext/index.cjs +7 -7
- package/dist/contexts/enviveCssContext/index.js +7 -7
- package/dist/contexts/featureFlagContext/index.cjs +4 -4
- package/dist/contexts/featureFlagContext/index.d.cts +2 -2
- package/dist/contexts/featureFlagContext/index.d.ts +2 -2
- package/dist/contexts/featureFlagContext/index.js +4 -4
- package/dist/contexts/featureFlagServiceContext/index.d.cts +3 -3
- package/dist/contexts/featureFlagServiceContext/index.d.ts +3 -3
- package/dist/contexts/graphqlContext/index.cjs +4 -4
- package/dist/contexts/graphqlContext/index.d.cts +5 -5
- package/dist/contexts/graphqlContext/index.d.ts +5 -5
- package/dist/contexts/graphqlContext/index.js +4 -4
- package/dist/contexts/localStorageContext/index.cjs +1 -1
- package/dist/contexts/localStorageContext/index.js +1 -1
- package/dist/contexts/newOrgConfigContext/index.cjs +6 -6
- package/dist/contexts/newOrgConfigContext/index.d.cts +6 -6
- package/dist/contexts/newOrgConfigContext/index.d.ts +6 -6
- package/dist/contexts/newOrgConfigContext/index.js +6 -6
- package/dist/contexts/searchContext/index.cjs +11 -11
- package/dist/contexts/searchContext/index.js +11 -11
- package/dist/contexts/sessionStorageContext/index.cjs +1 -1
- package/dist/contexts/sessionStorageContext/index.js +1 -1
- package/dist/contexts/shopifyUrlContext/index.cjs +1 -1
- package/dist/contexts/shopifyUrlContext/index.d.cts +2 -2
- package/dist/contexts/shopifyUrlContext/index.d.ts +2 -2
- package/dist/contexts/shopifyUrlContext/index.js +1 -1
- package/dist/contexts/systemSettingsContext/index.cjs +3 -3
- package/dist/contexts/systemSettingsContext/index.d.cts +4 -4
- package/dist/contexts/systemSettingsContext/index.d.ts +6 -6
- package/dist/contexts/systemSettingsContext/index.js +3 -3
- package/dist/contexts/types.d.cts +2 -2
- package/dist/contexts/types.d.ts +2 -2
- package/dist/contexts/userIdentityContext/index.cjs +12 -12
- package/dist/contexts/userIdentityContext/index.js +12 -12
- package/dist/{enviveConfig-DV8F12B9.js → enviveConfig-DZBohDpc.js} +2 -2
- package/dist/{enviveConfig-DZHdtLsQ.cjs → enviveConfig-Dv9-esGV.cjs} +2 -2
- package/dist/{enviveConfigContext-CTcHUIFP.cjs → enviveConfigContext-D2OELZDR.cjs} +2 -2
- package/dist/{enviveConfigContext-BS7aNop5.js → enviveConfigContext-DrDjCems.js} +2 -2
- package/dist/{featureFlagServiceContext-p5UBwPM3.d.cts → featureFlagServiceContext-CPqbnfe3.d.cts} +2 -2
- package/dist/{featureFlagServiceContext-CpxlOkI9.d.ts → featureFlagServiceContext-mFEI_SIk.d.ts} +2 -2
- package/dist/{frontendConfig-iZipB5FG.d.cts → frontendConfig-DPpzM5cz.d.cts} +3 -2
- package/dist/{frontendConfig-Cawh5iqv.d.ts → frontendConfig-msK69LYN.d.ts} +3 -2
- package/dist/{graphqlContext-DgkS-UX1.d.ts → graphqlContext-B1vmNkWT.d.ts} +2 -2
- package/dist/{graphqlContext-DouNZbYo.js → graphqlContext-C0hG5Uer.js} +3 -3
- package/dist/{graphqlContext-CVbYIftg.cjs → graphqlContext-Dddy7mr7.cjs} +3 -3
- package/dist/{graphqlContext-BeyKU1Dr.d.cts → graphqlContext-Y9q6GK71.d.cts} +2 -2
- package/dist/hooks/AmplitudeOperations/index.cjs +9 -9
- package/dist/hooks/AmplitudeOperations/index.js +9 -9
- package/dist/hooks/AppDetails/index.cjs +8 -8
- package/dist/hooks/AppDetails/index.d.cts +4 -4
- package/dist/hooks/AppDetails/index.d.ts +4 -4
- package/dist/hooks/AppDetails/index.js +8 -8
- package/dist/hooks/CdnOperations/index.cjs +3 -3
- package/dist/hooks/CdnOperations/index.js +3 -3
- package/dist/hooks/ChatToggle/index.cjs +10 -10
- package/dist/hooks/ChatToggle/index.d.cts +1 -1
- package/dist/hooks/ChatToggle/index.d.ts +1 -1
- package/dist/hooks/ChatToggle/index.js +10 -10
- package/dist/hooks/ChatToggleAnalytics/index.cjs +10 -10
- package/dist/hooks/ChatToggleAnalytics/index.d.cts +1 -1
- package/dist/hooks/ChatToggleAnalytics/index.d.ts +1 -1
- package/dist/hooks/ChatToggleAnalytics/index.js +10 -10
- package/dist/hooks/GrabAndScroll/index.d.cts +2 -2
- package/dist/hooks/GrabAndScroll/index.d.ts +2 -2
- package/dist/hooks/GraphQLConfig/index.cjs +5 -5
- package/dist/hooks/GraphQLConfig/index.d.cts +5 -5
- package/dist/hooks/GraphQLConfig/index.d.ts +5 -5
- package/dist/hooks/GraphQLConfig/index.js +5 -5
- package/dist/hooks/IdentifyUser/index.cjs +12 -12
- package/dist/hooks/IdentifyUser/index.js +12 -12
- package/dist/hooks/ImageResolver/index.cjs +3 -3
- package/dist/hooks/ImageResolver/index.js +3 -3
- package/dist/hooks/LocalStorageOperations/index.cjs +1 -1
- package/dist/hooks/LocalStorageOperations/index.js +1 -1
- package/dist/hooks/MessageFilter/index.cjs +1 -1
- package/dist/hooks/MessageFilter/index.d.cts +4 -4
- package/dist/hooks/MessageFilter/index.d.ts +4 -4
- package/dist/hooks/MessageFilter/index.js +1 -1
- package/dist/hooks/NewOrgConfig/index.cjs +7 -7
- package/dist/hooks/NewOrgConfig/index.d.cts +6 -6
- package/dist/hooks/NewOrgConfig/index.d.ts +6 -6
- package/dist/hooks/NewOrgConfig/index.js +7 -7
- package/dist/hooks/Search/index.cjs +28 -22
- package/dist/hooks/Search/index.d.cts +15 -8
- package/dist/hooks/Search/index.d.ts +15 -8
- package/dist/hooks/Search/index.js +28 -22
- package/dist/hooks/SearchOperations/index.cjs +11 -11
- package/dist/hooks/SearchOperations/index.js +11 -11
- package/dist/hooks/SessionStorageOperations/index.cjs +1 -1
- package/dist/hooks/SessionStorageOperations/index.js +1 -1
- package/dist/hooks/ShopifyUrlOperations/index.cjs +1 -1
- package/dist/hooks/ShopifyUrlOperations/index.d.cts +2 -2
- package/dist/hooks/ShopifyUrlOperations/index.d.ts +2 -2
- package/dist/hooks/ShopifyUrlOperations/index.js +1 -1
- package/dist/hooks/SystemSettingsContext/index.cjs +4 -4
- package/dist/hooks/SystemSettingsContext/index.d.cts +4 -4
- package/dist/hooks/SystemSettingsContext/index.d.ts +4 -4
- package/dist/hooks/SystemSettingsContext/index.js +4 -4
- package/dist/hooks/TrackComponentVisibleEvent/index.cjs +9 -9
- package/dist/hooks/TrackComponentVisibleEvent/index.d.cts +1 -1
- package/dist/hooks/TrackComponentVisibleEvent/index.d.ts +1 -1
- package/dist/hooks/TrackComponentVisibleEvent/index.js +9 -9
- package/dist/hooks/UpdateAnalyticsProps/index.cjs +8 -8
- package/dist/hooks/UpdateAnalyticsProps/index.js +8 -8
- package/dist/hooks/utils.d.cts +5 -5
- package/dist/hooks/utils.d.ts +5 -5
- package/dist/{index-CMJM-3zV.d.ts → index-BVsXKN48.d.ts} +31 -31
- package/dist/{index-BUDrAxnl.d.ts → index-Bb3zXP0P.d.ts} +2 -2
- package/dist/{index-DpJzjjpi.d.cts → index-CHxwYJZC.d.cts} +31 -31
- package/dist/{index-Dy3TTIOm.d.cts → index-DXTWZLEm.d.cts} +2 -2
- package/dist/interceptors/index.d.cts +4 -4
- package/dist/interceptors/index.d.ts +4 -4
- package/dist/interceptors/types.d.cts +4 -4
- package/dist/interceptors/types.d.ts +4 -4
- package/dist/{localStorageContext-CqcSvg2H.js → localStorageContext-BPZ82q-G.js} +1 -1
- package/dist/{localStorageContext-DiLfSsqL.cjs → localStorageContext-NRP-CdmF.cjs} +1 -1
- package/dist/models-CE5YjbzE.js +1286 -0
- package/dist/models-CJy0mOoW.cjs +1521 -0
- package/dist/{newOrgConfigContext-CKn7B2rj.d.ts → newOrgConfigContext-CmQ-7Trc.d.ts} +2 -2
- package/dist/{newOrgConfigContext-BIDz4ZuO.cjs → newOrgConfigContext-Dg2gtrwB.cjs} +3 -3
- package/dist/{newOrgConfigContext-CJI3tsVV.d.cts → newOrgConfigContext-DhsBBjlG.d.cts} +2 -2
- package/dist/{newOrgConfigContext-u_9UPNcX.js → newOrgConfigContext-P4xkie1E.js} +3 -3
- package/dist/{orgAnalyticsConfig-CGEQtAFs.cjs → orgAnalyticsConfig-Bm23fw4s.cjs} +1 -1
- package/dist/{orgAnalyticsConfig-i4jozLBB.js → orgAnalyticsConfig-CpBmga08.js} +1 -1
- package/dist/{search-NgNrXNS9.js → search-BRBqhum7.js} +2 -2
- package/dist/{search-CTVX9gC6.cjs → search-Bpd_wxaK.cjs} +2 -2
- package/dist/{searchContext-CnDXkawZ.cjs → searchContext-4mMbhaHA.cjs} +5 -5
- package/dist/{searchContext-DtRmshTA.js → searchContext-nzEsa-bl.js} +5 -5
- package/dist/{sessionStorageContext-1Ks_d4Z0.cjs → sessionStorageContext-B6FsNKjj.cjs} +1 -1
- package/dist/{sessionStorageContext-CDcl7NVl.js → sessionStorageContext-CLYCm83p.js} +1 -1
- package/dist/{shopifyUrlContext-D2btP_lY.js → shopifyUrlContext-C-PkSgNC.js} +1 -1
- package/dist/{shopifyUrlContext-CxjV3qvH.cjs → shopifyUrlContext-ZOcARiMR.cjs} +1 -1
- package/dist/{spiffyWidgets-eNbU1gMc.d.cts → spiffyWidgets-DK7Ekcy7.d.cts} +2 -1
- package/dist/{spiffyWidgets-CR6F7FRE.d.ts → spiffyWidgets-MTUAQq_u.d.ts} +2 -1
- package/dist/{systemSettingsContext-C4dtZ0uZ.js → systemSettingsContext-DF0jSq9m.js} +2 -2
- package/dist/{systemSettingsContext-BejoGzzB.cjs → systemSettingsContext-dmE1v6w8.cjs} +2 -2
- package/dist/types-BegmH0S1.d.ts +1 -1
- package/dist/types-CtUb63bt.js +1 -1
- package/dist/types-UUvB6h05.cjs +1 -1
- package/dist/types.d.cts +2 -2
- package/dist/types.d.ts +3 -3
- package/dist/{unsupportedProductExceptions-B0yx2bHK.cjs → unsupportedProductExceptions-DGENUnEA.cjs} +1 -1
- package/dist/{unsupportedProductExceptions-Cs66ngs3.js → unsupportedProductExceptions-uQuuelOs.js} +1 -1
- package/dist/{useAmplitudeOperations-Dym0Ker8.js → useAmplitudeOperations-Cr03Hlk6.js} +2 -2
- package/dist/{useAmplitudeOperations-BJXD9v2u.cjs → useAmplitudeOperations-DzFMBUU_.cjs} +2 -2
- package/dist/{useAppDetails-Dmh16bWE.js → useAppDetails-Bgql1vXN.js} +4 -4
- package/dist/{useAppDetails-DsAZ1xQn.cjs → useAppDetails-D-l3HbOk.cjs} +4 -4
- package/dist/{useGraphQLConfig-DSRaDTdT.js → useGraphQLConfig-8oeOwWRP.js} +2 -2
- package/dist/{useGraphQLConfig-B3DlwmGg.cjs → useGraphQLConfig-CO9lCk8b.cjs} +2 -2
- package/dist/userIdentityContext-B_CPsBYG.cjs +143 -0
- package/dist/userIdentityContext-BtOui2qA.js +126 -0
- package/dist/{utils-CcC2jZRi.cjs → utils-BXfzt6tu.cjs} +3 -3
- package/dist/{utils-CBD4g2Nc.d.cts → utils-C2HshI4X.d.cts} +2 -2
- package/dist/{utils-B7KTAEmV.js → utils-Cv772xzd.js} +3 -3
- package/dist/{utils-QKFAbPT6.d.ts → utils-aa1jK0Xe.d.ts} +2 -2
- package/package.json +1 -1
- package/src/application/models/chatElementDisplayLocation.ts +1 -0
- package/src/application/models/spiffyWidgets.ts +2 -0
- package/src/atoms/app/index.ts +1 -1
- package/src/contexts/amplitudeContext/amplitudeContext.tsx +1 -0
- package/src/contexts/types.ts +1 -0
- package/src/contexts/userIdentityContext/__tests__/userIdentityContext.test.tsx +0 -162
- package/src/contexts/userIdentityContext/userIdentityContext.tsx +12 -5
- package/src/hooks/Search/useSearch.tsx +12 -7
- package/dist/models-CWOgrLCm.js +0 -1284
- package/dist/models-DqdLOi2I.cjs +0 -1519
- package/dist/userIdentityContext-DF3atBFE.js +0 -119
- package/dist/userIdentityContext-DpQTduhF.cjs +0 -136
- /package/dist/{amplitudeContext-BItT9HmT.js → amplitudeContext-DbicJUzl.js} +0 -0
- /package/dist/{amplitudeContext-DPtyVv3Q.cjs → amplitudeContext-q3mggFSE.cjs} +0 -0
|
@@ -13,6 +13,7 @@ export enum ChatElementDisplayLocation {
|
|
|
13
13
|
GLOBAL_SEARCH_ENTRYPOINT = 'global_search_entrypoint',
|
|
14
14
|
SEARCH_NAV_ENTRYPOINT = 'search_nav_entrypoint',
|
|
15
15
|
SEARCH_PROMPT = 'search_prompt',
|
|
16
|
+
SEARCH_ZERO_STATE_SUGGESTED_PRODUCTS = 'search_zero_state_suggested_products',
|
|
16
17
|
SEARCH_PROMPT_BUTTON = 'search_prompt_button',
|
|
17
18
|
PRODUCT_GRID = 'product_grid',
|
|
18
19
|
UNSPECIFIED = 'unspecified',
|
package/src/atoms/app/index.ts
CHANGED
|
@@ -32,7 +32,7 @@ export const userIdAtom = atom(
|
|
|
32
32
|
return maybeUserId;
|
|
33
33
|
}
|
|
34
34
|
|
|
35
|
-
|
|
35
|
+
throw new Error('userIdAtom is not set. Ensure that all use of userIdAtom is under UserIdentityProvider');
|
|
36
36
|
},
|
|
37
37
|
(_, set, value: string | undefined) => {
|
|
38
38
|
set(internalUserIdAtom, value);
|
package/src/contexts/types.ts
CHANGED
|
@@ -496,168 +496,6 @@ describe("UserIdentityProvider", () => {
|
|
|
496
496
|
{ timeout: 3000 }
|
|
497
497
|
);
|
|
498
498
|
});
|
|
499
|
-
|
|
500
|
-
it("should not call identifyUser when context is not ready", async () => {
|
|
501
|
-
const identifySpy = vi.spyOn(CommerceApiClient, "identifyUser");
|
|
502
|
-
const logWarnSpy = vi.spyOn(Logger, "logWarn");
|
|
503
|
-
|
|
504
|
-
// Mock localStorage to be unavailable
|
|
505
|
-
const originalLocalStorage = window.localStorage;
|
|
506
|
-
Object.defineProperty(window, "localStorage", {
|
|
507
|
-
value: undefined,
|
|
508
|
-
writable: true,
|
|
509
|
-
});
|
|
510
|
-
|
|
511
|
-
renderWithProviders(<IdentifyUserComponent />);
|
|
512
|
-
|
|
513
|
-
await waitFor(() => {
|
|
514
|
-
expect(screen.getByTestId("identify-button")).toBeInTheDocument();
|
|
515
|
-
});
|
|
516
|
-
|
|
517
|
-
await act(async () => {
|
|
518
|
-
screen.getByTestId("identify-button").click();
|
|
519
|
-
});
|
|
520
|
-
|
|
521
|
-
await waitFor(() => {
|
|
522
|
-
expect(logWarnSpy).toHaveBeenCalledWith(
|
|
523
|
-
"[UserIdentityContext] Context not ready, skipping identifyUser",
|
|
524
|
-
undefined
|
|
525
|
-
);
|
|
526
|
-
expect(identifySpy).not.toHaveBeenCalled();
|
|
527
|
-
});
|
|
528
|
-
|
|
529
|
-
// Restore localStorage
|
|
530
|
-
Object.defineProperty(window, "localStorage", {
|
|
531
|
-
value: originalLocalStorage,
|
|
532
|
-
writable: true,
|
|
533
|
-
});
|
|
534
|
-
});
|
|
535
|
-
|
|
536
|
-
it("should handle errors when identifyUser fails", async () => {
|
|
537
|
-
const identifySpy = vi
|
|
538
|
-
.spyOn(CommerceApiClient, "identifyUser")
|
|
539
|
-
.mockRejectedValueOnce(new Error("API Error"));
|
|
540
|
-
const logErrorSpy = vi.spyOn(Logger, "logError");
|
|
541
|
-
|
|
542
|
-
renderWithProviders(<IdentifyUserComponent />);
|
|
543
|
-
|
|
544
|
-
await waitFor(() => {
|
|
545
|
-
expect(screen.getByTestId("identify-button")).toBeInTheDocument();
|
|
546
|
-
});
|
|
547
|
-
|
|
548
|
-
await act(async () => {
|
|
549
|
-
screen.getByTestId("identify-button").click();
|
|
550
|
-
});
|
|
551
|
-
|
|
552
|
-
await waitFor(() => {
|
|
553
|
-
expect(identifySpy).toHaveBeenCalled();
|
|
554
|
-
expect(logErrorSpy).toHaveBeenCalledWith(
|
|
555
|
-
"[spiffy-ai] Error identifying user",
|
|
556
|
-
expect.any(Error)
|
|
557
|
-
);
|
|
558
|
-
});
|
|
559
|
-
});
|
|
560
|
-
|
|
561
|
-
it("should skip identifyUser when cdpUserId is not available", async () => {
|
|
562
|
-
const identifySpy = vi.spyOn(CommerceApiClient, "identifyUser");
|
|
563
|
-
const logWarnSpy = vi.spyOn(Logger, "logWarn");
|
|
564
|
-
|
|
565
|
-
// The current implementation uses "UNKNOWN_CDP_USER_ID" as placeholder
|
|
566
|
-
// and checks if cdpUserId is falsy, so it will skip
|
|
567
|
-
renderWithProviders(<IdentifyUserComponent />);
|
|
568
|
-
|
|
569
|
-
await waitFor(() => {
|
|
570
|
-
expect(screen.getByTestId("identify-button")).toBeInTheDocument();
|
|
571
|
-
});
|
|
572
|
-
|
|
573
|
-
await act(async () => {
|
|
574
|
-
screen.getByTestId("identify-button").click();
|
|
575
|
-
});
|
|
576
|
-
|
|
577
|
-
// Note: The current implementation checks `if (!cdpUserId)` but uses "UNKNOWN_CDP_USER_ID"
|
|
578
|
-
// which is truthy, so this test may need adjustment based on actual behavior
|
|
579
|
-
// For now, we'll verify the call was made (since "UNKNOWN_CDP_USER_ID" is truthy)
|
|
580
|
-
await waitFor(() => {
|
|
581
|
-
// The current code will call identifyUser because "UNKNOWN_CDP_USER_ID" is truthy
|
|
582
|
-
// If the behavior changes, this test should be updated
|
|
583
|
-
expect(identifySpy).toHaveBeenCalled();
|
|
584
|
-
});
|
|
585
|
-
});
|
|
586
|
-
});
|
|
587
|
-
|
|
588
|
-
describe("isReady state", () => {
|
|
589
|
-
it("should be false when localStorage is not available", async () => {
|
|
590
|
-
const originalLocalStorage = window.localStorage;
|
|
591
|
-
Object.defineProperty(window, "localStorage", {
|
|
592
|
-
value: undefined,
|
|
593
|
-
writable: true,
|
|
594
|
-
});
|
|
595
|
-
|
|
596
|
-
renderWithProviders(<MockComponent />);
|
|
597
|
-
|
|
598
|
-
await waitFor(() => {
|
|
599
|
-
expect(screen.getByTestId("is-ready").textContent).toBe("false");
|
|
600
|
-
});
|
|
601
|
-
|
|
602
|
-
// Restore localStorage
|
|
603
|
-
Object.defineProperty(window, "localStorage", {
|
|
604
|
-
value: originalLocalStorage,
|
|
605
|
-
writable: true,
|
|
606
|
-
});
|
|
607
|
-
});
|
|
608
|
-
|
|
609
|
-
it("should be true when localStorage is available", async () => {
|
|
610
|
-
renderWithProviders(<MockComponent />);
|
|
611
|
-
|
|
612
|
-
await waitFor(() => {
|
|
613
|
-
expect(screen.getByTestId("is-ready").textContent).toBe("true");
|
|
614
|
-
});
|
|
615
|
-
});
|
|
616
|
-
|
|
617
|
-
it("should update when localStorage availability changes", async () => {
|
|
618
|
-
renderWithProviders(<MockComponent />);
|
|
619
|
-
|
|
620
|
-
await waitFor(() => {
|
|
621
|
-
expect(screen.getByTestId("is-ready").textContent).toBe("true");
|
|
622
|
-
});
|
|
623
|
-
|
|
624
|
-
// Note: Testing localStorage becoming unavailable requires unmounting and remounting
|
|
625
|
-
// the provider, which is complex. This test verifies the ready state is correct
|
|
626
|
-
// when localStorage is available. The unavailable case is tested in the other test.
|
|
627
|
-
});
|
|
628
|
-
});
|
|
629
|
-
|
|
630
|
-
describe("Context Value Memoization", () => {
|
|
631
|
-
it("should maintain stable context value references", async () => {
|
|
632
|
-
let contextValue1: UserIdentityContextType | undefined;
|
|
633
|
-
let contextValue2: UserIdentityContextType | undefined;
|
|
634
|
-
|
|
635
|
-
const Component1: React.FC = () => {
|
|
636
|
-
const context = useUserIdentity();
|
|
637
|
-
contextValue1 = context;
|
|
638
|
-
return <div>Component1</div>;
|
|
639
|
-
};
|
|
640
|
-
|
|
641
|
-
const Component2: React.FC = () => {
|
|
642
|
-
const context = useUserIdentity();
|
|
643
|
-
contextValue2 = context;
|
|
644
|
-
return <div>Component2</div>;
|
|
645
|
-
};
|
|
646
|
-
|
|
647
|
-
renderWithProviders(
|
|
648
|
-
<>
|
|
649
|
-
<Component1 />
|
|
650
|
-
<Component2 />
|
|
651
|
-
</>
|
|
652
|
-
);
|
|
653
|
-
|
|
654
|
-
await waitFor(() => {
|
|
655
|
-
expect(contextValue1).toBeDefined();
|
|
656
|
-
expect(contextValue2).toBeDefined();
|
|
657
|
-
// Both components should receive the same context instance
|
|
658
|
-
expect(contextValue1).toBe(contextValue2);
|
|
659
|
-
});
|
|
660
|
-
});
|
|
661
499
|
});
|
|
662
500
|
});
|
|
663
501
|
|
|
@@ -12,7 +12,7 @@ import CommerceApiClient from "src/application/commerce-api";
|
|
|
12
12
|
import { v4 as uuid } from "uuid";
|
|
13
13
|
import { ClientDetails } from "src/application/models/clientDetails";
|
|
14
14
|
import { useLocalStorage } from "src/contexts/localStorageContext";
|
|
15
|
-
import {
|
|
15
|
+
import { useSetAtom } from "jotai";
|
|
16
16
|
import { userIdAtom } from "src/atoms/app";
|
|
17
17
|
|
|
18
18
|
// Helper function from the original service
|
|
@@ -50,7 +50,8 @@ const UserIdentityContext = createContext<UserIdentityContextType | undefined>(
|
|
|
50
50
|
export const UserIdentityProvider: React.FC<{ children: React.ReactNode }> = ({
|
|
51
51
|
children,
|
|
52
52
|
}) => {
|
|
53
|
-
const [
|
|
53
|
+
const [localUserId, setLocalUserId] = useState<string | undefined>(undefined);
|
|
54
|
+
const setUserId = useSetAtom(userIdAtom);
|
|
54
55
|
const {
|
|
55
56
|
getItem,
|
|
56
57
|
setItem,
|
|
@@ -182,11 +183,17 @@ export const UserIdentityProvider: React.FC<{ children: React.ReactNode }> = ({
|
|
|
182
183
|
]
|
|
183
184
|
);
|
|
184
185
|
useEffect(() => {
|
|
185
|
-
if (isReady && !
|
|
186
|
-
|
|
186
|
+
if (isReady && !localUserId) {
|
|
187
|
+
const newUserId = getUserIdOrDefault();
|
|
188
|
+
console.log("useUserIdentity useEffect - setting localUserId", newUserId);
|
|
189
|
+
setLocalUserId(newUserId);
|
|
190
|
+
setUserId(newUserId);
|
|
187
191
|
}
|
|
188
|
-
}, [isReady,
|
|
192
|
+
}, [isReady, localUserId, setUserId]);
|
|
189
193
|
|
|
194
|
+
if (!localUserId) {
|
|
195
|
+
return null;
|
|
196
|
+
}
|
|
190
197
|
return (
|
|
191
198
|
<UserIdentityContext.Provider value={value}>
|
|
192
199
|
{children}
|
|
@@ -35,9 +35,6 @@ import {
|
|
|
35
35
|
import { getSearchResultsState, SearchResultsState } from "../utils";
|
|
36
36
|
import { orgShortNameAtom } from "src/atoms/envive/enviveConfig";
|
|
37
37
|
import { useTrackComponentVisibleEvent } from "../TrackComponentVisibleEvent";
|
|
38
|
-
import { amplitudeTrackEventAtom } from "src/atoms/amplitude/amplitudeTrackEventAtom";
|
|
39
|
-
import { newOrgConfigAtom } from "src/atoms/org";
|
|
40
|
-
import { retrievedProductsAtom } from "src/atoms/search/productRetrievalAPI";
|
|
41
38
|
import { useSearchInput } from "./useSearchInput";
|
|
42
39
|
import { SearchResponseProductAttributes } from "src/application/models";
|
|
43
40
|
import { useNewOrgConfig } from "../NewOrgConfig";
|
|
@@ -55,6 +52,8 @@ export interface SearchResultsHocProps {
|
|
|
55
52
|
availableDynamicFilters: { name: string; displayName: string }[];
|
|
56
53
|
selectedFilterOptions: SelectedFilterOption[];
|
|
57
54
|
recommendedProducts: SearchResponseProductAttributes['attributes'][];
|
|
55
|
+
recommendedProductsHeading: string;
|
|
56
|
+
searchOverlayHeading: string;
|
|
58
57
|
|
|
59
58
|
// State
|
|
60
59
|
searchText: string;
|
|
@@ -81,12 +80,12 @@ export interface SearchResultsHocProps {
|
|
|
81
80
|
onRemoveFilter: (filter: SelectedFilterOption) => void;
|
|
82
81
|
onClearAllFilters: () => void;
|
|
83
82
|
setIsFilterOpen: (isFilterOpen: boolean) => void;
|
|
84
|
-
|
|
83
|
+
resetSearch: () => void;
|
|
85
84
|
// Refs
|
|
86
85
|
searchResultsRef: React.RefObject<HTMLDivElement>;
|
|
87
86
|
}
|
|
88
87
|
|
|
89
|
-
export const useSearch = (): SearchResultsHocProps => {
|
|
88
|
+
export const useSearch = ({ allowRedirect = false }: { allowRedirect?: boolean } = {}): SearchResultsHocProps => {
|
|
90
89
|
// Atoms
|
|
91
90
|
const config = useNewOrgConfig();
|
|
92
91
|
const orgShortName = useAtomValue(orgShortNameAtom);
|
|
@@ -122,7 +121,7 @@ export const useSearch = (): SearchResultsHocProps => {
|
|
|
122
121
|
initialSearchText: query || '',
|
|
123
122
|
searchOrigin: SpiffyWidgets.SearchResults,
|
|
124
123
|
onSearchSubmit: (searchQuery) => {
|
|
125
|
-
performSearch({ query: searchQuery });
|
|
124
|
+
performSearch({ query: searchQuery }, allowRedirect);
|
|
126
125
|
},
|
|
127
126
|
});
|
|
128
127
|
|
|
@@ -139,6 +138,7 @@ export const useSearch = (): SearchResultsHocProps => {
|
|
|
139
138
|
handleAutocompleteSelect,
|
|
140
139
|
handleSubmitSearch,
|
|
141
140
|
setSearchText,
|
|
141
|
+
resetSearch,
|
|
142
142
|
} = searchInput;
|
|
143
143
|
const searchResultsState = getSearchResultsState(isLoadingSearch, searchData);
|
|
144
144
|
|
|
@@ -152,7 +152,9 @@ export const useSearch = (): SearchResultsHocProps => {
|
|
|
152
152
|
layoutVariant: "square",
|
|
153
153
|
};
|
|
154
154
|
const safeMerchantShortName = orgShortName || "";
|
|
155
|
-
|
|
155
|
+
const searchConfig = config?.frontendConfig?.uiConfigs?.searchConfig;
|
|
156
|
+
const safeRecommendedProductsHeading = searchConfig?.recommendedProductsHeading || 'Suggested Products'
|
|
157
|
+
const safeSearchOverlayHeading = searchConfig?.searchOverlayHeading ?? 'What can I help you find?'
|
|
156
158
|
const availableDynamicFilters = useMemo(() => {
|
|
157
159
|
return dynamicFilters
|
|
158
160
|
.filter(
|
|
@@ -316,6 +318,8 @@ export const useSearch = (): SearchResultsHocProps => {
|
|
|
316
318
|
searchData,
|
|
317
319
|
searchResponseId: searchData?.searchResponseId ?? '',
|
|
318
320
|
merchantShortName: safeMerchantShortName,
|
|
321
|
+
recommendedProductsHeading: safeRecommendedProductsHeading,
|
|
322
|
+
searchOverlayHeading: safeSearchOverlayHeading,
|
|
319
323
|
productCardConfig: safeProductCardConfig,
|
|
320
324
|
productList,
|
|
321
325
|
recommendedProducts,
|
|
@@ -343,6 +347,7 @@ export const useSearch = (): SearchResultsHocProps => {
|
|
|
343
347
|
onRemoveFilter: handleRemoveFilter,
|
|
344
348
|
onClearAllFilters: handleClearAllFilters,
|
|
345
349
|
setIsFilterOpen,
|
|
350
|
+
resetSearch,
|
|
346
351
|
searchResultsRef,
|
|
347
352
|
};
|
|
348
353
|
};
|