@faststore/core 4.9.1 → 4.9.3-dev.0

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.
@@ -1,9 +1,9 @@
1
1
 
2
- > @faststore/core@4.9.0 generate /home/runner/work/faststore/faststore/packages/core
2
+ > @faststore/core@4.9.2 generate /home/runner/work/faststore/faststore/packages/core
3
3
  > pnpm run gen-types && pnpm run cache-graphql
4
4
 
5
5
 
6
- > @faststore/core@4.9.0 gen-types /home/runner/work/faststore/faststore/packages/core
6
+ > @faststore/core@4.9.2 gen-types /home/runner/work/faststore/faststore/packages/core
7
7
  > node ../cli/bin/run generate-types .
8
8
 
9
9
  [STARTED] Parse Configuration
@@ -19,7 +19,7 @@
19
19
  [COMPLETED] Generate to @generated/
20
20
  [COMPLETED] Generate outputs
21
21
 
22
- > @faststore/core@4.9.0 cache-graphql /home/runner/work/faststore/faststore/packages/core
22
+ > @faststore/core@4.9.2 cache-graphql /home/runner/work/faststore/faststore/packages/core
23
23
  > node ../cli/bin/run cache-graphql --config=./discovery.config.default.js --queries=./@generated/persisted-documents.json
24
24
 
25
25
  [Info] - Config file location: /home/runner/work/faststore/faststore/packages/core/discovery.config.default.js
@@ -1,5 +1,5 @@
1
1
 
2
- > @faststore/core@4.9.0 test /home/runner/work/faststore/faststore/packages/core
2
+ > @faststore/core@4.9.2 test /home/runner/work/faststore/faststore/packages/core
3
3
  > vitest run
4
4
 
5
5
 
@@ -7,25 +7,23 @@
7
7
 
8
8
  Not implemented: navigation to another Document
9
9
  Not implemented: navigation to another Document
10
- ✓  browser  test/sdk/ui/useScrollRestoration.browser.test.ts (43 tests) 991ms
10
+ ✓  browser  test/sdk/ui/useScrollRestoration.browser.test.ts (43 tests) 1025ms
11
11
  Browserslist: browsers data (caniuse-lite) is 8 months old. Please run:
12
12
  npx update-browserslist-db@latest
13
13
  Why you should do it regularly: https://github.com/browserslist/update-db#readme
14
- ✓  browser  test/components/account/ContractSwitcher.browser.test.tsx (22 tests) 2974ms
15
- ✓ shows an error state when the list fails to load  681ms
16
- ✓ requires selecting a contract before Confirm is enabled, then switches (REQ-03)  370ms
17
- ✓ keeps Confirm disabled until a different contract is selected  346ms
18
- ✓  browser  test/components/account/cards/MyAccountListCards.browser.test.tsx (16 tests) 2099ms
19
- ✓ shows the tab bar and renders Personal cards by default  966ms
20
- ✓  browser  test/components/account/orders/BuyingPolicyAlert.browser.test.tsx (13 tests) 1905ms
21
- ✓ opens the reject confirmation modal with the default English copy  705ms
22
- ✓ opens the reject confirmation modal with CMS-provided labels  341ms
23
- ✓  browser  test/components/CartRecommendationShelf/CartRecommendationShelf.browser.test.tsx (13 tests) 221ms
24
- ✓  browser  test/sdk/localization/useBindingSelector.browser.test.tsx (9 tests) 139ms
25
- ✓  browser  test/components/account/OrganizationDrawer.browser.test.tsx (10 tests) 1489ms
26
- ✓ renders the menu view with contract details and manage footer  815ms
27
- ✓  browser  test/components/ui/ProductGallery/GalleryPageHeightLock.browser.test.tsx (8 tests) 90ms
28
- ✓  browser  test/sdk/session/reconcileSessionLocale.browser.test.ts (5 tests) 13ms
14
+ ✓  browser  test/components/account/cards/MyAccountListCards.browser.test.tsx (16 tests) 2299ms
15
+ ✓ shows the tab bar and renders Personal cards by default  888ms
16
+ ✓ paginates when there are more than 25 cards  355ms
17
+ ✓  browser  test/components/account/ContractSwitcher.browser.test.tsx (22 tests) 2772ms
18
+ ✓ shows an error state when the list fails to load  455ms
19
+ ✓  browser  test/components/account/orders/BuyingPolicyAlert.browser.test.tsx (13 tests) 2283ms
20
+ ✓ opens the reject confirmation modal with the default English copy  1093ms
21
+ ✓  browser  test/components/account/OrganizationDrawer.browser.test.tsx (10 tests) 1261ms
22
+ ✓ renders the menu view with contract details and manage footer  697ms
23
+ ✓  browser  test/components/CartRecommendationShelf/CartRecommendationShelf.browser.test.tsx (13 tests) 286ms
24
+ ✓  browser  test/sdk/localization/useBindingSelector.browser.test.tsx (9 tests) 126ms
25
+ ✓  browser  test/components/ui/ProductGallery/GalleryPageHeightLock.browser.test.tsx (8 tests) 107ms
26
+ ✓  browser  test/sdk/session/reconcileSessionLocale.browser.test.ts (5 tests) 17ms
29
27
  stderr | test/components/RecommendationShelf/RecommendationShelf.browser.test.tsx
30
28
  Error in optimistic validation: TypeError: Failed to parse URL from /api/graphql?operationName=ValidateCartMutation&operationHash=3c71b0d3fc2bade14df68abfa271858beb361b12
31
29
   at node:internal/deps/undici/undici:16416:13
@@ -33,7 +31,7 @@ Browserslist: browsers data (caniuse-lite) is 8 months old. Please run:
33
31
  at baseRequest (/home/runner/work/faststore/faststore/packages/core/src/sdk/graphql/request.ts:42:20)
34
32
  at GraphqlRequest (/home/runner/work/faststore/faststore/packages/core/src/sdk/graphql/request.ts:130:20)
35
33
  at request (/home/runner/work/faststore/faststore/packages/core/src/sdk/graphql/request.ts:154:5)
36
- at validateCart (/home/runner/work/faststore/faststore/packages/core/src/sdk/cart/index.ts:122:46)
34
+ at validateCart (/home/runner/work/faststore/faststore/packages/core/src/sdk/cart/index.ts:126:46)
37
35
  at onValidate (/home/runner/work/faststore/faststore/packages/core/src/sdk/useStore.ts:18:14)
38
36
  at a (/home/runner/work/faststore/faststore/packages/sdk/dist/es/index.mjs:357:17) {
39
37
  [cause]: TypeError: Invalid URL
@@ -52,13 +50,15 @@ Browserslist: browsers data (caniuse-lite) is 8 months old. Please run:
52
50
  }
53
51
  }
54
52
 
55
- ✓  browser  test/sdk/recommendations/useRecommendationShelf.browser.test.tsx (12 tests) 50ms
56
53
  stderr | test/components/RecommendationShelf/RecommendationShelf.browser.test.tsx > RecommendationShelf > renders nothing when there is an error
57
54
  Error fetching recommendations undefined boom for campaign vrn:recommendations:acc:rec-top-items-v2:campaign-1
58
55
 
59
- ✓  browser  test/components/RecommendationShelf/RecommendationShelf.browser.test.tsx (8 tests) 139ms
60
- ✓  browser  test/components/CartSidebar/CartSidebar.browser.test.tsx (5 tests) 51ms
61
- ✓  browser  test/components/sections/Account/AccountOrderDetails.browser.test.tsx (4 tests) 92ms
56
+ ✓  browser  test/components/RecommendationShelf/RecommendationShelf.browser.test.tsx (8 tests) 95ms
57
+ ✓  browser  test/sdk/recommendations/useRecommendationShelf.browser.test.tsx (12 tests) 42ms
58
+ ✓  browser  test/components/CartSidebar/CartSidebar.browser.test.tsx (5 tests) 56ms
59
+ ✓  browser  test/components/sections/Account/AccountOrderDetails.browser.test.tsx (4 tests) 113ms
60
+ ✓  browser  test/components/navigation/Navbar.browser.test.tsx (3 tests) 51ms
61
+ ✓  browser  test/sdk/session/getInitialSession.browser.test.ts (6 tests) 7ms
62
62
  stderr | test/pages/password-protection.browser.test.tsx > PasswordProtectionLogin > posts the password and redirects to the requested return path
63
63
  Warning: An update to PasswordProtectionLogin inside a test was not wrapped in act(...).
64
64
 
@@ -96,7 +96,6 @@ act(() => {
96
96
  This ensures that you're testing the behavior the user would see in the browser. Learn more at https://reactjs.org/link/wrap-tests-with-act
97
97
  at PasswordProtectionLogin (/home/runner/work/faststore/faststore/packages/core/src/pages/password-protection/index.tsx:19:69)
98
98
 
99
- ✓  browser  test/components/navigation/Navbar.browser.test.tsx (3 tests) 44ms
100
99
  stderr | test/pages/password-protection.browser.test.tsx > PasswordProtectionLogin > defaults returnTo to root and shows API validation errors
101
100
  Warning: An update to PasswordProtectionLogin inside a test was not wrapped in act(...).
102
101
 
@@ -289,92 +288,108 @@ act(() => {
289
288
  This ensures that you're testing the behavior the user would see in the browser. Learn more at https://reactjs.org/link/wrap-tests-with-act
290
289
  at PasswordProtectionLogin (/home/runner/work/faststore/faststore/packages/core/src/pages/password-protection/index.tsx:19:69)
291
290
 
292
- ✓  browser  test/pages/password-protection.browser.test.tsx (6 tests) 740ms
293
- ✓ renders the password protection form  431ms
294
- ✓  browser  test/sdk/session/getInitialSession.browser.test.ts (6 tests) 7ms
295
- ✓  browser  test/sdk/account/useSwitchContract.browser.test.ts (5 tests) 37ms
296
- ✓  browser  test/components/account/OrganizationDrawerFooter.browser.test.tsx (8 tests) 319ms
291
+ ✓  browser  test/pages/password-protection.browser.test.tsx (6 tests) 632ms
297
292
  stderr | test/components/cms/RenderSections.browser.test.tsx
298
293
  Error in optimistic validation: TypeError: Cannot read properties of undefined (reading 'read')
299
294
  at waitForSessionValidated (/home/runner/work/faststore/faststore/packages/core/src/sdk/cart/waitForSessionValidated.ts:16:32)
300
- at validateCart (/home/runner/work/faststore/faststore/packages/core/src/sdk/cart/index.ts:120:9)
295
+ at validateCart (/home/runner/work/faststore/faststore/packages/core/src/sdk/cart/index.ts:124:9)
301
296
  at onValidate (/home/runner/work/faststore/faststore/packages/core/src/sdk/useStore.ts:18:20)
302
297
  at a (/home/runner/work/faststore/faststore/packages/sdk/dist/es/index.mjs:357:23)
303
298
   at processTicksAndRejections (node:internal/process/task_queues:103:5)
304
299
 
305
- ✓  browser  test/components/cms/RenderSections.browser.test.tsx (5 tests) 63ms
306
- ✓  browser  test/components/navigation/NavbarSlider.browser.test.tsx (2 tests) 31ms
307
- ✓  browser  test/components/account/Menu.browser.test.tsx (6 tests) 234ms
300
+ ✓  browser  test/components/account/OrganizationDrawerFooter.browser.test.tsx (8 tests) 298ms
301
+ ✓  browser  test/sdk/account/useSwitchContract.browser.test.ts (5 tests) 31ms
302
+ ✓  browser  test/components/cms/RenderSections.browser.test.tsx (5 tests) 62ms
303
+ ✓  browser  test/components/navigation/NavbarSlider.browser.test.tsx (2 tests) 37ms
308
304
  stderr | test/sdk/localization/store-url.browser.test.ts
309
305
  Error in optimistic validation: TypeError: Cannot read properties of undefined (reading 'read')
310
306
  at waitForSessionValidated (/home/runner/work/faststore/faststore/packages/core/src/sdk/cart/waitForSessionValidated.ts:16:32)
311
- at validateCart (/home/runner/work/faststore/faststore/packages/core/src/sdk/cart/index.ts:120:9)
307
+ at validateCart (/home/runner/work/faststore/faststore/packages/core/src/sdk/cart/index.ts:124:9)
312
308
  at onValidate (/home/runner/work/faststore/faststore/packages/core/src/sdk/useStore.ts:18:20)
313
309
  at a (/home/runner/work/faststore/faststore/packages/sdk/dist/es/index.mjs:357:23)
314
310
   at processTicksAndRejections (node:internal/process/task_queues:103:5)
315
311
 
312
+ ✓  browser  test/components/account/Menu.browser.test.tsx (6 tests) 279ms
316
313
  ✓  browser  test/sdk/localization/store-url.browser.test.ts (3 tests) 4ms
317
- ✓  browser  test/sdk/account/useAvailableContracts.browser.test.ts (6 tests) 30ms
318
- ✓  browser  test/components/templates/SearchPage/SearchWrapper.browser.test.tsx (3 tests) 34ms
319
- ✓  browser  test/sdk/recommendations/useRecommendationShelf.sessionFallback.browser.test.tsx (2 tests) 125ms
320
- ✓  browser  test/components/sections/Account/AccountListQuotes.browser.test.tsx (4 tests) 101ms
321
- ✓  browser  test/components/navigation/NavbarAccountArea.browser.test.tsx (4 tests) 57ms
322
- ✓  browser  test/components/CartRecommendationShelf/CartRecommendationProductCard.browser.test.tsx (3 tests) 35ms
323
- ✓  browser  test/sdk/account/changeContractToken.browser.test.ts (9 tests) 15ms
314
+ ✓  browser  test/sdk/account/useAvailableContracts.browser.test.ts (6 tests) 27ms
315
+ ✓  browser  test/components/templates/SearchPage/SearchWrapper.browser.test.tsx (3 tests) 30ms
316
+ ✓  browser  test/sdk/recommendations/useRecommendationShelf.sessionFallback.browser.test.tsx (2 tests) 124ms
317
+ ✓  browser  test/components/sections/Account/AccountListQuotes.browser.test.tsx (4 tests) 95ms
318
+ ✓  browser  test/components/navigation/NavbarAccountArea.browser.test.tsx (4 tests) 47ms
319
+ ✓  browser  test/components/CartRecommendationShelf/CartRecommendationProductCard.browser.test.tsx (3 tests) 47ms
320
+ ✓  browser  test/sdk/account/changeContractToken.browser.test.ts (9 tests) 18ms
324
321
  stderr | test/components/account/doLogout.browser.test.ts
325
322
  Error in optimistic validation: TypeError: Cannot read properties of undefined (reading 'read')
326
323
  at waitForSessionValidated (/home/runner/work/faststore/faststore/packages/core/src/sdk/cart/waitForSessionValidated.ts:16:32)
327
- at validateCart (/home/runner/work/faststore/faststore/packages/core/src/sdk/cart/index.ts:120:9)
324
+ at validateCart (/home/runner/work/faststore/faststore/packages/core/src/sdk/cart/index.ts:124:9)
328
325
  at onValidate (/home/runner/work/faststore/faststore/packages/core/src/sdk/useStore.ts:18:20)
329
326
  at a (/home/runner/work/faststore/faststore/packages/sdk/dist/es/index.mjs:357:23)
330
327
   at processTicksAndRejections (node:internal/process/task_queues:103:5)
331
328
 
332
- ✓  browser  test/components/account/doLogout.browser.test.ts (1 test) 20ms
333
- ✓  browser  test/components/account/OrganizationDrawerHeader.browser.test.tsx (5 tests) 272ms
329
+ ✓  browser  test/components/account/doLogout.browser.test.ts (1 test) 25ms
330
+ ✓  browser  test/components/account/OrganizationDrawerHeader.browser.test.tsx (5 tests) 265ms
334
331
  ✓  browser  test/components/ui/LocalizationButton.browser.test.tsx (3 tests) 37ms
335
332
  stderr | test/sdk/account/clearPersistedSessionState.browser.test.ts
336
333
  Error in optimistic validation: TypeError: Cannot read properties of undefined (reading 'read')
337
334
  at waitForSessionValidated (/home/runner/work/faststore/faststore/packages/core/src/sdk/cart/waitForSessionValidated.ts:16:32)
338
- at validateCart (/home/runner/work/faststore/faststore/packages/core/src/sdk/cart/index.ts:120:9)
335
+ at validateCart (/home/runner/work/faststore/faststore/packages/core/src/sdk/cart/index.ts:124:9)
339
336
  at onValidate (/home/runner/work/faststore/faststore/packages/core/src/sdk/useStore.ts:18:20)
340
337
  at a (/home/runner/work/faststore/faststore/packages/sdk/dist/es/index.mjs:357:23)
341
338
   at processTicksAndRejections (node:internal/process/task_queues:103:5)
342
339
 
343
340
  ✓  browser  test/sdk/account/clearPersistedSessionState.browser.test.ts (4 tests) 14ms
344
- ✓  browser  test/components/sections/Account/AccountOrderDelivery.browser.test.tsx (2 tests) 61ms
345
- ✓  browser  test/components/account/orders/DeliveryOptionAccordion.browser.test.tsx (2 tests) 74ms
346
- ✓  browser  test/components/sections/Account/AccountOrderStatus.browser.test.tsx (3 tests) 90ms
347
- ✓  browser  test/components/sections/Account/AccountOrdersList.browser.test.tsx (2 tests) 37ms
348
- ✓  browser  test/components/sections/Account/AccountListCards.browser.test.tsx (3 tests) 71ms
349
- ✓  browser  test/components/account/orders/SummaryCard.browser.test.tsx (2 tests) 65ms
341
+ ✓  browser  test/components/sections/Account/AccountOrderDelivery.browser.test.tsx (2 tests) 71ms
342
+ ✓  browser  test/components/account/orders/DeliveryOptionAccordion.browser.test.tsx (2 tests) 80ms
343
+ ✓  browser  test/components/sections/Account/AccountOrderStatus.browser.test.tsx (3 tests) 77ms
344
+ ✓  browser  test/components/sections/Account/AccountListCards.browser.test.tsx (3 tests) 67ms
345
+ ✓  browser  test/components/region/useRegion.browser.test.ts (1 test) 20ms
346
+ ✓  browser  test/components/sections/Account/AccountOrdersList.browser.test.tsx (2 tests) 22ms
347
+ ✓  browser  test/components/account/orders/SummaryCard.browser.test.tsx (2 tests) 77ms
348
+ stderr | test/sdk/session/sessionStore.browser.test.ts
349
+ Error in optimistic validation: TypeError: Cannot read properties of undefined (reading 'read')
350
+ at waitForSessionValidated (/home/runner/work/faststore/faststore/packages/core/src/sdk/cart/waitForSessionValidated.ts:16:32)
351
+ at validateCart (/home/runner/work/faststore/faststore/packages/core/src/sdk/cart/index.ts:124:9)
352
+ at onValidate (/home/runner/work/faststore/faststore/packages/core/src/sdk/useStore.ts:18:20)
353
+ at a (/home/runner/work/faststore/faststore/packages/sdk/dist/es/index.mjs:357:23)
354
+  at processTicksAndRejections (node:internal/process/task_queues:103:5)
355
+
356
+ ✓  browser  test/sdk/session/sessionStore.browser.test.ts (2 tests) 9ms
357
+ ✓  browser  test/components/account/OrganizationSignInButton.browser.test.tsx (2 tests) 186ms
350
358
  ✓  browser  test/components/account/orders/DeliveryOptionAccordionDeliveryInfo.browser.test.tsx (1 test) 26ms
351
- ✓  browser  test/components/account/OrganizationSignInButton.browser.test.tsx (2 tests) 182ms
352
- ✓  browser  test/components/account/orders/StatusCard.browser.test.tsx (2 tests) 86ms
353
- ✓  browser  test/utils/isLocalHost.browser.test.ts (3 tests) 4ms
359
+ stderr | test/sdk/session/validateSession.browser.test.ts
360
+ Error in optimistic validation: TypeError: Cannot read properties of undefined (reading 'read')
361
+ at waitForSessionValidated (/home/runner/work/faststore/faststore/packages/core/src/sdk/cart/waitForSessionValidated.ts:16:32)
362
+ at validateCart (/home/runner/work/faststore/faststore/packages/core/src/sdk/cart/index.ts:124:9)
363
+ at onValidate (/home/runner/work/faststore/faststore/packages/core/src/sdk/useStore.ts:18:20)
364
+ at a (/home/runner/work/faststore/faststore/packages/sdk/dist/es/index.mjs:357:23)
365
+  at processTicksAndRejections (node:internal/process/task_queues:103:5)
366
+
367
+ ✓  browser  test/sdk/session/validateSession.browser.test.ts (1 test) 4ms
368
+ ✓  browser  test/components/account/orders/StatusCard.browser.test.tsx (2 tests) 88ms
369
+ ✓  browser  test/utils/isLocalHost.browser.test.ts (3 tests) 3ms
354
370
  ✓  browser  test/sdk/session/reconcileSessionLocale.disabled.browser.test.ts (1 test) 3ms
355
- ✓  browser  test/components/account/orders/DeliveryCard.browser.test.tsx (1 test) 39ms
371
+ ✓  browser  test/components/account/orders/DeliveryCard.browser.test.tsx (1 test) 36ms
356
372
  ✓  browser  test/components/account/orders/DeliveryOptionAccordionProducts.browser.test.tsx (1 test) 37ms
357
- ✓  browser  test/components/skeletons/ProductGridSkeleton.browser.test.tsx (2 tests) 22ms
373
+ ✓  browser  test/components/skeletons/ProductGridSkeleton.browser.test.tsx (2 tests) 30ms
374
+ ✓  node  test/utils/localization/bindingPaths.test.ts (71 tests) 19ms
358
375
  stderr | test/sdk/account/refreshToken.browser.test.ts
359
376
  Error in optimistic validation: TypeError: Cannot read properties of undefined (reading 'read')
360
377
  at waitForSessionValidated (/home/runner/work/faststore/faststore/packages/core/src/sdk/cart/waitForSessionValidated.ts:16:32)
361
- at validateCart (/home/runner/work/faststore/faststore/packages/core/src/sdk/cart/index.ts:120:9)
378
+ at validateCart (/home/runner/work/faststore/faststore/packages/core/src/sdk/cart/index.ts:124:9)
362
379
  at onValidate (/home/runner/work/faststore/faststore/packages/core/src/sdk/useStore.ts:18:20)
363
380
  at a (/home/runner/work/faststore/faststore/packages/sdk/dist/es/index.mjs:357:23)
364
381
   at processTicksAndRejections (node:internal/process/task_queues:103:5)
365
382
 
366
383
  ✓  browser  test/sdk/account/refreshToken.browser.test.ts (1 test) 4ms
367
- ✓  node  test/utils/localization/bindingPaths.test.ts (71 tests) 19ms
368
- ✓  node  test/pages/api/switch-contract.test.ts (25 tests) 67ms
369
- ✓  node  test/server/password-protection-service.test.ts (22 tests) 26ms
370
- ✓  node  test/utils/match-url.test.ts (10 tests) 8ms
371
- ✓  browser  test/components/account/orders/FilterFacetPendingApproval.browser.test.tsx (1 test) 167ms
372
- ✓  node  test/sdk/localization/useBindingSelector.test.tsx (22 tests) 11ms
373
- ✓  node  test/pages/api/unlock.test.ts (15 tests) 136ms
384
+ ✓  node  test/server/password-protection-service.test.ts (22 tests) 27ms
385
+ ✓  node  test/pages/api/switch-contract.test.ts (25 tests) 71ms
386
+ ✓  browser  test/components/account/orders/FilterFacetPendingApproval.browser.test.tsx (1 test) 156ms
387
+ ✓  node  test/utils/match-url.test.ts (10 tests) 5ms
388
+ ✓  node  test/sdk/localization/useBindingSelector.test.tsx (22 tests) 12ms
389
+ ✓  node  test/pages/api/unlock.test.ts (15 tests) 124ms
374
390
  stderr | test/components/search/SearchInputComponent.test.tsx
375
391
  Warning: forwardRef render functions accept exactly two parameters: props and ref. Did you forget to use the ref parameter?
376
392
 
377
- ✓  node  test/sdk/localization/bindingSelector.test.ts (18 tests) 8ms
378
393
  stderr | test/components/search/SearchInputComponent.test.tsx > SearchInput (OES integration) > renders without crashing
379
394
  Warning: React does not recognize the `visibleDropdown` prop on a DOM element. If you intentionally want it to appear in the DOM as a custom attribute, spell it as lowercase `visibledropdown` instead. If you accidentally passed it from a parent component, remove it from the DOM element.
380
395
  at div
@@ -435,22 +450,24 @@ Warning: React does not recognize the `providerProps` prop on a DOM element. If
435
450
  at Suspense
436
451
  at Wrapper (/home/runner/work/faststore/faststore/packages/core/test/components/search/SearchInputComponent.test.tsx:106:20)
437
452
 
453
+ ✓  node  test/sdk/localization/bindingSelector.test.ts (18 tests) 8ms
438
454
  ✓  node  test/components/search/SearchInputComponent.test.tsx (6 tests) 63ms
439
- ✓  node  test/components/quotes/MyAccountListQuotesTable.test.tsx (15 tests) 350ms
455
+ ✓  node  test/components/quotes/MyAccountListQuotesTable.test.tsx (15 tests) 319ms
456
+ ✓  node  test/sdk/search/useSearchHistory.test.ts (13 tests) 32ms
440
457
  stderr | test/pages/pvt/account/cards/index.test.ts > Cards page getServerSideProps > redirects to /pvt/account/403 when the query fails with 401/403
441
458
  { extensions: { status: 401 } }
442
459
 
443
460
  stderr | test/pages/pvt/account/cards/index.test.ts > Cards page getServerSideProps > renders the error state (no redirect) when the query fails with a non-auth status
444
461
  { extensions: { status: 502 } }
445
462
 
446
- ✓  node  test/pages/pvt/account/cards/index.test.ts (8 tests) 6ms
447
- ✓  node  test/sdk/search/useSearchHistory.test.ts (13 tests) 28ms
448
- ✓  node  test/components/quotes/MyAccountListQuotes.test.tsx (11 tests) 798ms
449
- ✓ navigates with the search term on blur  360ms
463
+ ✓  node  test/pages/pvt/account/cards/index.test.ts (8 tests) 8ms
464
+ ✓  node  test/components/quotes/MyAccountListQuotes.test.tsx (11 tests) 800ms
465
+ ✓ navigates with the search term on blur  358ms
450
466
  ✓ navigates without a label param when the search is cleared  356ms
451
- ✓  node  test/components/quotes/quoteFilters.test.ts (26 tests) 31ms
467
+ ✓  node  test/components/quotes/quoteFilters.test.ts (26 tests) 28ms
468
+ ✓  node  test/utils/cookieCacheBusting.test.ts (10 tests) 11ms
452
469
  ✓  node  test/utils/productJsonLd.test.ts (36 tests) 11ms
453
- ✓  node  test/utils/cookieCacheBusting.test.ts (10 tests) 12ms
470
+ ✓  node  test/experimental/myAccountCmsServerSideProps.test.ts (5 tests) 8ms
454
471
  stderr | test/pages/api/graphql.test.ts > /api/graphql error status propagation > propagates the upstream 400 from a wrapped BadRequestError instead of 500
455
472
  Graphql execution returned with error: [
456
473
  {
@@ -561,71 +578,70 @@ Warning: React does not recognize the `providerProps` prop on a DOM element. If
561
578
  at runTest (file:///home/runner/work/faststore/faststore/node_modules/.pnpm/@vitest+runner@4.0.18/node_modules/@vitest/runner/dist/index.js:1653:12)
562
579
 
563
580
  ✓  node  test/pages/api/graphql.test.ts (19 tests) 28ms
564
- ✓  node  test/experimental/myAccountCmsServerSideProps.test.ts (5 tests) 8ms
565
581
  ✓  node  test/utils/clearCookies.test.ts (20 tests) 20ms
566
- ✓  node  test/utils/multipleTemplates.test.ts (8 tests) 5ms
582
+ ✓  node  test/utils/multipleTemplates.test.ts (8 tests) 6ms
567
583
  stderr | test/sdk/account/useSetPassword.test.ts > useSetPassword > maps wrongcredentials error responses to the existing message
568
584
  Set password request failed: Bad Request
569
585
 
570
- ✓  node  test/sdk/account/useSetPassword.test.ts (6 tests) 33ms
571
- ✓  node  test/sdk/orderEntry/useOrderEntryOperation.test.ts (8 tests) 26ms
586
+ ✓  node  test/sdk/account/useSetPassword.test.ts (6 tests) 38ms
587
+ ✓  node  test/sdk/orderEntry/useOrderEntryOperation.test.ts (8 tests) 30ms
572
588
  ✓  node  test/utils/localization/localizeRedirectDestination.test.ts (11 tests) 5ms
573
- ✓  node  test/components/quotes/MyAccountQuotesFilterSlider.test.tsx (8 tests) 137ms
574
- ✓  node  test/components/quotes/MyAccountQuotesStatusSelector.test.tsx (14 tests) 130ms
575
- ✓  node  test/utils/localization/hreflang.test.ts (8 tests) 5ms
576
- ✓  node  test/sdk/account/getMyAccountRoutes.test.ts (13 tests) 8ms
577
- ✓  node  test/components/quotes/MyAccountQuotesSelectedTags.test.tsx (10 tests) 94ms
578
- ✓  node  test/sdk/redirects/index.test.ts (7 tests) 50ms
579
- ✓  node  test/sdk/orderEntry/useOrderEntryUpload.test.ts (8 tests) 39ms
580
- ✓  node  test/proxy.localization.test.ts (5 tests) 34ms
581
- ✓  node  test/sdk/orderEntry/useOrderEntry.test.ts (8 tests) 34ms
582
- ✓  node  test/components/account/orders/getDeliveryOptionLabel.test.ts (21 tests) 6ms
583
- ✓  node  test/sdk/graphql/retryPolicy.test.ts (18 tests) 15ms
584
- ✓  node  test/server/cms/myAccountDefaultSections.test.ts (9 tests) 8ms
585
- ✓  node  test/utils/productJsonLdRendering.test.tsx (5 tests) 11ms
586
- ✓  node  test/sdk/session/syncSalesChannelFromOrderForm.test.ts (6 tests) 6ms
587
- ✓  node  test/sdk/analytics/useStartRecommendationSession.test.ts (6 tests) 31ms
588
- ✓  node  test/server/index.test.ts (7 tests) 1039ms
589
- ✓ should handle options and execute  591ms
590
- ✓  node  test/sdk/orderEntry/useOrderFormItems.test.ts (7 tests) 22ms
589
+ ✓  node  test/components/quotes/MyAccountQuotesFilterSlider.test.tsx (8 tests) 159ms
590
+ ✓  node  test/components/quotes/MyAccountQuotesStatusSelector.test.tsx (14 tests) 163ms
591
+ ✓  node  test/utils/localization/hreflang.test.ts (8 tests) 4ms
592
+ ✓  node  test/sdk/account/getMyAccountRoutes.test.ts (13 tests) 7ms
593
+ ✓  node  test/components/quotes/MyAccountQuotesSelectedTags.test.tsx (10 tests) 85ms
594
+ ✓  node  test/sdk/redirects/index.test.ts (7 tests) 37ms
595
+ ✓  node  test/sdk/orderEntry/useOrderEntryUpload.test.ts (8 tests) 36ms
596
+ ✓  node  test/proxy.localization.test.ts (5 tests) 37ms
597
+ ✓  node  test/components/account/orders/getDeliveryOptionLabel.test.ts (21 tests) 7ms
598
+ ✓  node  test/sdk/orderEntry/useOrderEntry.test.ts (8 tests) 40ms
599
+ ✓  node  test/sdk/graphql/retryPolicy.test.ts (18 tests) 22ms
600
+ ✓  node  test/server/cms/myAccountDefaultSections.test.ts (9 tests) 6ms
601
+ ✓  node  test/utils/productJsonLdRendering.test.tsx (5 tests) 13ms
602
+ ✓  node  test/sdk/session/syncSalesChannelFromOrderForm.test.ts (6 tests) 5ms
603
+ ✓  node  test/server/index.test.ts (7 tests) 786ms
604
+ ✓  node  test/proxy.test.ts (4 tests) 13ms
591
605
  ✓  node  test/server/webops-api.test.ts (9 tests) 11ms
592
- ✓  node  test/proxy.test.ts (4 tests) 15ms
593
- ✓  node  test/components/account/orders/StatusCard.test.ts (3 tests) 24ms
594
- ✓  node  test/sdk/localization/store-url.test.ts (4 tests) 3ms
606
+ ✓  node  test/sdk/analytics/useStartRecommendationSession.test.ts (6 tests) 40ms
607
+ ✓  node  test/components/account/orders/StatusCard.test.ts (3 tests) 25ms
608
+ ✓  node  test/sdk/localization/store-url.test.ts (4 tests) 4ms
609
+ ✓  node  test/sdk/orderEntry/useOrderFormItems.test.ts (7 tests) 27ms
595
610
  ✓  node  test/sdk/cart/waitForSessionValidated.test.ts (5 tests) 9ms
596
- ✓  node  test/sdk/account/refreshToken.test.ts (5 tests) 5ms
611
+ ✓  node  test/sdk/account/refreshToken.test.ts (5 tests) 10ms
597
612
  ✓  node  test/server/content/service.test.ts (5 tests) 4ms
598
- ✓  node  test/server/cms/global.test.ts (3 tests) 4ms
599
- ✓  node  test/sdk/auth/useAuth.test.ts (5 tests) 24ms
600
- ✓  node  test/components/account/Layout.test.tsx (6 tests) 55ms
601
- ✓  node  test/utils/getRequestHostname.test.ts (12 tests) 6ms
602
- ✓  node  test/server/rootSpan.test.ts (4 tests) 25ms
613
+ ✓  node  test/server/cms/global.test.ts (3 tests) 3ms
614
+ ✓  node  test/sdk/auth/useAuth.test.ts (5 tests) 33ms
615
+ ✓  node  test/utils/getRequestHostname.test.ts (12 tests) 5ms
616
+ ✓  node  test/components/account/Layout.test.tsx (6 tests) 46ms
617
+ ✓  node  test/server/rootSpan.test.ts (4 tests) 39ms
618
+ ✓  node  test/pages/api/preview.test.ts (2 tests) 7ms
603
619
  ✓  node  test/utils/validateSessionRefreshToken.test.ts (6 tests) 4ms
604
- ✓  node  test/pages/api/preview.test.ts (2 tests) 8ms
605
620
  ✓  node  test/components/search/SearchInput.test.ts (6 tests) 6ms
606
621
  ✓  node  test/sdk/recommendations/vrn.test.ts (5 tests) 3ms
607
622
  ✓  node  test/server/cms/index.test.ts (2 tests) 4ms
608
623
  ✓  node  test/utils/retry.test.ts (5 tests) 12ms
609
- ✓  node  test/sdk/account/getB2BSessionClaims.test.ts (4 tests) 3ms
624
+ ✓  node  test/sdk/account/getB2BSessionClaims.test.ts (4 tests) 5ms
610
625
  ✓  node  test/utils/userOrderStatus.test.ts (4 tests) 4ms
611
- ✓  node  test/sdk/recommendations/useRecommendationUserId.test.ts (4 tests) 182ms
626
+ ✓  node  test/sdk/recommendations/useRecommendationUserId.test.ts (4 tests) 190ms
627
+ ✓  node  test/components/account/OrganizationDrawerBody.test.tsx (3 tests) 33ms
612
628
  ✓  node  test/utils/unlockResponse.test.ts (11 tests) 5ms
613
- ✓  node  test/components/account/OrganizationDrawerBody.test.tsx (3 tests) 29ms
614
629
  ✓  node  test/sdk/recommendations/useRecommendations.test.ts (2 tests) 4ms
615
- ✓  node  test/components/quotes/MyAccountQuoteStatusBadge.test.tsx (4 tests) 36ms
616
- ✓  node  test/utils/isLocalHost.test.ts (7 tests) 4ms
617
- ✓  node  test/components/account/orders/listOrdersLabels.test.ts (2 tests) 2ms
618
- ✓  node  test/components/account/orders/getOrderTotalLabel.test.ts (6 tests) 3ms
619
- ✓  node  test/utils/getCookie.test.ts (4 tests) 5ms
630
+ ✓  node  test/utils/isLocalHost.test.ts (7 tests) 3ms
631
+ ✓  node  test/components/quotes/MyAccountQuoteStatusBadge.test.tsx (4 tests) 41ms
632
+ ✓  node  test/sdk/session/toSessionInput.test.ts (3 tests) 3ms
633
+ ✓  node  test/components/account/orders/getOrderTotalLabel.test.ts (6 tests) 4ms
634
+ ✓  node  test/components/account/orders/listOrdersLabels.test.ts (2 tests) 3ms
635
+ ✓  node  test/utils/getCookie.test.ts (4 tests) 3ms
620
636
  ✓  node  test/sdk/session/isSignInAreaResolved.test.ts (3 tests) 3ms
621
- ✓  node  test/instrumentation.test.ts (3 tests) 4ms
622
637
  ✓  node  test/sdk/analytics/utils.test.ts (2 tests) 3ms
623
- ✓  node  test/components/auth/ProfileChallenge.test.tsx (3 tests) 31ms
624
- ✓  node  test/components/account/orders/orderDetailsLabels.test.ts (1 test) 4ms
625
- ✓  node  test/sdk/account/clearPersistedSessionState.test.ts (1 test) 9ms
626
-
627
-  Test Files  123 passed (123)
628
-  Tests  985 passed (985)
629
-  Start at  14:08:29
630
-  Duration  46.77s (transform 11.26s, setup 0ms, import 41.54s, tests 17.36s, environment 57.52s)
638
+ ✓  node  test/components/auth/ProfileChallenge.test.tsx (3 tests) 25ms
639
+ ✓  node  test/instrumentation.test.ts (3 tests) 5ms
640
+ ✓  node  test/components/account/orders/orderDetailsLabels.test.ts (1 test) 3ms
641
+ ✓  node  test/sdk/account/clearPersistedSessionState.test.ts (1 test) 8ms
642
+
643
+  Test Files  127 passed (127)
644
+  Tests  992 passed (992)
645
+  Start at  13:35:02
646
+  Duration  48.01s (transform 11.84s, setup 0ms, import 44.44s, tests 17.34s, environment 57.43s)
631
647
 
package/CHANGELOG.md CHANGED
@@ -3,6 +3,16 @@
3
3
  All notable changes to this project will be documented in this file.
4
4
  See [Conventional Commits](https://conventionalcommits.org) for commit guidelines.
5
5
 
6
+ ## [4.9.3-dev.0](https://github.com/vtex/faststore/compare/v4.9.1-dev.0...v4.9.3-dev.0) (2026-10-05)
7
+
8
+ **Note:** Version bump only for package @faststore/core
9
+
10
+ ## [4.9.2](https://github.com/vtex/faststore/compare/v4.9.1...v4.9.2) (2026-10-02)
11
+
12
+ ### Bug Fixes
13
+
14
+ - **core:** keep UI session state out of session and cart mutations ([#3511](https://github.com/vtex/faststore/issues/3511)) ([3c58a21](https://github.com/vtex/faststore/commit/3c58a213d237f8d5f7919ab12f63015fbfe3ef73)), closes [#3479](https://github.com/vtex/faststore/issues/3479) [#3479](https://github.com/vtex/faststore/issues/3479) [#3509](https://github.com/vtex/faststore/issues/3509)
15
+
6
16
  ## [4.9.1](https://github.com/vtex/faststore/compare/v4.9.0...v4.9.1) (2026-10-02)
7
17
 
8
18
  ### Bug Fixes
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@faststore/core",
3
- "version": "4.9.1",
3
+ "version": "4.9.3-dev.0",
4
4
  "license": "MIT",
5
5
  "repository": {
6
6
  "type": "git",
@@ -71,11 +71,11 @@
71
71
  "style-loader": "^3.3.1",
72
72
  "swr": "^2.2.5",
73
73
  "use-sync-external-store": "^1.6.0",
74
- "@faststore/api": "4.9.1",
75
- "@faststore/diagnostics": "4.9.1",
76
- "@faststore/sdk": "4.9.1",
77
- "@faststore/lighthouse": "4.9.1",
78
- "@faststore/ui": "4.9.1"
74
+ "@faststore/api": "4.9.3-dev.0",
75
+ "@faststore/lighthouse": "4.9.3-dev.0",
76
+ "@faststore/diagnostics": "4.9.3-dev.0",
77
+ "@faststore/ui": "4.9.3-dev.0",
78
+ "@faststore/sdk": "4.9.3-dev.0"
79
79
  },
80
80
  "devDependencies": {
81
81
  "@cypress/code-coverage": "^3.12.1",
@@ -65,7 +65,7 @@ function RegionModal(regionModalProps: RegionModalProps) {
65
65
  } = cmsData?.regionalization ?? {}
66
66
 
67
67
  const inputRef = useRef<HTMLInputElement>(null)
68
- const { isValidating, isSessionReady, ...session } = useSession()
68
+ const { isValidating, ...session } = useSession()
69
69
  const { modal: displayModal, closeModal } = useUI()
70
70
 
71
71
  const [input, setInput] = useState<string>('')
@@ -3,7 +3,7 @@ import { useState } from 'react'
3
3
  import type { Session } from '@faststore/sdk'
4
4
  import { deliveryPromise } from 'discovery.config'
5
5
  import { getProductCount } from 'src/sdk/product'
6
- import { sessionStore, validateSession } from 'src/sdk/session'
6
+ import { sessionStore, toSessionInput, validateSession } from 'src/sdk/session'
7
7
 
8
8
  type SetRegionProps = {
9
9
  session: Session
@@ -40,8 +40,9 @@ export default function useRegion(): UseRegionValues {
40
40
  setLoading(true)
41
41
 
42
42
  try {
43
+ // `session` usually comes from `useSession()`, which also carries UI state
43
44
  const newSession = {
44
- ...session,
45
+ ...toSessionInput(session),
45
46
  postalCode,
46
47
  geoCoordinates: null, // Revalidate geo coordinates in API when users set a new postal code
47
48
  } as Session
@@ -78,7 +78,7 @@ function RegionPopover(regionPopoverProps: RegionPopoverProps) {
78
78
  } = cmsData?.regionalization ?? {}
79
79
 
80
80
  const inputRef = useRef<HTMLInputElement>(null)
81
- const { isValidating, isSessionReady, ...session } = useSession()
81
+ const { isValidating, ...session } = useSession()
82
82
  const { popover: displayPopover, closePopover } = useUI()
83
83
  const { onPostalCodeChange } = useDeliveryPromise()
84
84
  const { city, postalCode } = sessionStore.read()
@@ -45,7 +45,7 @@ function RegionSlider() {
45
45
  regionSlider: { type: regionSliderType, isOpen },
46
46
  closeRegionSlider,
47
47
  } = useUI()
48
- const { isValidating, isSessionReady, ...session } = useSession()
48
+ const { isValidating, ...session } = useSession()
49
49
  const { state: searchState, setState: setSearchState } = useSearch()
50
50
  const {
51
51
  loading: loadingRegion,
@@ -10,7 +10,7 @@ import type {
10
10
  } from '@generated/graphql'
11
11
  import ReorderError from '../error/ReorderError/ReorderError'
12
12
  import { request } from '../graphql/request'
13
- import { sessionStore } from '../session'
13
+ import { sessionStore, toSessionInput } from '../session'
14
14
  import { useLink } from '../ui/useLink'
15
15
 
16
16
  import storeConfig from '../../../discovery.config'
@@ -116,7 +116,7 @@ export const useReorder = () => {
116
116
  ValidateCartMutationMutation,
117
117
  ValidateCartMutationMutationVariables
118
118
  >(ValidateCartMutation, {
119
- session: sessionStore.read(),
119
+ session: toSessionInput(sessionStore.read()),
120
120
  cart: {
121
121
  order: orderPayload as IStoreCart['order'],
122
122
  },
@@ -13,7 +13,11 @@ import type {
13
13
 
14
14
  import storeConfig from '../../../discovery.config'
15
15
  import { request } from '../graphql/request'
16
- import { hasValidatedSessionStore, sessionStore } from '../session'
16
+ import {
17
+ hasValidatedSessionStore,
18
+ sessionStore,
19
+ toSessionInput,
20
+ } from '../session'
17
21
  import { syncSalesChannelFromOrderForm } from '../session/syncSalesChannelFromOrderForm'
18
22
  import { createValidationStore, useStore } from '../useStore'
19
23
  import { waitForSessionValidated } from './waitForSessionValidated'
@@ -123,7 +127,9 @@ const validateCart = async (cart: Cart): Promise<Cart | null> => {
123
127
  ValidateCartMutationMutation,
124
128
  ValidateCartMutationMutationVariables
125
129
  >(ValidateCartMutation, {
126
- session: sessionStore.read(),
130
+ // The session loaded from IndexedDB skips `sessionStore.set`, so it may
131
+ // still carry UI state persisted by an older version
132
+ session: toSessionInput(sessionStore.read()),
127
133
  cart: {
128
134
  order: {
129
135
  orderNumber: cart.id,
@@ -21,6 +21,9 @@ import { createValidationStore, useStore } from '../useStore'
21
21
  import { getPostalCode } from '../userLocation/index'
22
22
  import { getInitialSession, reconcileSessionLocale } from './initialSession'
23
23
  import { RELOAD_AFTER_LOGOUT_KEY, SESSION_READY_KEY } from './storageKeys'
24
+ import { type SessionUIKey, toSessionInput } from './toSessionInput'
25
+
26
+ export { toSessionInput } from './toSessionInput'
24
27
 
25
28
  const isReloadAfterLogoutPending = (): boolean => {
26
29
  try {
@@ -160,18 +163,11 @@ export const validateSession = async (session: Session) => {
160
163
  return null
161
164
  }
162
165
 
163
- // Remove fields that are not part of IStoreSession type
164
- const { isSessionReady, isValidating, ...sessionWithoutExtras } =
165
- session as Session & {
166
- isSessionReady?: boolean
167
- isValidating?: boolean
168
- }
169
-
170
166
  const data = await request<
171
167
  ValidateSessionMutation,
172
168
  ValidateSessionMutationVariables
173
169
  >(mutation, {
174
- session: sessionWithoutExtras,
170
+ session: toSessionInput(session),
175
171
  search: window.location.search,
176
172
  })
177
173
 
@@ -210,9 +206,11 @@ const defaultStore = createSessionStore(
210
206
  export const sessionStore = {
211
207
  ...defaultStore,
212
208
  set: (val: Session) => {
213
- if (deepEqual(val, defaultStore.read()) === true) return
209
+ // Also drops UI state already persisted, since `session` then differs
210
+ const session = toSessionInput(val)
211
+ if (deepEqual(session, defaultStore.read()) === true) return
214
212
 
215
- defaultStore.set(val)
213
+ defaultStore.set(session)
216
214
 
217
215
  // Trigger cart revalidation when session changes
218
216
  cartStore.set(cartStore.read())
@@ -224,9 +222,10 @@ export const sessionStore = {
224
222
  * path keeps an explicit (non-default) client SC.
225
223
  */
226
224
  setSilent: (val: Session) => {
227
- if (deepEqual(val, defaultStore.read()) === true) return
225
+ const session = toSessionInput(val)
226
+ if (deepEqual(session, defaultStore.read()) === true) return
228
227
 
229
- defaultStore.set(val)
228
+ defaultStore.set(session)
230
229
  },
231
230
  }
232
231
 
@@ -276,16 +275,17 @@ export const useSession = ({ filter }: SessionOptions = { filter: true }) => {
276
275
  channel = filterChannel(channel ?? '')
277
276
  }
278
277
 
279
- return useMemo(
280
- () => ({
281
- ...session,
282
- channel,
278
+ return useMemo(() => {
279
+ // Must match `SESSION_UI_KEYS`, which `toSessionInput` strips before the
280
+ // session is stored or sent to the API
281
+ const uiState = {
283
282
  isValidating,
284
283
  isSessionReady,
285
284
  hasValidated,
286
- }),
287
- [isValidating, session, channel, isSessionReady, hasValidated]
288
- )
285
+ } satisfies Record<SessionUIKey, boolean>
286
+
287
+ return { ...session, channel, ...uiState }
288
+ }, [isValidating, session, channel, isSessionReady, hasValidated])
289
289
  }
290
290
 
291
291
  /**
@@ -0,0 +1,27 @@
1
+ import type { Session } from '@faststore/sdk'
2
+
3
+ /** UI-only state that `useSession()` returns next to the session fields. */
4
+ export const SESSION_UI_KEYS = [
5
+ 'isSessionReady',
6
+ 'isValidating',
7
+ 'hasValidated',
8
+ ] as const
9
+
10
+ export type SessionUIKey = (typeof SESSION_UI_KEYS)[number]
11
+
12
+ type SessionUIState = Partial<Record<SessionUIKey, boolean>>
13
+
14
+ /**
15
+ * Returns the session without the UI-only state, as `IStoreSession` expects.
16
+ * GraphQL rejects unknown input fields, so a session that carries them (e.g.
17
+ * built from `useSession()` or persisted that way) fails every validation.
18
+ */
19
+ export function toSessionInput(session: Session & SessionUIState): Session {
20
+ const input = { ...session }
21
+
22
+ for (const key of SESSION_UI_KEYS) {
23
+ delete input[key]
24
+ }
25
+
26
+ return input
27
+ }
@@ -0,0 +1,64 @@
1
+ import type { Session } from '@faststore/sdk'
2
+ import { act, renderHook } from '@testing-library/react'
3
+ import { afterEach, describe, expect, it, vi } from 'vitest'
4
+
5
+ const mockValidateSession = vi.hoisted(() => vi.fn())
6
+ const mockSessionSet = vi.hoisted(() => vi.fn())
7
+
8
+ vi.mock('src/sdk/session', async () => ({
9
+ validateSession: mockValidateSession,
10
+ sessionStore: { set: mockSessionSet },
11
+ toSessionInput: (await import('src/sdk/session/toSessionInput'))
12
+ .toSessionInput,
13
+ }))
14
+
15
+ vi.mock('src/sdk/product', () => ({
16
+ getProductCount: vi.fn().mockResolvedValue(1),
17
+ }))
18
+
19
+ import useRegion from '../../../src/components/region/RegionModal/useRegion'
20
+
21
+ const session: Session = {
22
+ locale: 'en-US',
23
+ currency: { code: 'USD', symbol: '$' },
24
+ country: 'USA',
25
+ channel: '{"salesChannel":"1","regionId":""}',
26
+ deliveryMode: null,
27
+ addressType: null,
28
+ city: null,
29
+ postalCode: null,
30
+ geoCoordinates: null,
31
+ person: null,
32
+ b2b: null,
33
+ marketingData: null,
34
+ refreshAfter: null,
35
+ }
36
+
37
+ describe('useRegion', () => {
38
+ afterEach(() => {
39
+ vi.clearAllMocks()
40
+ })
41
+
42
+ it('keeps the UI state from useSession() out of the new session', async () => {
43
+ mockValidateSession.mockResolvedValue(null)
44
+ const { result } = renderHook(() => useRegion())
45
+
46
+ await act(() =>
47
+ result.current.setRegion({
48
+ session: {
49
+ ...session,
50
+ isValidating: false,
51
+ isSessionReady: true,
52
+ hasValidated: true,
53
+ } as Session,
54
+ postalCode: '10001',
55
+ errorMessage: 'error',
56
+ })
57
+ )
58
+
59
+ const expected = { ...session, postalCode: '10001' }
60
+
61
+ expect(mockValidateSession).toHaveBeenCalledWith(expected)
62
+ expect(mockSessionSet).toHaveBeenCalledWith(expected)
63
+ })
64
+ })
@@ -0,0 +1,63 @@
1
+ import type { Session } from '@faststore/sdk'
2
+ import { beforeAll, beforeEach, describe, expect, it, vi } from 'vitest'
3
+
4
+ const mockRequest = vi.hoisted(() => vi.fn())
5
+
6
+ vi.mock('../../../src/sdk/graphql/request', () => ({
7
+ request: mockRequest,
8
+ }))
9
+
10
+ import { sessionStore } from '../../../src/sdk/session'
11
+
12
+ const session: Session = {
13
+ locale: 'en-US',
14
+ currency: { code: 'USD', symbol: '$' },
15
+ country: 'USA',
16
+ channel: '{"salesChannel":"1","regionId":""}',
17
+ deliveryMode: null,
18
+ addressType: null,
19
+ city: null,
20
+ postalCode: '10001',
21
+ geoCoordinates: null,
22
+ person: null,
23
+ b2b: null,
24
+ marketingData: null,
25
+ refreshAfter: null,
26
+ }
27
+
28
+ const withUIState = {
29
+ isValidating: false,
30
+ isSessionReady: true,
31
+ hasValidated: true,
32
+ }
33
+
34
+ describe('sessionStore', () => {
35
+ beforeAll(async () => {
36
+ mockRequest.mockResolvedValue({ validateSession: null })
37
+ // The store validates its initial session on load; let it settle first
38
+ await vi.waitFor(() => expect(mockRequest).toHaveBeenCalled())
39
+ })
40
+
41
+ beforeEach(() => {
42
+ mockRequest.mockClear()
43
+ })
44
+
45
+ it('does not store the UI state from useSession()', () => {
46
+ sessionStore.set({ ...session, ...withUIState } as Session)
47
+
48
+ expect(sessionStore.read()).toStrictEqual(session)
49
+ })
50
+
51
+ it('does not store the UI state on a silent update', () => {
52
+ sessionStore.setSilent({
53
+ ...session,
54
+ postalCode: '10002',
55
+ ...withUIState,
56
+ } as Session)
57
+
58
+ expect(sessionStore.read()).toStrictEqual({
59
+ ...session,
60
+ postalCode: '10002',
61
+ })
62
+ })
63
+ })
@@ -0,0 +1,43 @@
1
+ import type { Session } from '@faststore/sdk'
2
+ import { describe, expect, it } from 'vitest'
3
+
4
+ import { toSessionInput } from '../../../src/sdk/session/toSessionInput'
5
+
6
+ const session: Session = {
7
+ locale: 'en-US',
8
+ currency: { code: 'USD', symbol: '$' },
9
+ country: 'USA',
10
+ channel: '{"salesChannel":"1","regionId":""}',
11
+ deliveryMode: null,
12
+ addressType: null,
13
+ city: null,
14
+ postalCode: '10001',
15
+ geoCoordinates: null,
16
+ person: null,
17
+ b2b: null,
18
+ marketingData: null,
19
+ refreshAfter: null,
20
+ }
21
+
22
+ describe('toSessionInput', () => {
23
+ it('drops the UI state useSession() adds, which IStoreSession rejects', () => {
24
+ expect(
25
+ toSessionInput({
26
+ ...session,
27
+ isValidating: false,
28
+ isSessionReady: true,
29
+ hasValidated: true,
30
+ })
31
+ ).toEqual(session)
32
+ })
33
+
34
+ it('strips the UI state from a session persisted with it', () => {
35
+ const persisted = { ...session, hasValidated: true } as Session
36
+
37
+ expect(toSessionInput(persisted)).toEqual(session)
38
+ })
39
+
40
+ it('keeps a clean session as is', () => {
41
+ expect(toSessionInput(session)).toEqual(session)
42
+ })
43
+ })
@@ -0,0 +1,47 @@
1
+ import type { Session } from '@faststore/sdk'
2
+ import { beforeEach, describe, expect, it, vi } from 'vitest'
3
+
4
+ const mockRequest = vi.hoisted(() => vi.fn())
5
+
6
+ vi.mock('../../../src/sdk/graphql/request', () => ({
7
+ request: mockRequest,
8
+ }))
9
+
10
+ import { validateSession } from '../../../src/sdk/session'
11
+
12
+ const session: Session = {
13
+ locale: 'en-US',
14
+ currency: { code: 'USD', symbol: '$' },
15
+ country: 'USA',
16
+ channel: '{"salesChannel":"1","regionId":""}',
17
+ deliveryMode: null,
18
+ addressType: null,
19
+ city: null,
20
+ postalCode: '10001',
21
+ geoCoordinates: null,
22
+ person: null,
23
+ b2b: null,
24
+ marketingData: null,
25
+ refreshAfter: null,
26
+ }
27
+
28
+ describe('validateSession', () => {
29
+ beforeEach(async () => {
30
+ mockRequest.mockResolvedValue({ validateSession: null })
31
+ // The store validates its initial session on load; let it settle first
32
+ await vi.waitFor(() => expect(mockRequest).toHaveBeenCalled())
33
+ mockRequest.mockClear()
34
+ })
35
+
36
+ it('does not send the UI state persisted with the session', async () => {
37
+ await validateSession({
38
+ ...session,
39
+ isValidating: false,
40
+ isSessionReady: true,
41
+ hasValidated: true,
42
+ } as Session)
43
+
44
+ expect(mockRequest).toHaveBeenCalledTimes(1)
45
+ expect(mockRequest.mock.calls[0][1].session).toStrictEqual(session)
46
+ })
47
+ })