@envive-ai/react-hooks 0.2.6-alpha.13 → 0.2.7-arthur-1
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-DJm6_abA.cjs → NewOrgConfig-Bo1seKr6.cjs} +2 -2
- package/dist/{NewOrgConfig-BfbTlFg1.js → NewOrgConfig-yptI2imS.js} +2 -2
- package/dist/{SystemSettingsContext-BbTKNBvJ.js → SystemSettingsContext-BY1BFgAQ.js} +2 -2
- package/dist/{SystemSettingsContext-6ZHzQkCE.cjs → SystemSettingsContext-EDpRMMt2.cjs} +2 -2
- package/dist/{TrackComponentVisibleEvent-BJgNOypY.js → TrackComponentVisibleEvent-CXhKOwKQ.js} +3 -3
- package/dist/{TrackComponentVisibleEvent-BRC2FTp-.cjs → TrackComponentVisibleEvent-CgxCqrIt.cjs} +7 -7
- package/dist/amplitudeContext-C8tT74Mi.cjs +286 -0
- package/dist/{amplitudeContext-B73xamNe.d.cts → amplitudeContext-CCVyp5RU.d.cts} +1 -1
- package/dist/amplitudeContext-DCk6Va-j.js +264 -0
- package/dist/{amplitudeContext-CZUzMXHl.d.ts → amplitudeContext-DcRur97Z.d.ts} +1 -1
- package/dist/app-BbPSHefQ.cjs +156 -0
- package/dist/app-CflxT_xI.js +110 -0
- package/dist/application/models/graphql/index.cjs +3 -2
- package/dist/application/models/graphql/index.d.cts +2 -2
- package/dist/application/models/graphql/index.d.ts +2 -2
- package/dist/application/models/graphql/index.js +2 -2
- package/dist/application/models/guards/api/index.d.cts +2 -1
- package/dist/application/models/guards/api/index.d.ts +3 -2
- package/dist/application/models/guards/utils.d.cts +1 -1
- package/dist/application/models/guards/utils.d.ts +1 -1
- package/dist/application/models/index.cjs +3 -3
- package/dist/application/models/index.d.cts +11 -10
- package/dist/application/models/index.d.ts +12 -11
- package/dist/application/models/index.js +2 -2
- package/dist/application/models/utilityTypes/index.d.ts +1 -1
- package/dist/application/models/variantInfo/index.d.cts +1 -1
- package/dist/application/models/variantInfo/index.d.ts +1 -1
- package/dist/application/utils/index.cjs +8 -6
- package/dist/application/utils/index.d.cts +14 -13
- package/dist/application/utils/index.d.ts +17 -16
- package/dist/application/utils/index.js +8 -6
- package/dist/{atomStore-DNji91Im.cjs → atomStore-CmZbgQHc.cjs} +1 -1
- package/dist/{atomStore-DXTVqiKc.js → atomStore-DEcDhiLp.js} +1 -1
- package/dist/atoms/app/index.cjs +9 -14
- package/dist/atoms/app/index.d.cts +19 -18
- package/dist/atoms/app/index.d.ts +20 -19
- package/dist/atoms/app/index.js +4 -9
- package/dist/atoms/atomStore/index.cjs +1 -1
- package/dist/atoms/atomStore/index.js +1 -1
- package/dist/atoms/chat/index.cjs +9 -8
- package/dist/atoms/chat/index.d.cts +39 -38
- package/dist/atoms/chat/index.d.ts +40 -39
- package/dist/atoms/chat/index.js +9 -8
- package/dist/atoms/globalSearch/index.cjs +1 -2
- package/dist/atoms/globalSearch/index.d.cts +5 -5
- package/dist/atoms/globalSearch/index.d.ts +6 -6
- package/dist/atoms/globalSearch/index.js +1 -2
- package/dist/atoms/org/index.cjs +8 -7
- package/dist/atoms/org/index.d.cts +30 -29
- package/dist/atoms/org/index.d.ts +31 -30
- package/dist/atoms/org/index.js +4 -3
- package/dist/atoms/search/index.cjs +16 -15
- package/dist/atoms/search/index.d.cts +13 -12
- package/dist/atoms/search/index.d.ts +14 -13
- package/dist/atoms/search/index.js +16 -15
- package/dist/atoms/search/types.cjs +1 -1
- package/dist/atoms/search/types.d.cts +4 -2
- package/dist/atoms/search/types.d.ts +4 -2
- package/dist/atoms/search/types.js +1 -1
- package/dist/atoms/search/utils.cjs +1 -1
- package/dist/atoms/search/utils.d.ts +1 -1
- package/dist/atoms/search/utils.js +1 -1
- package/dist/{cdnContext-DOSIofl8.cjs → cdnContext-CaDyQ_5p.cjs} +1 -1
- package/dist/{cdnContext-CEGBVVBU.js → cdnContext-CtrIlAqX.js} +1 -1
- package/dist/{chat-DH70QqJp.js → chat-BjhQCyW_.js} +8 -7
- package/dist/{chat-CqPuT9_V.cjs → chat-BkPax29G.cjs} +16 -9
- package/dist/{chatElementDisplayLocation-DWmfNX_u.d.cts → chatElementDisplayLocation-B7vr33eG.d.cts} +1 -1
- package/dist/{chatElementDisplayLocation-CpgV2wR1.d.ts → chatElementDisplayLocation-D4XF0UfI.d.ts} +1 -1
- package/dist/{chatSearch-C7Y-hb-6.js → chatSearch-BsYlFvpv.js} +7 -7
- package/dist/{chatSearch-DLV4BUGA.cjs → chatSearch-C3N3iIxu.cjs} +7 -7
- package/dist/{chatState-CcFtSqJT.cjs → chatState-CJ52Ag_7.cjs} +5 -5
- package/dist/{chatState-DKnNHmwe.js → chatState-CXA1vF16.js} +3 -3
- package/dist/commerce-api-DA1QGGMK.cjs +319 -0
- package/dist/commerce-api-rgj30eEp.js +312 -0
- package/dist/config/index.d.cts +4 -4
- package/dist/config/index.d.ts +4 -4
- package/dist/config/locators/components/chat/index.d.cts +1 -1
- package/dist/config/locators/components/chat/index.d.ts +1 -1
- package/dist/config/locators/components/common/index.d.cts +1 -1
- package/dist/config/locators/components/common/index.d.ts +1 -1
- package/dist/config/locators/components/index.d.cts +1 -1
- package/dist/config/locators/components/index.d.ts +1 -1
- package/dist/config/locators/index.d.cts +4 -4
- package/dist/config/locators/index.d.ts +4 -4
- package/dist/contexts/amplitudeContext/index.cjs +10 -9
- package/dist/contexts/amplitudeContext/index.d.cts +1 -1
- package/dist/contexts/amplitudeContext/index.d.ts +1 -1
- package/dist/contexts/amplitudeContext/index.js +7 -6
- package/dist/contexts/cdnContext/index.cjs +1 -1
- package/dist/contexts/cdnContext/index.js +1 -1
- package/dist/contexts/chatContext/index.cjs +32 -27
- package/dist/contexts/chatContext/index.d.cts +2 -2
- package/dist/contexts/chatContext/index.d.ts +4 -4
- package/dist/contexts/chatContext/index.js +22 -17
- package/dist/contexts/enviveConfigContext/index.d.cts +3 -3
- package/dist/contexts/enviveConfigContext/index.d.ts +3 -3
- package/dist/contexts/enviveCssContext/index.cjs +7 -7
- package/dist/contexts/enviveCssContext/index.js +7 -7
- package/dist/contexts/featureFlagContext/index.cjs +1 -1
- package/dist/contexts/featureFlagContext/index.d.cts +3 -3
- package/dist/contexts/featureFlagContext/index.d.ts +3 -3
- package/dist/contexts/featureFlagContext/index.js +1 -1
- package/dist/contexts/featureFlagServiceContext/index.d.cts +4 -4
- package/dist/contexts/featureFlagServiceContext/index.d.ts +4 -4
- package/dist/contexts/graphqlContext/index.cjs +3 -3
- package/dist/contexts/graphqlContext/index.d.cts +13 -12
- package/dist/contexts/graphqlContext/index.d.ts +14 -13
- package/dist/contexts/graphqlContext/index.js +3 -3
- package/dist/contexts/newOrgConfigContext/index.cjs +6 -6
- package/dist/contexts/newOrgConfigContext/index.d.cts +14 -13
- package/dist/contexts/newOrgConfigContext/index.d.ts +15 -14
- package/dist/contexts/newOrgConfigContext/index.js +6 -6
- package/dist/contexts/searchContext/index.cjs +10 -13
- package/dist/contexts/searchContext/index.d.cts +1 -1
- package/dist/contexts/searchContext/index.d.ts +2 -2
- package/dist/contexts/searchContext/index.js +10 -13
- 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 +3 -3
- package/dist/contexts/shopifyUrlContext/index.d.ts +3 -3
- package/dist/contexts/shopifyUrlContext/index.js +1 -1
- package/dist/contexts/systemSettingsContext/index.cjs +1 -1
- package/dist/contexts/systemSettingsContext/index.d.cts +14 -13
- package/dist/contexts/systemSettingsContext/index.d.ts +15 -14
- package/dist/contexts/systemSettingsContext/index.js +1 -1
- package/dist/contexts/types.d.cts +3 -3
- package/dist/contexts/types.d.ts +3 -3
- package/dist/contexts/userIdentityContext/index.cjs +14 -8
- package/dist/contexts/userIdentityContext/index.d.cts +1 -1
- package/dist/contexts/userIdentityContext/index.d.ts +1 -1
- package/dist/contexts/userIdentityContext/index.js +12 -6
- package/dist/{domObserver-Bqf3ooj8.cjs → domObserver-COKvTfZV.cjs} +1 -1
- package/dist/{domObserver-v9ODTyfT.js → domObserver-DEiUh0qg.js} +1 -1
- package/dist/{featureFlagServiceContext-V0J-69ty.d.ts → featureFlagServiceContext-CpxlOkI9.d.ts} +2 -2
- package/dist/{featureFlagServiceContext-Be_LUbFf.d.cts → featureFlagServiceContext-p5UBwPM3.d.cts} +2 -2
- package/dist/frontendConfig-Cawh5iqv.d.ts +859 -0
- package/dist/frontendConfig-iZipB5FG.d.cts +859 -0
- package/dist/{globalSearch-FBk2epe8.cjs → globalSearch-BOG3wmck.cjs} +1 -1
- package/dist/{globalSearch-Ccxq8hNF.js → globalSearch-BQEX-2Ml.js} +1 -1
- package/dist/graphql-CkxgqsXP.js +48 -0
- package/dist/graphql-i3dtpVTl.cjs +71 -0
- package/dist/graphqlConfig-BnfE0ql5.cjs +39 -0
- package/dist/graphqlConfig-CZGjJ8hP.js +14 -0
- package/dist/{graphqlContext-D67VEQg3.d.cts → graphqlContext-BeyKU1Dr.d.cts} +2 -2
- package/dist/{graphqlContext-BQA6gnpH.d.ts → graphqlContext-CXQl0hq2.d.ts} +3 -3
- package/dist/{graphqlContext-W0cZNBf1.cjs → graphqlContext-DP8T3-Kd.cjs} +4 -4
- package/dist/{graphqlContext-Ci5GRAdH.js → graphqlContext-czH0kIZg.js} +3 -3
- package/dist/hooks/AmplitudeOperations/index.cjs +8 -8
- package/dist/hooks/AmplitudeOperations/index.d.cts +1 -1
- package/dist/hooks/AmplitudeOperations/index.d.ts +1 -1
- package/dist/hooks/AmplitudeOperations/index.js +8 -8
- package/dist/hooks/AppDetails/index.cjs +7 -12
- package/dist/hooks/AppDetails/index.d.cts +12 -11
- package/dist/hooks/AppDetails/index.d.ts +13 -12
- package/dist/hooks/AppDetails/index.js +7 -12
- package/dist/hooks/CdnOperations/index.cjs +1 -1
- package/dist/hooks/CdnOperations/index.js +1 -1
- package/dist/hooks/ChatToggle/index.cjs +13 -12
- 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 -9
- package/dist/hooks/ChatToggleAnalytics/index.cjs +9 -9
- package/dist/hooks/ChatToggleAnalytics/index.d.cts +1 -1
- package/dist/hooks/ChatToggleAnalytics/index.d.ts +1 -1
- package/dist/hooks/ChatToggleAnalytics/index.js +9 -9
- package/dist/hooks/Debounce/index.cjs +20 -2
- package/dist/hooks/Debounce/index.js +18 -2
- package/dist/hooks/ElementObserver/index.cjs +1 -1
- package/dist/hooks/ElementObserver/index.d.cts +1 -1
- package/dist/hooks/ElementObserver/index.d.ts +1 -1
- package/dist/hooks/ElementObserver/index.js +1 -1
- package/dist/hooks/GrabAndScroll/index.d.cts +2 -2
- package/dist/hooks/GrabAndScroll/index.d.ts +2 -2
- package/dist/hooks/GraphQLConfig/index.cjs +4 -4
- package/dist/hooks/GraphQLConfig/index.d.cts +13 -12
- package/dist/hooks/GraphQLConfig/index.d.ts +14 -13
- package/dist/hooks/GraphQLConfig/index.js +4 -4
- package/dist/hooks/IdentifyUser/index.cjs +14 -8
- package/dist/hooks/IdentifyUser/index.js +13 -7
- package/dist/hooks/ImageResolver/index.cjs +2 -2
- package/dist/hooks/ImageResolver/index.js +2 -2
- package/dist/hooks/Intersection/index.cjs +1 -1
- package/dist/hooks/Intersection/index.js +1 -1
- package/dist/hooks/MessageFilter/index.cjs +2 -2
- package/dist/hooks/MessageFilter/index.d.cts +12 -11
- package/dist/hooks/MessageFilter/index.d.ts +13 -12
- package/dist/hooks/MessageFilter/index.js +2 -2
- package/dist/hooks/NewOrgConfig/index.cjs +7 -7
- package/dist/hooks/NewOrgConfig/index.d.cts +14 -13
- package/dist/hooks/NewOrgConfig/index.d.ts +15 -14
- package/dist/hooks/NewOrgConfig/index.js +7 -7
- package/dist/hooks/Search/index.cjs +1469 -159
- package/dist/hooks/Search/index.d.cts +21 -17
- package/dist/hooks/Search/index.d.ts +22 -18
- package/dist/hooks/Search/index.js +1464 -154
- package/dist/hooks/SearchOperations/index.cjs +11 -14
- package/dist/hooks/SearchOperations/index.d.cts +1 -1
- package/dist/hooks/SearchOperations/index.d.ts +2 -2
- package/dist/hooks/SearchOperations/index.js +11 -14
- 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 +5 -5
- package/dist/hooks/ShopifyUrlOperations/index.d.ts +5 -5
- package/dist/hooks/ShopifyUrlOperations/index.js +1 -1
- package/dist/hooks/SystemSettingsContext/index.cjs +2 -2
- package/dist/hooks/SystemSettingsContext/index.d.cts +14 -13
- package/dist/hooks/SystemSettingsContext/index.d.ts +15 -14
- package/dist/hooks/SystemSettingsContext/index.js +2 -2
- package/dist/hooks/TrackComponentVisibleEvent/index.cjs +8 -8
- package/dist/hooks/TrackComponentVisibleEvent/index.d.cts +2 -2
- package/dist/hooks/TrackComponentVisibleEvent/index.d.ts +2 -2
- package/dist/hooks/TrackComponentVisibleEvent/index.js +8 -8
- package/dist/hooks/UpdateAnalyticsProps/index.cjs +11 -11
- package/dist/hooks/UpdateAnalyticsProps/index.js +6 -6
- package/dist/hooks/utils.d.cts +12 -11
- package/dist/hooks/utils.d.ts +13 -12
- package/dist/{index-BeYfyZ6k.d.ts → index--9_c4tze.d.ts} +1 -1
- package/dist/index-BEpDGqnz.d.cts +41 -0
- package/dist/{index-xHVrsrbz.d.ts → index-BKvFVPUX.d.ts} +1 -1
- package/dist/{index-DJTrxIFJ.d.ts → index-BNHIIgYk.d.ts} +1 -1
- package/dist/{index-BeGt0Aw3.d.cts → index-BSd8767K.d.cts} +5 -5
- package/dist/index-BUDrAxnl.d.ts +673 -0
- package/dist/{index-DzbkQtaK.d.cts → index-CCboEuTO.d.cts} +1 -1
- package/dist/{index-FQjyuD3D.d.cts → index-COXkY78t.d.cts} +1 -1
- package/dist/{index-xhBQ1HBx.d.ts → index-CUO68KG3.d.ts} +34 -34
- package/dist/{index-DazMsEy_.d.ts → index-D7htGSQC.d.ts} +1 -1
- package/dist/index-DM_5fh8c.d.ts +101 -0
- package/dist/index-DU7uw0ba.d.cts +101 -0
- package/dist/{index-Da1s8h5C.d.cts → index-DZtnHhlr.d.cts} +1 -1
- package/dist/{index-h809JLbL.d.ts → index-Dtw-hJdt.d.ts} +1 -1
- package/dist/{index-Dfwnna1j.d.ts → index-Dxpscrvz.d.ts} +1 -1
- package/dist/index-Dy3TTIOm.d.cts +673 -0
- package/dist/index-ErVcwUnR.d.ts +41 -0
- package/dist/{index-Cyq5HiC0.d.cts → index-OkKEOL6H.d.cts} +1 -1
- package/dist/{index-9NE86em3.d.cts → index-hAqp0oYb.d.cts} +1 -1
- package/dist/interceptors/index.d.cts +13 -12
- package/dist/interceptors/index.d.ts +14 -13
- package/dist/interceptors/types.d.cts +12 -11
- package/dist/interceptors/types.d.ts +13 -12
- package/dist/models-CWOgrLCm.js +1284 -0
- package/dist/models-DqdLOi2I.cjs +1519 -0
- package/dist/{newOrgConfigAtom-DxILMn2I.cjs → newOrgConfigAtom-CPA6Gp6n.cjs} +1 -1
- package/dist/{newOrgConfigAtom-sqve6LZU.js → newOrgConfigAtom-DEUj6H-p.js} +1 -1
- package/dist/{newOrgConfigContext-Cl4H9c3q.cjs → newOrgConfigContext-Bet9CgKP.cjs} +3 -3
- package/dist/{newOrgConfigContext-DQiuf8nd.js → newOrgConfigContext-Bi_dBNe5.js} +3 -3
- package/dist/{newOrgConfigContext-5Bw7RwT-.d.cts → newOrgConfigContext-CJI3tsVV.d.cts} +2 -2
- package/dist/{newOrgConfigContext-CS8IA5Eg.d.ts → newOrgConfigContext-I2qceBB4.d.ts} +2 -2
- package/dist/{nodeSelector-BiCDowlK.d.ts → nodeSelector-B5NfnUHv.d.ts} +1 -1
- package/dist/{nodeSelector-B3bPtEjX.d.cts → nodeSelector-vKB44CDB.d.cts} +1 -1
- package/dist/{org-DlAesvQ_.cjs → org-B_cWn2bt.cjs} +1 -1
- package/dist/{org-vi0njpBh.js → org-h32_LSEb.js} +1 -1
- package/dist/orgAnalyticsConfig-Bm23fw4s.cjs +39 -0
- package/dist/orgAnalyticsConfig-CpBmga08.js +14 -0
- package/dist/responseGenerics-D9bS-Dd6.d.ts +148 -0
- package/dist/{index-CCa4tZuO.d.ts → responseGenerics-DWLV09cQ.d.cts} +4 -40
- package/dist/{search-y-ioX5Mz.d.cts → search-6RrxBXD6.d.cts} +1 -1
- package/dist/{search-CXXslzAO.cjs → search-Csh2n66W.cjs} +5 -5
- package/dist/{search-DBSMrXWv.js → search-DkiqkogN.js} +5 -5
- package/dist/{search-1NQLQD9d.d.ts → search-DrJiCT7d.d.ts} +2 -2
- package/dist/{search-filter-types-BxaNSLs_.d.cts → search-filter-types-BItKtezf.d.cts} +1 -1
- package/dist/{search-filter-types-DPgeG8FS.d.ts → search-filter-types-CGFhksO3.d.ts} +1 -1
- package/dist/{searchContext-mvwUJncR.js → searchContext-BmgoAFMF.js} +4 -4
- package/dist/{searchContext-DXW6xvXv.cjs → searchContext-DksJfC1s.cjs} +6 -6
- package/dist/{searchServiceAdapter-DEv1tTn0.cjs → searchServiceAdapter-BGlvoZFE.cjs} +1 -1
- package/dist/{searchServiceAdapter-WyCU55NV.js → searchServiceAdapter-Db6jEcJs.js} +1 -1
- package/dist/{sessionStorageContext-1Ks_d4Z0.cjs → sessionStorageContext-B6FsNKjj.cjs} +1 -1
- package/dist/{sessionStorageContext-CDcl7NVl.js → sessionStorageContext-CLYCm83p.js} +1 -1
- package/dist/{shopifyUrlContext-CejRZfj7.js → shopifyUrlContext-C-PkSgNC.js} +1 -1
- package/dist/{shopifyUrlContext-lnHoAOEf.cjs → shopifyUrlContext-ZOcARiMR.cjs} +1 -1
- package/dist/{spiffyWidgets-B1uc84_g.d.ts → spiffyWidgets-CR6F7FRE.d.ts} +1 -1
- package/dist/{spiffyWidgets-BuS00VaQ.d.cts → spiffyWidgets-eNbU1gMc.d.cts} +1 -1
- package/dist/{systemSettingsContext-CVUxEcsU.js → systemSettingsContext-DF0jSq9m.js} +1 -1
- package/dist/{systemSettingsContext-B0Kyq7nA.cjs → systemSettingsContext-dmE1v6w8.cjs} +1 -1
- package/dist/{test-types-y6kp-tiw.d.ts → test-types-BEml_bm3.d.ts} +1 -1
- package/dist/{test-types-ThQiO_cc.d.cts → test-types-Dsu8RJZu.d.cts} +1 -1
- package/dist/types/index.cjs +1 -16
- package/dist/types/index.d.cts +3 -17
- package/dist/types/index.d.ts +3 -17
- package/dist/types/index.js +2 -16
- package/dist/{types-Db5Eux6K.d.ts → types-4LQ7LUCk.d.ts} +2 -2
- package/dist/types-BegmH0S1.d.ts +60 -0
- package/dist/types-BuvXXGxE.cjs +48 -0
- package/dist/types-CtUb63bt.js +1 -1
- package/dist/{types-zQGBI-Yo.d.cts → types-DFsSqmWx.d.cts} +2 -2
- package/dist/types-DWorwfS-.d.cts +60 -0
- package/dist/types-DXnG1tV0.js +30 -0
- package/dist/types-UUvB6h05.cjs +1 -1
- package/dist/types.d.cts +4 -23
- package/dist/types.d.ts +4 -23
- package/dist/unsupportedProductExceptions-DGENUnEA.cjs +32 -0
- package/dist/unsupportedProductExceptions-uQuuelOs.js +20 -0
- package/dist/{useAmplitudeOperations-jqa7K9dH.cjs → useAmplitudeOperations-Bo6YNbTV.cjs} +3 -3
- package/dist/{useAmplitudeOperations-DYs1h8a_.js → useAmplitudeOperations-zIRSqmMW.js} +2 -2
- package/dist/{useAppDetails-BRUqZEyt.js → useAppDetails-B584gkCs.js} +3 -3
- package/dist/{useAppDetails-C71k0brz.cjs → useAppDetails-DczgqeLG.cjs} +6 -6
- package/dist/{useGraphQLConfig-5VwS9Q_Z.js → useGraphQLConfig-7UxACM4n.js} +2 -2
- package/dist/{useGraphQLConfig-Cj26_J9I.cjs → useGraphQLConfig-D_rF2Sun.cjs} +2 -2
- package/dist/{useIntersection-Cncgxdmy.js → useIntersection-CZSEBUbv.js} +1 -1
- package/dist/{useIntersection-m4PEpvG7.cjs → useIntersection-DSDREfj6.cjs} +1 -1
- package/dist/userIdentityContext-BqbNu7xu.cjs +132 -0
- package/dist/userIdentityContext-BxFH9FNQ.js +115 -0
- package/dist/{userIdentityContext-BVODeTlN.d.ts → userIdentityContext-C6kApbuk.d.ts} +1 -1
- package/dist/{userIdentityContext-D2oFVFzo.d.cts → userIdentityContext-kU1PIo8K.d.cts} +1 -1
- package/dist/{utils-DpneNSJf.d.ts → utils-BRkGP1eb.d.ts} +1 -1
- package/dist/utils-C1ErYSoW.js +606 -0
- package/dist/{utils-BxPPugeP.d.cts → utils-CBD4g2Nc.d.cts} +4 -4
- package/dist/{utils-2SWrJ12w.cjs → utils-CvLmSsUj.cjs} +1 -1
- package/dist/{utils-CqBxIpEV.js → utils-D82gfbgU.js} +1 -1
- package/dist/{utils-B3x_9JTY.d.cts → utils-DCrwX6FT.d.cts} +1 -1
- package/dist/{utils-Covisryh.d.ts → utils-QKFAbPT6.d.ts} +4 -4
- package/dist/utils-mqfncrhI.cjs +715 -0
- package/package.json +18 -13
- package/src/application/commerce-api.ts +2 -0
- package/src/application/models/graphql/index.ts +1 -0
- package/src/application/utils/__tests__/divideArrays.test.ts +12 -13
- package/src/atoms/app/index.ts +1 -2
- package/src/atoms/search/productRetrievalAPI.ts +70 -0
- package/src/atoms/search/productRetrievalAdapter.ts +25 -0
- package/src/atoms/search/types.ts +13 -0
- package/src/contexts/enviveConfigContext/__tests__/enviveConfigContext.test.tsx +411 -0
- package/src/contexts/graphqlContext/__tests__/graphqlContext.test.tsx +790 -0
- package/src/contexts/localStorageContext/__tests__/localStorageContext.test.tsx +775 -0
- package/src/contexts/newOrgConfigContext/__tests__/newOrgConfigContext.test.tsx +495 -0
- package/src/contexts/searchContext/__tests__/searchContext.test.tsx +806 -0
- package/src/contexts/systemSettingsContext/__tests__/systemSettingsContext.test.tsx +506 -0
- package/src/contexts/types.ts +16 -14
- package/src/contexts/userIdentityContext/__tests__/userIdentityContext.test.tsx +663 -0
- package/src/contexts/userIdentityContext/userIdentityContext.tsx +6 -0
- package/src/hooks/Search/useRecommendedProducts.ts +48 -0
- package/src/hooks/Search/useSearch.tsx +89 -182
- package/src/hooks/Search/useSearchInput.ts +263 -0
- package/src/types/FilterAttribute.ts +35 -0
- package/src/types/index.ts +0 -1
- package/src/types.ts +0 -16
- package/dist/frontendConfig-CeWhVevA.d.ts +0 -857
- package/dist/frontendConfig-OWWJmuPc.d.cts +0 -857
- package/dist/graphql-3PxNRFOc.js +0 -36
- package/dist/graphql-DGYfelZp.cjs +0 -53
- package/dist/graphqlConfig-GHZ1UgCw.cjs +0 -73
- package/dist/graphqlConfig-mDg6J44N.js +0 -24
- package/dist/hooks/FloatingButtonVisibility/index.cjs +0 -73
- package/dist/hooks/FloatingButtonVisibility/index.d.cts +0 -7
- package/dist/hooks/FloatingButtonVisibility/index.d.ts +0 -7
- package/dist/hooks/FloatingButtonVisibility/index.js +0 -69
- package/dist/hooks/LastInteraction/index.cjs +0 -34
- package/dist/hooks/LastInteraction/index.d.cts +0 -17
- package/dist/hooks/LastInteraction/index.d.ts +0 -17
- package/dist/hooks/LastInteraction/index.js +0 -32
- package/dist/index-Bmub8e38.d.cts +0 -98
- package/dist/index-CiWEYzXl.d.cts +0 -184
- package/dist/index-D4c-port.d.ts +0 -676
- package/dist/index-O33GSSRr.d.cts +0 -676
- package/dist/index-bjMvkcBF.d.ts +0 -98
- package/dist/models-D-4db7XW.cjs +0 -1537
- package/dist/models-c86hYW-F.js +0 -1296
- package/dist/types-BCz-hOvv.d.ts +0 -51
- package/dist/types-CKMMb_gX.d.cts +0 -51
- package/dist/types-CS0Hrzja.js +0 -30
- package/dist/types-CxObxLKs.cjs +0 -48
- package/dist/useDebounce-DZ8Cgiwc.cjs +0 -26
- package/dist/useDebounce-v9cezyjn.js +0 -19
- package/dist/utils-CLGXsOwE.cjs +0 -1591
- package/dist/utils-jYtD3hmA.js +0 -1385
- package/src/hooks/FloatingButtonVisibility/index.ts +0 -1
- package/src/hooks/FloatingButtonVisibility/useFloatingButtonVisibility.ts +0 -99
- package/src/hooks/LastInteraction/index.ts +0 -1
- package/src/hooks/LastInteraction/useLastInteraction.ts +0 -42
- package/src/types/floatingbuttonoverrides-types.ts +0 -10
- /package/dist/{AmplitudeOperations-ni7wVevx.js → AmplitudeOperations-ChZWcSsc.js} +0 -0
- /package/dist/{AmplitudeOperations-DxQnurSG.cjs → AmplitudeOperations-JggIc1zD.cjs} +0 -0
- /package/dist/{globalSearch-BpGfkuXz.js → amplitudeContext-BItT9HmT.js} +0 -0
- /package/dist/{globalSearch-B9DRBxSM.cjs → amplitudeContext-DPtyVv3Q.cjs} +0 -0
- /package/dist/{index-CgAfoNpB.d.ts → index-A0HvA68Y.d.cts} +0 -0
- /package/dist/{index-RcVcRKH7.d.cts → index-DNVvRcKu.d.ts} +0 -0
|
@@ -0,0 +1,790 @@
|
|
|
1
|
+
import React from "react";
|
|
2
|
+
import { render, screen, waitFor, act } from "@testing-library/react";
|
|
3
|
+
import { Provider } from "jotai";
|
|
4
|
+
import { useAtomValue } from "jotai";
|
|
5
|
+
import { GraphQLProvider, useGraphQLClient } from "../graphqlContext";
|
|
6
|
+
import { EnviveConfigProvider } from "src/contexts/enviveConfigContext/enviveConfigContext";
|
|
7
|
+
import {
|
|
8
|
+
orgLevelApiKeyAtom,
|
|
9
|
+
baseUrlAtom,
|
|
10
|
+
} from "src/atoms/envive/enviveConfig";
|
|
11
|
+
import Logger from "src/application/logging/logger";
|
|
12
|
+
import { getMerchantOrgIdQuery } from "src/application/models/graphql/queries/getMerchantOrgIdQuery";
|
|
13
|
+
|
|
14
|
+
// Mock the Logger to avoid console output in tests
|
|
15
|
+
vi.spyOn(Logger, "logDebug").mockImplementation(() => {});
|
|
16
|
+
vi.spyOn(Logger, "logWarn").mockImplementation(() => {});
|
|
17
|
+
vi.spyOn(Logger, "logError").mockImplementation(() => {});
|
|
18
|
+
|
|
19
|
+
// Mock fetch globally
|
|
20
|
+
global.fetch = vi.fn();
|
|
21
|
+
|
|
22
|
+
// Component that uses the useGraphQLClient hook
|
|
23
|
+
const MockGraphQLComponent: React.FC = () => {
|
|
24
|
+
const client = useGraphQLClient();
|
|
25
|
+
|
|
26
|
+
return (
|
|
27
|
+
<div data-testid="graphql-component">
|
|
28
|
+
<div data-testid="is-ready">{client.isReady.toString()}</div>
|
|
29
|
+
<button
|
|
30
|
+
data-testid="execute-query-btn"
|
|
31
|
+
onClick={async () => {
|
|
32
|
+
try {
|
|
33
|
+
const result = await client.executeQuery("query { test }");
|
|
34
|
+
(window as any).lastQueryResult = result;
|
|
35
|
+
} catch (error) {
|
|
36
|
+
(window as any).lastQueryError = error;
|
|
37
|
+
}
|
|
38
|
+
}}
|
|
39
|
+
>
|
|
40
|
+
Execute Query
|
|
41
|
+
</button>
|
|
42
|
+
<button
|
|
43
|
+
data-testid="get-org-id-btn"
|
|
44
|
+
onClick={async () => {
|
|
45
|
+
try {
|
|
46
|
+
const orgId = await client.getOrgId();
|
|
47
|
+
(window as any).lastOrgId = orgId;
|
|
48
|
+
} catch (error) {
|
|
49
|
+
(window as any).lastOrgIdError = error;
|
|
50
|
+
}
|
|
51
|
+
}}
|
|
52
|
+
>
|
|
53
|
+
Get Org ID
|
|
54
|
+
</button>
|
|
55
|
+
<button
|
|
56
|
+
data-testid="get-config-btn"
|
|
57
|
+
onClick={async () => {
|
|
58
|
+
try {
|
|
59
|
+
const config = await client.getColorsAndFrontendConfig();
|
|
60
|
+
(window as any).lastConfig = config;
|
|
61
|
+
} catch (error) {
|
|
62
|
+
(window as any).lastConfigError = error;
|
|
63
|
+
}
|
|
64
|
+
}}
|
|
65
|
+
>
|
|
66
|
+
Get Config
|
|
67
|
+
</button>
|
|
68
|
+
</div>
|
|
69
|
+
);
|
|
70
|
+
};
|
|
71
|
+
|
|
72
|
+
// Component that reads atoms directly to verify they're set
|
|
73
|
+
const AtomReaderComponent: React.FC = () => {
|
|
74
|
+
const apiKey = useAtomValue(orgLevelApiKeyAtom);
|
|
75
|
+
const baseUrl = useAtomValue(baseUrlAtom);
|
|
76
|
+
|
|
77
|
+
return (
|
|
78
|
+
<div data-testid="atom-reader">
|
|
79
|
+
<div data-testid="atom-api-key">{apiKey || "not-set"}</div>
|
|
80
|
+
<div data-testid="atom-base-url">{baseUrl || "not-set"}</div>
|
|
81
|
+
</div>
|
|
82
|
+
);
|
|
83
|
+
};
|
|
84
|
+
|
|
85
|
+
// Wrapper component to ensure providers are in correct order
|
|
86
|
+
const TestWrapper: React.FC<{
|
|
87
|
+
children: React.ReactNode;
|
|
88
|
+
orgLevelApiKey?: string;
|
|
89
|
+
baseUrl?: string;
|
|
90
|
+
}> = ({ children, orgLevelApiKey, baseUrl }) => {
|
|
91
|
+
return (
|
|
92
|
+
<Provider>
|
|
93
|
+
<EnviveConfigProvider
|
|
94
|
+
identifyingPrefix="test"
|
|
95
|
+
orgLevelApiKey={orgLevelApiKey}
|
|
96
|
+
baseUrl={baseUrl}
|
|
97
|
+
>
|
|
98
|
+
<GraphQLProvider>{children}</GraphQLProvider>
|
|
99
|
+
</EnviveConfigProvider>
|
|
100
|
+
</Provider>
|
|
101
|
+
);
|
|
102
|
+
};
|
|
103
|
+
|
|
104
|
+
describe("GraphQLProvider", () => {
|
|
105
|
+
beforeEach(() => {
|
|
106
|
+
vi.clearAllMocks();
|
|
107
|
+
(global.fetch as any).mockClear();
|
|
108
|
+
// Clear any stored results
|
|
109
|
+
delete (window as any).lastQueryResult;
|
|
110
|
+
delete (window as any).lastQueryError;
|
|
111
|
+
delete (window as any).lastOrgId;
|
|
112
|
+
delete (window as any).lastOrgIdError;
|
|
113
|
+
delete (window as any).lastConfig;
|
|
114
|
+
delete (window as any).lastConfigError;
|
|
115
|
+
});
|
|
116
|
+
|
|
117
|
+
describe("Provider Integration with Jotai Store", () => {
|
|
118
|
+
it("should read atoms correctly when provider is mounted", async () => {
|
|
119
|
+
const testConfig = {
|
|
120
|
+
orgLevelApiKey: "test-api-key",
|
|
121
|
+
baseUrl: "https://test-api.example.com",
|
|
122
|
+
};
|
|
123
|
+
|
|
124
|
+
render(
|
|
125
|
+
<TestWrapper {...testConfig}>
|
|
126
|
+
<AtomReaderComponent />
|
|
127
|
+
</TestWrapper>
|
|
128
|
+
);
|
|
129
|
+
|
|
130
|
+
await waitFor(() => {
|
|
131
|
+
expect(screen.getByTestId("atom-api-key")).toHaveTextContent(
|
|
132
|
+
testConfig.orgLevelApiKey
|
|
133
|
+
);
|
|
134
|
+
});
|
|
135
|
+
|
|
136
|
+
expect(screen.getByTestId("atom-base-url")).toHaveTextContent(
|
|
137
|
+
testConfig.baseUrl
|
|
138
|
+
);
|
|
139
|
+
});
|
|
140
|
+
});
|
|
141
|
+
|
|
142
|
+
describe("useGraphQLClient Hook Integration", () => {
|
|
143
|
+
it("should provide GraphQL context through useGraphQLClient hook", async () => {
|
|
144
|
+
render(
|
|
145
|
+
<TestWrapper
|
|
146
|
+
orgLevelApiKey="test-key"
|
|
147
|
+
baseUrl="https://test-api.example.com"
|
|
148
|
+
>
|
|
149
|
+
<MockGraphQLComponent />
|
|
150
|
+
</TestWrapper>
|
|
151
|
+
);
|
|
152
|
+
|
|
153
|
+
await waitFor(() => {
|
|
154
|
+
expect(screen.getByTestId("is-ready")).toHaveTextContent("true");
|
|
155
|
+
});
|
|
156
|
+
|
|
157
|
+
// Verify all context methods are accessible
|
|
158
|
+
expect(screen.getByTestId("graphql-component")).toBeInTheDocument();
|
|
159
|
+
});
|
|
160
|
+
|
|
161
|
+
it("should throw error when used outside of GraphQLProvider", () => {
|
|
162
|
+
const consoleSpy = vi
|
|
163
|
+
.spyOn(console, "error")
|
|
164
|
+
.mockImplementation(() => {});
|
|
165
|
+
|
|
166
|
+
const TestComponent: React.FC = () => {
|
|
167
|
+
try {
|
|
168
|
+
useGraphQLClient();
|
|
169
|
+
return <div data-testid="no-error">No Error</div>;
|
|
170
|
+
} catch (error: any) {
|
|
171
|
+
return <div data-testid="error">{error.message}</div>;
|
|
172
|
+
}
|
|
173
|
+
};
|
|
174
|
+
|
|
175
|
+
render(
|
|
176
|
+
<Provider>
|
|
177
|
+
<TestComponent />
|
|
178
|
+
</Provider>
|
|
179
|
+
);
|
|
180
|
+
|
|
181
|
+
expect(screen.getByTestId("error")).toHaveTextContent(
|
|
182
|
+
"useGraphQLClient must be used within a GraphQLProvider"
|
|
183
|
+
);
|
|
184
|
+
|
|
185
|
+
consoleSpy.mockRestore();
|
|
186
|
+
});
|
|
187
|
+
});
|
|
188
|
+
|
|
189
|
+
describe("isReady State", () => {
|
|
190
|
+
it("should be false when orgLevelApiKey is missing", async () => {
|
|
191
|
+
render(
|
|
192
|
+
<TestWrapper baseUrl="https://test-api.example.com">
|
|
193
|
+
<MockGraphQLComponent />
|
|
194
|
+
</TestWrapper>
|
|
195
|
+
);
|
|
196
|
+
|
|
197
|
+
await waitFor(() => {
|
|
198
|
+
expect(screen.getByTestId("is-ready")).toHaveTextContent("false");
|
|
199
|
+
});
|
|
200
|
+
});
|
|
201
|
+
|
|
202
|
+
it("should be true when baseUrl is missing but has default value", async () => {
|
|
203
|
+
// Note: baseUrlAtom has a default value, so isReady will be true
|
|
204
|
+
// even if baseUrl is not explicitly provided
|
|
205
|
+
render(
|
|
206
|
+
<TestWrapper orgLevelApiKey="test-key">
|
|
207
|
+
<MockGraphQLComponent />
|
|
208
|
+
</TestWrapper>
|
|
209
|
+
);
|
|
210
|
+
|
|
211
|
+
await waitFor(() => {
|
|
212
|
+
expect(screen.getByTestId("is-ready")).toHaveTextContent("true");
|
|
213
|
+
});
|
|
214
|
+
});
|
|
215
|
+
|
|
216
|
+
it("should be true when all required dependencies are present", async () => {
|
|
217
|
+
render(
|
|
218
|
+
<TestWrapper
|
|
219
|
+
orgLevelApiKey="test-key"
|
|
220
|
+
baseUrl="https://test-api.example.com"
|
|
221
|
+
>
|
|
222
|
+
<MockGraphQLComponent />
|
|
223
|
+
</TestWrapper>
|
|
224
|
+
);
|
|
225
|
+
|
|
226
|
+
await waitFor(() => {
|
|
227
|
+
expect(screen.getByTestId("is-ready")).toHaveTextContent("true");
|
|
228
|
+
});
|
|
229
|
+
});
|
|
230
|
+
});
|
|
231
|
+
|
|
232
|
+
describe("executeQuery", () => {
|
|
233
|
+
it("should execute a GraphQL query successfully", async () => {
|
|
234
|
+
const mockResponse = {
|
|
235
|
+
data: { test: "result" },
|
|
236
|
+
};
|
|
237
|
+
|
|
238
|
+
(global.fetch as any).mockResolvedValueOnce({
|
|
239
|
+
ok: true,
|
|
240
|
+
json: async () => mockResponse,
|
|
241
|
+
});
|
|
242
|
+
|
|
243
|
+
render(
|
|
244
|
+
<TestWrapper
|
|
245
|
+
orgLevelApiKey="test-key"
|
|
246
|
+
baseUrl="https://test-api.example.com"
|
|
247
|
+
>
|
|
248
|
+
<MockGraphQLComponent />
|
|
249
|
+
</TestWrapper>
|
|
250
|
+
);
|
|
251
|
+
|
|
252
|
+
await waitFor(() => {
|
|
253
|
+
expect(screen.getByTestId("is-ready")).toHaveTextContent("true");
|
|
254
|
+
});
|
|
255
|
+
|
|
256
|
+
await act(async () => {
|
|
257
|
+
screen.getByTestId("execute-query-btn").click();
|
|
258
|
+
});
|
|
259
|
+
|
|
260
|
+
await waitFor(() => {
|
|
261
|
+
expect((window as any).lastQueryResult).toEqual(mockResponse.data);
|
|
262
|
+
});
|
|
263
|
+
|
|
264
|
+
expect(global.fetch).toHaveBeenCalledWith(
|
|
265
|
+
"https://test-api.example.com/v1/graphql",
|
|
266
|
+
{
|
|
267
|
+
method: "POST",
|
|
268
|
+
headers: {
|
|
269
|
+
"Content-Type": "application/json",
|
|
270
|
+
Authorization: "Bearer test-key",
|
|
271
|
+
},
|
|
272
|
+
body: JSON.stringify({ query: "query { test }", variables: undefined }),
|
|
273
|
+
}
|
|
274
|
+
);
|
|
275
|
+
});
|
|
276
|
+
|
|
277
|
+
it("should execute a query with variables", async () => {
|
|
278
|
+
const mockResponse = {
|
|
279
|
+
data: { result: "success" },
|
|
280
|
+
};
|
|
281
|
+
|
|
282
|
+
(global.fetch as any).mockResolvedValueOnce({
|
|
283
|
+
ok: true,
|
|
284
|
+
json: async () => mockResponse,
|
|
285
|
+
});
|
|
286
|
+
|
|
287
|
+
const TestComponent: React.FC = () => {
|
|
288
|
+
const client = useGraphQLClient();
|
|
289
|
+
React.useEffect(() => {
|
|
290
|
+
if (client.isReady) {
|
|
291
|
+
client
|
|
292
|
+
.executeQuery("query Test($id: String)", { id: "123" })
|
|
293
|
+
.then((result) => {
|
|
294
|
+
(window as any).lastQueryResult = result;
|
|
295
|
+
});
|
|
296
|
+
}
|
|
297
|
+
}, [client]);
|
|
298
|
+
|
|
299
|
+
return <div>Test</div>;
|
|
300
|
+
};
|
|
301
|
+
|
|
302
|
+
render(
|
|
303
|
+
<TestWrapper
|
|
304
|
+
orgLevelApiKey="test-key"
|
|
305
|
+
baseUrl="https://test-api.example.com"
|
|
306
|
+
>
|
|
307
|
+
<TestComponent />
|
|
308
|
+
</TestWrapper>
|
|
309
|
+
);
|
|
310
|
+
|
|
311
|
+
await waitFor(() => {
|
|
312
|
+
expect((window as any).lastQueryResult).toEqual(mockResponse.data);
|
|
313
|
+
});
|
|
314
|
+
|
|
315
|
+
expect(global.fetch).toHaveBeenCalledWith(
|
|
316
|
+
"https://test-api.example.com/v1/graphql",
|
|
317
|
+
{
|
|
318
|
+
method: "POST",
|
|
319
|
+
headers: {
|
|
320
|
+
"Content-Type": "application/json",
|
|
321
|
+
Authorization: "Bearer test-key",
|
|
322
|
+
},
|
|
323
|
+
body: JSON.stringify({
|
|
324
|
+
query: "query Test($id: String)",
|
|
325
|
+
variables: { id: "123" },
|
|
326
|
+
}),
|
|
327
|
+
}
|
|
328
|
+
);
|
|
329
|
+
});
|
|
330
|
+
|
|
331
|
+
it("should throw error when client is not ready", async () => {
|
|
332
|
+
const TestComponent: React.FC = () => {
|
|
333
|
+
const client = useGraphQLClient();
|
|
334
|
+
React.useEffect(() => {
|
|
335
|
+
client
|
|
336
|
+
.executeQuery("query { test }")
|
|
337
|
+
.catch((error) => {
|
|
338
|
+
(window as any).lastQueryError = error;
|
|
339
|
+
});
|
|
340
|
+
}, [client]);
|
|
341
|
+
|
|
342
|
+
return <div>Test</div>;
|
|
343
|
+
};
|
|
344
|
+
|
|
345
|
+
render(
|
|
346
|
+
<TestWrapper baseUrl="https://test-api.example.com">
|
|
347
|
+
<TestComponent />
|
|
348
|
+
</TestWrapper>
|
|
349
|
+
);
|
|
350
|
+
|
|
351
|
+
await waitFor(() => {
|
|
352
|
+
expect((window as any).lastQueryError).toBeDefined();
|
|
353
|
+
expect((window as any).lastQueryError.message).toBe(
|
|
354
|
+
"GraphQL client not ready - missing apiKey or baseUrl"
|
|
355
|
+
);
|
|
356
|
+
});
|
|
357
|
+
});
|
|
358
|
+
|
|
359
|
+
it("should throw error when fetch fails", async () => {
|
|
360
|
+
(global.fetch as any).mockResolvedValueOnce({
|
|
361
|
+
ok: false,
|
|
362
|
+
statusText: "Internal Server Error",
|
|
363
|
+
});
|
|
364
|
+
|
|
365
|
+
render(
|
|
366
|
+
<TestWrapper
|
|
367
|
+
orgLevelApiKey="test-key"
|
|
368
|
+
baseUrl="https://test-api.example.com"
|
|
369
|
+
>
|
|
370
|
+
<MockGraphQLComponent />
|
|
371
|
+
</TestWrapper>
|
|
372
|
+
);
|
|
373
|
+
|
|
374
|
+
await waitFor(() => {
|
|
375
|
+
expect(screen.getByTestId("is-ready")).toHaveTextContent("true");
|
|
376
|
+
});
|
|
377
|
+
|
|
378
|
+
await act(async () => {
|
|
379
|
+
screen.getByTestId("execute-query-btn").click();
|
|
380
|
+
});
|
|
381
|
+
|
|
382
|
+
await waitFor(() => {
|
|
383
|
+
expect((window as any).lastQueryError).toBeDefined();
|
|
384
|
+
expect((window as any).lastQueryError.message).toContain(
|
|
385
|
+
"GraphQL request failed"
|
|
386
|
+
);
|
|
387
|
+
});
|
|
388
|
+
});
|
|
389
|
+
|
|
390
|
+
it("should throw error when GraphQL response contains errors", async () => {
|
|
391
|
+
const mockResponse = {
|
|
392
|
+
data: null,
|
|
393
|
+
errors: [{ message: "GraphQL error" }],
|
|
394
|
+
};
|
|
395
|
+
|
|
396
|
+
(global.fetch as any).mockResolvedValueOnce({
|
|
397
|
+
ok: true,
|
|
398
|
+
json: async () => mockResponse,
|
|
399
|
+
});
|
|
400
|
+
|
|
401
|
+
render(
|
|
402
|
+
<TestWrapper
|
|
403
|
+
orgLevelApiKey="test-key"
|
|
404
|
+
baseUrl="https://test-api.example.com"
|
|
405
|
+
>
|
|
406
|
+
<MockGraphQLComponent />
|
|
407
|
+
</TestWrapper>
|
|
408
|
+
);
|
|
409
|
+
|
|
410
|
+
await waitFor(() => {
|
|
411
|
+
expect(screen.getByTestId("is-ready")).toHaveTextContent("true");
|
|
412
|
+
});
|
|
413
|
+
|
|
414
|
+
await act(async () => {
|
|
415
|
+
screen.getByTestId("execute-query-btn").click();
|
|
416
|
+
});
|
|
417
|
+
|
|
418
|
+
await waitFor(() => {
|
|
419
|
+
expect((window as any).lastQueryError).toBeDefined();
|
|
420
|
+
expect((window as any).lastQueryError.message).toContain(
|
|
421
|
+
"GraphQL errors"
|
|
422
|
+
);
|
|
423
|
+
});
|
|
424
|
+
});
|
|
425
|
+
});
|
|
426
|
+
|
|
427
|
+
describe("getOrgId", () => {
|
|
428
|
+
it("should fetch and return org ID successfully", async () => {
|
|
429
|
+
const mockOrgId = "org-123";
|
|
430
|
+
const mockResponse = {
|
|
431
|
+
data: {
|
|
432
|
+
me: {
|
|
433
|
+
org: {
|
|
434
|
+
id: mockOrgId,
|
|
435
|
+
},
|
|
436
|
+
},
|
|
437
|
+
},
|
|
438
|
+
};
|
|
439
|
+
|
|
440
|
+
(global.fetch as any).mockResolvedValueOnce({
|
|
441
|
+
ok: true,
|
|
442
|
+
json: async () => mockResponse,
|
|
443
|
+
});
|
|
444
|
+
|
|
445
|
+
render(
|
|
446
|
+
<TestWrapper
|
|
447
|
+
orgLevelApiKey="test-key"
|
|
448
|
+
baseUrl="https://test-api.example.com"
|
|
449
|
+
>
|
|
450
|
+
<MockGraphQLComponent />
|
|
451
|
+
</TestWrapper>
|
|
452
|
+
);
|
|
453
|
+
|
|
454
|
+
await waitFor(() => {
|
|
455
|
+
expect(screen.getByTestId("is-ready")).toHaveTextContent("true");
|
|
456
|
+
});
|
|
457
|
+
|
|
458
|
+
await act(async () => {
|
|
459
|
+
screen.getByTestId("get-org-id-btn").click();
|
|
460
|
+
});
|
|
461
|
+
|
|
462
|
+
await waitFor(() => {
|
|
463
|
+
expect((window as any).lastOrgId).toBe(mockOrgId);
|
|
464
|
+
});
|
|
465
|
+
|
|
466
|
+
expect(global.fetch).toHaveBeenCalledWith(
|
|
467
|
+
"https://test-api.example.com/v1/graphql",
|
|
468
|
+
expect.objectContaining({
|
|
469
|
+
body: JSON.stringify({
|
|
470
|
+
query: getMerchantOrgIdQuery,
|
|
471
|
+
variables: undefined,
|
|
472
|
+
}),
|
|
473
|
+
})
|
|
474
|
+
);
|
|
475
|
+
});
|
|
476
|
+
|
|
477
|
+
it("should return undefined when org ID is not available", async () => {
|
|
478
|
+
const mockResponse = {
|
|
479
|
+
data: {
|
|
480
|
+
me: {
|
|
481
|
+
org: null,
|
|
482
|
+
},
|
|
483
|
+
},
|
|
484
|
+
};
|
|
485
|
+
|
|
486
|
+
(global.fetch as any).mockResolvedValueOnce({
|
|
487
|
+
ok: true,
|
|
488
|
+
json: async () => mockResponse,
|
|
489
|
+
});
|
|
490
|
+
|
|
491
|
+
render(
|
|
492
|
+
<TestWrapper
|
|
493
|
+
orgLevelApiKey="test-key"
|
|
494
|
+
baseUrl="https://test-api.example.com"
|
|
495
|
+
>
|
|
496
|
+
<MockGraphQLComponent />
|
|
497
|
+
</TestWrapper>
|
|
498
|
+
);
|
|
499
|
+
|
|
500
|
+
await waitFor(() => {
|
|
501
|
+
expect(screen.getByTestId("is-ready")).toHaveTextContent("true");
|
|
502
|
+
});
|
|
503
|
+
|
|
504
|
+
await act(async () => {
|
|
505
|
+
screen.getByTestId("get-org-id-btn").click();
|
|
506
|
+
});
|
|
507
|
+
|
|
508
|
+
await waitFor(() => {
|
|
509
|
+
expect((window as any).lastOrgId).toBeUndefined();
|
|
510
|
+
});
|
|
511
|
+
});
|
|
512
|
+
|
|
513
|
+
it("should return undefined when org.id is empty string", async () => {
|
|
514
|
+
const mockResponse = {
|
|
515
|
+
data: {
|
|
516
|
+
me: {
|
|
517
|
+
org: {
|
|
518
|
+
id: "",
|
|
519
|
+
},
|
|
520
|
+
},
|
|
521
|
+
},
|
|
522
|
+
};
|
|
523
|
+
|
|
524
|
+
(global.fetch as any).mockResolvedValueOnce({
|
|
525
|
+
ok: true,
|
|
526
|
+
json: async () => mockResponse,
|
|
527
|
+
});
|
|
528
|
+
|
|
529
|
+
render(
|
|
530
|
+
<TestWrapper
|
|
531
|
+
orgLevelApiKey="test-key"
|
|
532
|
+
baseUrl="https://test-api.example.com"
|
|
533
|
+
>
|
|
534
|
+
<MockGraphQLComponent />
|
|
535
|
+
</TestWrapper>
|
|
536
|
+
);
|
|
537
|
+
|
|
538
|
+
await waitFor(() => {
|
|
539
|
+
expect(screen.getByTestId("is-ready")).toHaveTextContent("true");
|
|
540
|
+
});
|
|
541
|
+
|
|
542
|
+
await act(async () => {
|
|
543
|
+
screen.getByTestId("get-org-id-btn").click();
|
|
544
|
+
});
|
|
545
|
+
|
|
546
|
+
await waitFor(() => {
|
|
547
|
+
expect((window as any).lastOrgId).toBeUndefined();
|
|
548
|
+
});
|
|
549
|
+
});
|
|
550
|
+
});
|
|
551
|
+
|
|
552
|
+
describe("getColorsAndFrontendConfig", () => {
|
|
553
|
+
it("should fetch and return colors and frontend config successfully", async () => {
|
|
554
|
+
const mockColorsConfig = {
|
|
555
|
+
accent_primary: "#FF0000",
|
|
556
|
+
accent_secondary: "#00FF00",
|
|
557
|
+
background_dark: "#000000",
|
|
558
|
+
};
|
|
559
|
+
const mockFrontendConfig = {
|
|
560
|
+
merchant_override_css: "test-css",
|
|
561
|
+
page_variants: [],
|
|
562
|
+
};
|
|
563
|
+
|
|
564
|
+
const mockResponse = {
|
|
565
|
+
data: {
|
|
566
|
+
me: {
|
|
567
|
+
getProductsConfigByVersion: {
|
|
568
|
+
colors: {
|
|
569
|
+
values: mockColorsConfig,
|
|
570
|
+
},
|
|
571
|
+
frontend: {
|
|
572
|
+
values: mockFrontendConfig,
|
|
573
|
+
},
|
|
574
|
+
},
|
|
575
|
+
},
|
|
576
|
+
},
|
|
577
|
+
};
|
|
578
|
+
|
|
579
|
+
(global.fetch as any).mockResolvedValueOnce({
|
|
580
|
+
ok: true,
|
|
581
|
+
json: async () => mockResponse,
|
|
582
|
+
});
|
|
583
|
+
|
|
584
|
+
render(
|
|
585
|
+
<TestWrapper
|
|
586
|
+
orgLevelApiKey="test-key"
|
|
587
|
+
baseUrl="https://test-api.example.com"
|
|
588
|
+
>
|
|
589
|
+
<MockGraphQLComponent />
|
|
590
|
+
</TestWrapper>
|
|
591
|
+
);
|
|
592
|
+
|
|
593
|
+
await waitFor(() => {
|
|
594
|
+
expect(screen.getByTestId("is-ready")).toHaveTextContent("true");
|
|
595
|
+
});
|
|
596
|
+
|
|
597
|
+
await act(async () => {
|
|
598
|
+
screen.getByTestId("get-config-btn").click();
|
|
599
|
+
});
|
|
600
|
+
|
|
601
|
+
await waitFor(() => {
|
|
602
|
+
const config = (window as any).lastConfig;
|
|
603
|
+
expect(config).toBeDefined();
|
|
604
|
+
expect(config.colorsConfig).toBeDefined();
|
|
605
|
+
expect(config.frontendConfig).toBeDefined();
|
|
606
|
+
});
|
|
607
|
+
});
|
|
608
|
+
|
|
609
|
+
it("should handle missing colors and frontend config gracefully", async () => {
|
|
610
|
+
const mockResponse = {
|
|
611
|
+
data: {
|
|
612
|
+
me: {
|
|
613
|
+
getProductsConfigByVersion: null,
|
|
614
|
+
},
|
|
615
|
+
},
|
|
616
|
+
};
|
|
617
|
+
|
|
618
|
+
(global.fetch as any).mockResolvedValueOnce({
|
|
619
|
+
ok: true,
|
|
620
|
+
json: async () => mockResponse,
|
|
621
|
+
});
|
|
622
|
+
|
|
623
|
+
render(
|
|
624
|
+
<TestWrapper
|
|
625
|
+
orgLevelApiKey="test-key"
|
|
626
|
+
baseUrl="https://test-api.example.com"
|
|
627
|
+
>
|
|
628
|
+
<MockGraphQLComponent />
|
|
629
|
+
</TestWrapper>
|
|
630
|
+
);
|
|
631
|
+
|
|
632
|
+
await waitFor(() => {
|
|
633
|
+
expect(screen.getByTestId("is-ready")).toHaveTextContent("true");
|
|
634
|
+
});
|
|
635
|
+
|
|
636
|
+
await act(async () => {
|
|
637
|
+
screen.getByTestId("get-config-btn").click();
|
|
638
|
+
});
|
|
639
|
+
|
|
640
|
+
await waitFor(() => {
|
|
641
|
+
const config = (window as any).lastConfig;
|
|
642
|
+
expect(config).toBeDefined();
|
|
643
|
+
expect(config.colorsConfig).toBeUndefined();
|
|
644
|
+
expect(config.frontendConfig).toBeUndefined();
|
|
645
|
+
});
|
|
646
|
+
});
|
|
647
|
+
|
|
648
|
+
it("should handle errors and return undefined configs", async () => {
|
|
649
|
+
const logErrorSpy = vi.spyOn(Logger, "logError");
|
|
650
|
+
|
|
651
|
+
(global.fetch as any).mockRejectedValueOnce(new Error("Network error"));
|
|
652
|
+
|
|
653
|
+
render(
|
|
654
|
+
<TestWrapper
|
|
655
|
+
orgLevelApiKey="test-key"
|
|
656
|
+
baseUrl="https://test-api.example.com"
|
|
657
|
+
>
|
|
658
|
+
<MockGraphQLComponent />
|
|
659
|
+
</TestWrapper>
|
|
660
|
+
);
|
|
661
|
+
|
|
662
|
+
await waitFor(() => {
|
|
663
|
+
expect(screen.getByTestId("is-ready")).toHaveTextContent("true");
|
|
664
|
+
});
|
|
665
|
+
|
|
666
|
+
await act(async () => {
|
|
667
|
+
screen.getByTestId("get-config-btn").click();
|
|
668
|
+
});
|
|
669
|
+
|
|
670
|
+
await waitFor(() => {
|
|
671
|
+
const config = (window as any).lastConfig;
|
|
672
|
+
expect(config).toBeDefined();
|
|
673
|
+
expect(config.colorsConfig).toBeUndefined();
|
|
674
|
+
expect(config.frontendConfig).toBeUndefined();
|
|
675
|
+
expect(logErrorSpy).toHaveBeenCalledWith(
|
|
676
|
+
"Error fetching graphql colors and frontend config",
|
|
677
|
+
expect.any(Error)
|
|
678
|
+
);
|
|
679
|
+
});
|
|
680
|
+
});
|
|
681
|
+
|
|
682
|
+
it("should transform snake_case to camelCase", async () => {
|
|
683
|
+
const mockColorsConfig = {
|
|
684
|
+
accent_primary: "#FF0000",
|
|
685
|
+
accent_secondary: "#00FF00",
|
|
686
|
+
};
|
|
687
|
+
const mockFrontendConfig = {
|
|
688
|
+
merchant_override_css: "test-css",
|
|
689
|
+
page_variants: [],
|
|
690
|
+
};
|
|
691
|
+
|
|
692
|
+
const mockResponse = {
|
|
693
|
+
data: {
|
|
694
|
+
me: {
|
|
695
|
+
getProductsConfigByVersion: {
|
|
696
|
+
colors: {
|
|
697
|
+
values: mockColorsConfig,
|
|
698
|
+
},
|
|
699
|
+
frontend: {
|
|
700
|
+
values: mockFrontendConfig,
|
|
701
|
+
},
|
|
702
|
+
},
|
|
703
|
+
},
|
|
704
|
+
},
|
|
705
|
+
};
|
|
706
|
+
|
|
707
|
+
(global.fetch as any).mockResolvedValueOnce({
|
|
708
|
+
ok: true,
|
|
709
|
+
json: async () => mockResponse,
|
|
710
|
+
});
|
|
711
|
+
|
|
712
|
+
const TestComponent: React.FC = () => {
|
|
713
|
+
const client = useGraphQLClient();
|
|
714
|
+
const [config, setConfig] = React.useState<any>(null);
|
|
715
|
+
|
|
716
|
+
React.useEffect(() => {
|
|
717
|
+
if (client.isReady) {
|
|
718
|
+
client.getColorsAndFrontendConfig().then(setConfig);
|
|
719
|
+
}
|
|
720
|
+
}, [client]);
|
|
721
|
+
|
|
722
|
+
return (
|
|
723
|
+
<div>
|
|
724
|
+
{config && (
|
|
725
|
+
<div data-testid="config-display">
|
|
726
|
+
<div data-testid="has-colors">
|
|
727
|
+
{config.colorsConfig ? "yes" : "no"}
|
|
728
|
+
</div>
|
|
729
|
+
<div data-testid="has-frontend">
|
|
730
|
+
{config.frontendConfig ? "yes" : "no"}
|
|
731
|
+
</div>
|
|
732
|
+
</div>
|
|
733
|
+
)}
|
|
734
|
+
</div>
|
|
735
|
+
);
|
|
736
|
+
};
|
|
737
|
+
|
|
738
|
+
render(
|
|
739
|
+
<TestWrapper
|
|
740
|
+
orgLevelApiKey="test-key"
|
|
741
|
+
baseUrl="https://test-api.example.com"
|
|
742
|
+
>
|
|
743
|
+
<TestComponent />
|
|
744
|
+
</TestWrapper>
|
|
745
|
+
);
|
|
746
|
+
|
|
747
|
+
await waitFor(() => {
|
|
748
|
+
expect(screen.getByTestId("has-colors")).toHaveTextContent("yes");
|
|
749
|
+
expect(screen.getByTestId("has-frontend")).toHaveTextContent("yes");
|
|
750
|
+
});
|
|
751
|
+
});
|
|
752
|
+
});
|
|
753
|
+
|
|
754
|
+
describe("Context Value Memoization", () => {
|
|
755
|
+
it("should maintain stable context value references", async () => {
|
|
756
|
+
let contextValue1: any;
|
|
757
|
+
let contextValue2: any;
|
|
758
|
+
|
|
759
|
+
const Component1: React.FC = () => {
|
|
760
|
+
const context = useGraphQLClient();
|
|
761
|
+
contextValue1 = context;
|
|
762
|
+
return <div>Component1</div>;
|
|
763
|
+
};
|
|
764
|
+
|
|
765
|
+
const Component2: React.FC = () => {
|
|
766
|
+
const context = useGraphQLClient();
|
|
767
|
+
contextValue2 = context;
|
|
768
|
+
return <div>Component2</div>;
|
|
769
|
+
};
|
|
770
|
+
|
|
771
|
+
render(
|
|
772
|
+
<TestWrapper
|
|
773
|
+
orgLevelApiKey="test-key"
|
|
774
|
+
baseUrl="https://test-api.example.com"
|
|
775
|
+
>
|
|
776
|
+
<Component1 />
|
|
777
|
+
<Component2 />
|
|
778
|
+
</TestWrapper>
|
|
779
|
+
);
|
|
780
|
+
|
|
781
|
+
await waitFor(() => {
|
|
782
|
+
expect(contextValue1).toBeDefined();
|
|
783
|
+
expect(contextValue2).toBeDefined();
|
|
784
|
+
// Both components should receive the same context instance
|
|
785
|
+
expect(contextValue1).toBe(contextValue2);
|
|
786
|
+
});
|
|
787
|
+
});
|
|
788
|
+
});
|
|
789
|
+
});
|
|
790
|
+
|