@faststore/core 4.11.4-dev.1 → 4.11.4-dev.3

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.11.4-dev.0 generate /home/runner/work/faststore/faststore/packages/core
2
+ > @faststore/core@4.11.4-dev.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.11.4-dev.0 gen-types /home/runner/work/faststore/faststore/packages/core
6
+ > @faststore/core@4.11.4-dev.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.11.4-dev.0 cache-graphql /home/runner/work/faststore/faststore/packages/core
22
+ > @faststore/core@4.11.4-dev.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.11.4-dev.0 test /home/runner/work/faststore/faststore/packages/core
2
+ > @faststore/core@4.11.4-dev.2 test /home/runner/work/faststore/faststore/packages/core
3
3
  > vitest run
4
4
 
5
5
 
@@ -7,29 +7,25 @@
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) 975ms
10
+ ✓  browser  test/sdk/ui/useScrollRestoration.browser.test.ts (43 tests) 991ms
11
11
  Browserslist: browsers data (caniuse-lite) is 9 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/cards/MyAccountListCards.browser.test.tsx (16 tests) 2842ms
15
- ✓ shows the tab bar and renders Personal cards by default  1156ms
16
- ✓ paginates when there are more than 25 cards  479ms
17
- ✓  browser  test/components/account/ContractSwitcher.browser.test.tsx (22 tests) 3486ms
18
- ✓ shows an error state when the list fails to load  820ms
19
- ✓ requires selecting a contract before Confirm is enabled, then switches (REQ-03)  408ms
20
- ✓ keeps Confirm disabled until a different contract is selected  341ms
21
- ✓ keeps Confirm disabled when switching is unavailable  359ms
22
- ✓ keeps Confirm disabled when the selected contract is filtered out  361ms
23
- ✓  browser  test/components/account/orders/BuyingPolicyAlert.browser.test.tsx (13 tests) 2266ms
24
- ✓ opens the reject confirmation modal with the default English copy  753ms
25
- ✓ opens the reject confirmation modal with CMS-provided labels  319ms
26
- ✓  browser  test/sdk/product/usePageProductsQuery.browser.test.ts (9 tests) 127ms
27
- ✓  browser  test/components/ui/RichText/RichText.browser.test.tsx (8 tests) 228ms
28
- ✓  browser  test/components/account/OrganizationDrawer.browser.test.tsx (10 tests) 1594ms
29
- ✓ renders the menu view with contract details and manage footer  802ms
30
- ✓  browser  test/sdk/session/reconcileSessionLocale.browser.test.ts (6 tests) 11ms
31
- ✓  browser  test/sdk/localization/useBindingSelector.browser.test.tsx (9 tests) 75ms
32
- ✓  browser  test/components/CartRecommendationShelf/CartRecommendationShelf.browser.test.tsx (13 tests) 188ms
14
+ ✓  browser  test/components/account/ContractSwitcher.browser.test.tsx (22 tests) 2246ms
15
+ ✓ shows an error state when the list fails to load  501ms
16
+ ✓  browser  test/components/account/cards/MyAccountListCards.browser.test.tsx (16 tests) 1654ms
17
+ ✓ shows the tab bar and renders Personal cards by default  844ms
18
+ ✓  browser  test/components/account/orders/BuyingPolicyAlert.browser.test.tsx (13 tests) 1555ms
19
+ ✓ opens the reject confirmation modal with the default English copy  861ms
20
+ ✓  browser  test/components/account/OrganizationDrawer.browser.test.tsx (10 tests) 1190ms
21
+ ✓ renders the menu view with contract details and manage footer  671ms
22
+ ✓  browser  test/components/ui/RichText/RichText.browser.test.tsx (8 tests) 290ms
23
+ ✓  browser  test/sdk/product/usePageProductsQuery.browser.test.ts (9 tests) 50ms
24
+ ✓  browser  test/components/CartRecommendationShelf/CartRecommendationShelf.browser.test.tsx (13 tests) 75ms
25
+ ✓  browser  test/sdk/localization/useBindingSelector.browser.test.tsx (9 tests) 27ms
26
+ ✓  browser  test/sdk/session/reconcileSessionLocale.browser.test.ts (6 tests) 12ms
27
+ ✓  browser  test/components/ui/ProductGallery/GalleryPageHeightLock.browser.test.tsx (8 tests) 48ms
28
+ ✓  browser  test/sdk/recommendations/useRecommendationShelf.browser.test.tsx (12 tests) 75ms
33
29
  stderr | test/components/RecommendationShelf/RecommendationShelf.browser.test.tsx
34
30
  Error in optimistic validation: TypeError: Failed to parse URL from /api/graphql?operationName=ValidateCartMutation&operationHash=3c71b0d3fc2bade14df68abfa271858beb361b12
35
31
   at node:internal/deps/undici/undici:16416:13
@@ -56,16 +52,14 @@ Browserslist: browsers data (caniuse-lite) is 9 months old. Please run:
56
52
  }
57
53
  }
58
54
 
59
- ✓  browser  test/sdk/recommendations/useRecommendationShelf.browser.test.tsx (12 tests) 33ms
60
- ✓  browser  test/components/ui/ProductGallery/GalleryPageHeightLock.browser.test.tsx (8 tests) 98ms
61
55
  stderr | test/components/RecommendationShelf/RecommendationShelf.browser.test.tsx > RecommendationShelf > renders nothing when there is an error
62
56
  Error fetching recommendations undefined boom for campaign vrn:recommendations:acc:rec-top-items-v2:campaign-1
63
57
 
64
- ✓  browser  test/components/RecommendationShelf/RecommendationShelf.browser.test.tsx (8 tests) 83ms
65
- ✓  browser  test/components/sections/Account/AccountOrderDetails.browser.test.tsx (4 tests) 53ms
66
- ✓  browser  test/components/CartSidebar/CartSidebar.browser.test.tsx (5 tests) 114ms
67
- ✓  browser  test/sdk/product/useProductQuery.browser.test.ts (5 tests) 359ms
68
- ✓  browser  test/sdk/session/getInitialSession.browser.test.ts (7 tests) 13ms
58
+ ✓  browser  test/components/RecommendationShelf/RecommendationShelf.browser.test.tsx (8 tests) 89ms
59
+ ✓  browser  test/sdk/product/useProductQuery.browser.test.ts (5 tests) 311ms
60
+ ✓  browser  test/components/CartSidebar/CartSidebar.browser.test.tsx (5 tests) 43ms
61
+ ✓  browser  test/sdk/session/getInitialSession.browser.test.ts (7 tests) 14ms
62
+ ✓  browser  test/components/sections/Account/AccountOrderDetails.browser.test.tsx (4 tests) 54ms
69
63
  stderr | test/sdk/session/validateSession.browser.test.ts
70
64
  Error in optimistic validation: TypeError: Cannot read properties of undefined (reading 'read')
71
65
  at waitForSessionValidated (/home/runner/work/faststore/faststore/packages/core/src/sdk/cart/waitForSessionValidated.ts:16:32)
@@ -74,8 +68,7 @@ Browserslist: browsers data (caniuse-lite) is 9 months old. Please run:
74
68
  at a (/home/runner/work/faststore/faststore/packages/sdk/dist/es/index.mjs:357:23)
75
69
   at processTicksAndRejections (node:internal/process/task_queues:103:5)
76
70
 
77
- ✓  browser  test/components/navigation/Navbar.browser.test.tsx (3 tests) 41ms
78
- ✓  browser  test/sdk/session/validateSession.browser.test.ts (9 tests) 21ms
71
+ ✓  browser  test/sdk/session/validateSession.browser.test.ts (9 tests) 20ms
79
72
  stderr | test/pages/password-protection.browser.test.tsx > PasswordProtectionLogin > posts the password and redirects to the requested return path
80
73
  Warning: An update to PasswordProtectionLogin inside a test was not wrapped in act(...).
81
74
 
@@ -305,8 +298,10 @@ act(() => {
305
298
  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
306
299
  at PasswordProtectionLogin (/home/runner/work/faststore/faststore/packages/core/src/pages/password-protection/index.tsx:19:69)
307
300
 
308
- ✓  browser  test/pages/password-protection.browser.test.tsx (6 tests) 1061ms
309
- ✓ renders the password protection form  461ms
301
+ ✓  browser  test/pages/password-protection.browser.test.tsx (6 tests) 649ms
302
+ ✓  browser  test/components/navigation/Navbar.browser.test.tsx (3 tests) 89ms
303
+ ✓  browser  test/components/account/OrganizationDrawerFooter.browser.test.tsx (8 tests) 433ms
304
+ ✓  browser  test/sdk/account/useSwitchContract.browser.test.ts (5 tests) 68ms
310
305
  stderr | test/components/cms/RenderSections.browser.test.tsx
311
306
  Error in optimistic validation: TypeError: Cannot read properties of undefined (reading 'read')
312
307
  at waitForSessionValidated (/home/runner/work/faststore/faststore/packages/core/src/sdk/cart/waitForSessionValidated.ts:16:32)
@@ -315,13 +310,9 @@ This ensures that you're testing the behavior the user would see in the browser.
315
310
  at a (/home/runner/work/faststore/faststore/packages/sdk/dist/es/index.mjs:357:23)
316
311
   at processTicksAndRejections (node:internal/process/task_queues:103:5)
317
312
 
318
- ✓  browser  test/components/account/OrganizationDrawerFooter.browser.test.tsx (8 tests) 607ms
319
- ✓ shows manage link for organization managers  391ms
320
- ✓  browser  test/sdk/account/useSwitchContract.browser.test.ts (5 tests) 40ms
321
- ✓  browser  test/components/cms/RenderSections.browser.test.tsx (5 tests) 121ms
322
- ✓  browser  test/components/navigation/NavbarSlider.browser.test.tsx (2 tests) 37ms
323
- ✓  browser  test/sdk/product/usePageProductsQuery.deliveryPromise.browser.test.ts (3 tests) 29ms
324
- ✓  browser  test/components/account/Menu.browser.test.tsx (6 tests) 228ms
313
+ ✓  browser  test/components/cms/RenderSections.browser.test.tsx (5 tests) 52ms
314
+ ✓  browser  test/components/navigation/NavbarSlider.browser.test.tsx (2 tests) 21ms
315
+ ✓  browser  test/sdk/product/usePageProductsQuery.deliveryPromise.browser.test.ts (3 tests) 26ms
325
316
  stderr | test/sdk/localization/store-url.browser.test.ts
326
317
  Error in optimistic validation: TypeError: Cannot read properties of undefined (reading 'read')
327
318
  at waitForSessionValidated (/home/runner/work/faststore/faststore/packages/core/src/sdk/cart/waitForSessionValidated.ts:16:32)
@@ -330,9 +321,10 @@ This ensures that you're testing the behavior the user would see in the browser.
330
321
  at a (/home/runner/work/faststore/faststore/packages/sdk/dist/es/index.mjs:357:23)
331
322
   at processTicksAndRejections (node:internal/process/task_queues:103:5)
332
323
 
333
- ✓  browser  test/sdk/localization/store-url.browser.test.ts (3 tests) 4ms
334
- ✓  browser  test/sdk/account/useAvailableContracts.browser.test.ts (6 tests) 26ms
335
- ✓  browser  test/components/templates/SearchPage/SearchWrapper.browser.test.tsx (3 tests) 34ms
324
+ ✓  browser  test/sdk/localization/store-url.browser.test.ts (3 tests) 5ms
325
+ ✓  browser  test/sdk/account/useAvailableContracts.browser.test.ts (6 tests) 25ms
326
+ ✓  browser  test/components/account/Menu.browser.test.tsx (6 tests) 202ms
327
+ ✓  browser  test/components/templates/SearchPage/SearchWrapper.browser.test.tsx (3 tests) 17ms
336
328
  stderr | test/sdk/session/refreshTokenRoute.browser.test.ts
337
329
  Error in optimistic validation: TypeError: Cannot read properties of undefined (reading 'read')
338
330
  at waitForSessionValidated (/home/runner/work/faststore/faststore/packages/core/src/sdk/cart/waitForSessionValidated.ts:16:32)
@@ -341,12 +333,12 @@ This ensures that you're testing the behavior the user would see in the browser.
341
333
  at a (/home/runner/work/faststore/faststore/packages/sdk/dist/es/index.mjs:357:23)
342
334
   at processTicksAndRejections (node:internal/process/task_queues:103:5)
343
335
 
344
- ✓  browser  test/sdk/recommendations/useRecommendationShelf.sessionFallback.browser.test.tsx (2 tests) 128ms
345
- ✓  browser  test/sdk/session/refreshTokenRoute.browser.test.ts (3 tests) 6ms
346
- ✓  browser  test/components/navigation/NavbarAccountArea.browser.test.tsx (4 tests) 42ms
347
- ✓  browser  test/components/CartRecommendationShelf/CartRecommendationProductCard.browser.test.tsx (3 tests) 46ms
348
- ✓  browser  test/components/sections/Account/AccountListQuotes.browser.test.tsx (4 tests) 109ms
349
- ✓  browser  test/sdk/account/changeContractToken.browser.test.ts (9 tests) 12ms
336
+ ✓  browser  test/sdk/session/refreshTokenRoute.browser.test.ts (3 tests) 5ms
337
+ ✓  browser  test/sdk/recommendations/useRecommendationShelf.sessionFallback.browser.test.tsx (2 tests) 120ms
338
+ ✓  browser  test/components/sections/Account/AccountListQuotes.browser.test.tsx (4 tests) 87ms
339
+ ✓  browser  test/components/navigation/NavbarAccountArea.browser.test.tsx (4 tests) 35ms
340
+ ✓  browser  test/components/CartRecommendationShelf/CartRecommendationProductCard.browser.test.tsx (3 tests) 26ms
341
+ ✓  browser  test/sdk/account/changeContractToken.browser.test.ts (9 tests) 9ms
350
342
  stderr | test/components/account/doLogout.browser.test.ts
351
343
  Error in optimistic validation: TypeError: Cannot read properties of undefined (reading 'read')
352
344
  at waitForSessionValidated (/home/runner/work/faststore/faststore/packages/core/src/sdk/cart/waitForSessionValidated.ts:16:32)
@@ -355,11 +347,12 @@ This ensures that you're testing the behavior the user would see in the browser.
355
347
  at a (/home/runner/work/faststore/faststore/packages/sdk/dist/es/index.mjs:357:23)
356
348
   at processTicksAndRejections (node:internal/process/task_queues:103:5)
357
349
 
358
- ✓  browser  test/components/account/doLogout.browser.test.ts (1 test) 39ms
359
- ✓  browser  test/components/account/OrganizationDrawerHeader.browser.test.tsx (5 tests) 288ms
360
- ✓  browser  test/sdk/product/useProductNotFoundRedirect.browser.test.ts (7 tests) 30ms
350
+ ✓  browser  test/components/account/doLogout.browser.test.ts (1 test) 28ms
351
+ ✓  browser  test/components/account/OrganizationDrawerHeader.browser.test.tsx (5 tests) 195ms
352
+ ✓  browser  test/sdk/product/useProductNotFoundRedirect.browser.test.ts (7 tests) 20ms
361
353
  ✓  browser  test/sdk/account/useRefreshToken.browser.test.ts (4 tests) 134ms
362
- ✓  browser  test/components/ui/LocalizationButton.browser.test.tsx (3 tests) 38ms
354
+ ✓  browser  test/components/ui/LocalizationButton.browser.test.tsx (3 tests) 27ms
355
+ ✓  browser  test/components/account/OrganizationSignInButton.browser.test.tsx (4 tests) 140ms
363
356
  stderr | test/sdk/account/clearPersistedSessionState.browser.test.ts
364
357
  Error in optimistic validation: TypeError: Cannot read properties of undefined (reading 'read')
365
358
  at waitForSessionValidated (/home/runner/work/faststore/faststore/packages/core/src/sdk/cart/waitForSessionValidated.ts:16:32)
@@ -368,14 +361,12 @@ This ensures that you're testing the behavior the user would see in the browser.
368
361
  at a (/home/runner/work/faststore/faststore/packages/sdk/dist/es/index.mjs:357:23)
369
362
   at processTicksAndRejections (node:internal/process/task_queues:103:5)
370
363
 
371
- ✓  browser  test/components/account/OrganizationSignInButton.browser.test.tsx (4 tests) 222ms
372
- ✓  browser  test/sdk/account/clearPersistedSessionState.browser.test.ts (4 tests) 15ms
373
- ✓  browser  test/components/sections/Account/AccountOrderDelivery.browser.test.tsx (2 tests) 55ms
374
- ✓  browser  test/components/account/orders/DeliveryOptionAccordion.browser.test.tsx (2 tests) 72ms
375
- ✓  browser  test/components/sections/Account/AccountOrderStatus.browser.test.tsx (3 tests) 95ms
376
- ✓  browser  test/components/sections/Account/AccountListCards.browser.test.tsx (3 tests) 53ms
377
- ✓  browser  test/components/region/useRegion.browser.test.ts (1 test) 19ms
378
- ✓  browser  test/components/sections/Account/AccountOrdersList.browser.test.tsx (2 tests) 20ms
364
+ ✓  browser  test/sdk/account/clearPersistedSessionState.browser.test.ts (4 tests) 13ms
365
+ ✓  browser  test/components/sections/Account/AccountOrderDelivery.browser.test.tsx (2 tests) 58ms
366
+ ✓  browser  test/components/account/orders/DeliveryOptionAccordion.browser.test.tsx (2 tests) 61ms
367
+ ✓  browser  test/components/sections/Account/AccountOrderStatus.browser.test.tsx (3 tests) 61ms
368
+ ✓  browser  test/components/region/useRegion.browser.test.ts (1 test) 14ms
369
+ ✓  browser  test/components/sections/Account/AccountListCards.browser.test.tsx (3 tests) 49ms
379
370
  stderr | test/sdk/session/sessionStore.browser.test.ts
380
371
  Error in optimistic validation: TypeError: Cannot read properties of undefined (reading 'read')
381
372
  at waitForSessionValidated (/home/runner/work/faststore/faststore/packages/core/src/sdk/cart/waitForSessionValidated.ts:16:32)
@@ -384,10 +375,11 @@ This ensures that you're testing the behavior the user would see in the browser.
384
375
  at a (/home/runner/work/faststore/faststore/packages/sdk/dist/es/index.mjs:357:23)
385
376
   at processTicksAndRejections (node:internal/process/task_queues:103:5)
386
377
 
387
- ✓  browser  test/sdk/session/sessionStore.browser.test.ts (2 tests) 5ms
388
- ✓  browser  test/components/account/orders/SummaryCard.browser.test.tsx (2 tests) 64ms
389
- ✓  browser  test/components/account/orders/DeliveryOptionAccordionDeliveryInfo.browser.test.tsx (1 test) 32ms
390
- ✓  browser  test/utils/shouldBypassRefreshToken.browser.test.ts (5 tests) 5ms
378
+ ✓  browser  test/components/sections/Account/AccountOrdersList.browser.test.tsx (2 tests) 19ms
379
+ ✓  browser  test/sdk/session/sessionStore.browser.test.ts (2 tests) 4ms
380
+ ✓  browser  test/components/account/orders/SummaryCard.browser.test.tsx (2 tests) 40ms
381
+ ✓  browser  test/utils/shouldBypassRefreshToken.browser.test.ts (5 tests) 3ms
382
+ ✓  browser  test/components/account/orders/DeliveryOptionAccordionDeliveryInfo.browser.test.tsx (1 test) 27ms
391
383
  stderr | test/sdk/account/refreshToken.browser.test.ts
392
384
  Error in optimistic validation: TypeError: Cannot read properties of undefined (reading 'read')
393
385
  at waitForSessionValidated (/home/runner/work/faststore/faststore/packages/core/src/sdk/cart/waitForSessionValidated.ts:16:32)
@@ -397,18 +389,17 @@ This ensures that you're testing the behavior the user would see in the browser.
397
389
   at processTicksAndRejections (node:internal/process/task_queues:103:5)
398
390
 
399
391
  ✓  browser  test/sdk/account/refreshToken.browser.test.ts (2 tests) 4ms
400
- ✓  browser  test/components/account/orders/StatusCard.browser.test.tsx (2 tests) 75ms
401
- ✓  browser  test/sdk/session/reconcileSessionLocale.disabled.browser.test.ts (1 test) 3ms
402
- ✓  browser  test/components/account/orders/DeliveryCard.browser.test.tsx (1 test) 36ms
403
- ✓  browser  test/components/account/orders/DeliveryOptionAccordionProducts.browser.test.tsx (1 test) 25ms
392
+ ✓  browser  test/sdk/session/reconcileSessionLocale.disabled.browser.test.ts (1 test) 2ms
393
+ ✓  browser  test/components/account/orders/StatusCard.browser.test.tsx (2 tests) 70ms
394
+ ✓  browser  test/components/account/orders/DeliveryCard.browser.test.tsx (1 test) 28ms
395
+ ✓  browser  test/components/account/orders/DeliveryOptionAccordionProducts.browser.test.tsx (1 test) 26ms
404
396
  ✓  browser  test/components/skeletons/ProductGridSkeleton.browser.test.tsx (2 tests) 23ms
405
- ✓  node  test/pages/api/switch-contract.test.ts (61 tests) 137ms
406
- ✓  node  test/utils/localization/bindingPaths.test.ts (71 tests) 21ms
407
- ✓  node  test/server/password-protection-service.test.ts (22 tests) 32ms
408
- ✓  browser  test/components/account/orders/FilterFacetPendingApproval.browser.test.tsx (1 test) 174ms
409
- ✓  node  test/server/content/service.test.ts (32 tests) 36ms
410
- ✓  node  test/sdk/localization/useBindingSelector.test.tsx (22 tests) 12ms
411
- ✓  node  test/utils/match-url.test.ts (10 tests) 6ms
397
+ ✓  node  test/pages/api/switch-contract.test.ts (61 tests) 139ms
398
+ ✓  browser  test/components/account/orders/FilterFacetPendingApproval.browser.test.tsx (1 test) 116ms
399
+ ✓  node  test/utils/localization/bindingPaths.test.ts (71 tests) 14ms
400
+ ✓  node  test/server/password-protection-service.test.ts (22 tests) 22ms
401
+ ✓  node  test/server/content/service.test.ts (32 tests) 30ms
402
+ ✓  node  test/sdk/localization/useBindingSelector.test.tsx (22 tests) 8ms
412
403
  stderr | test/sdk/deliveryPromise/provider.effect.test.tsx > DeliveryPromiseProvider pickup fetch > clears the loading flag after a failed request and retries on the next update
413
404
  Failed to fetch pickup points: Error: network
414
405
  at /home/runner/work/faststore/faststore/packages/core/test/sdk/deliveryPromise/provider.effect.test.tsx:250:30
@@ -435,7 +426,8 @@ This ensures that you're testing the behavior the user would see in the browser.
435
426
  at trace (file:///home/runner/work/faststore/faststore/node_modules/.pnpm/vitest@4.0.18_@opentelemetry+api@1.9.0_@types+node@20.19.13_jiti@2.6.1_jsdom@27.4.0_sas_13be941c57d55f08f06eeaf1c180ddfe/node_modules/vitest/dist/chunks/test.B8ej_ZHS.js:239:21)
436
427
  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)
437
428
 
438
- ✓  node  test/sdk/deliveryPromise/provider.effect.test.tsx (9 tests) 75ms
429
+ ✓  node  test/sdk/deliveryPromise/provider.effect.test.tsx (9 tests) 50ms
430
+ ✓  node  test/utils/match-url.test.ts (10 tests) 5ms
439
431
  stderr | test/pages/api/graphql.test.ts > /api/graphql error status propagation > propagates the upstream 400 from a wrapped BadRequestError instead of 500
440
432
  Graphql execution returned with error: [
441
433
  {
@@ -577,13 +569,13 @@ This ensures that you're testing the behavior the user would see in the browser.
577
569
  extensions: { status: 401, type: 'UnauthorizedError' }
578
570
  }
579
571
 
580
- ✓  node  test/pages/api/graphql.test.ts (30 tests) 37ms
581
- ✓  node  test/pages/api/unlock.test.ts (15 tests) 114ms
582
- ✓  node  test/sdk/session/syncSalesChannelFromOrderForm.test.ts (14 tests) 8ms
583
- ✓  node  test/sdk/localization/bindingSelector.test.ts (18 tests) 7ms
572
+ ✓  node  test/pages/api/graphql.test.ts (30 tests) 25ms
573
+ ✓  node  test/pages/api/unlock.test.ts (15 tests) 83ms
574
+ ✓  node  test/sdk/session/syncSalesChannelFromOrderForm.test.ts (14 tests) 10ms
584
575
  stderr | test/components/search/SearchInputComponent.test.tsx
585
576
  Warning: forwardRef render functions accept exactly two parameters: props and ref. Did you forget to use the ref parameter?
586
577
 
578
+ ✓  node  test/sdk/localization/bindingSelector.test.ts (18 tests) 5ms
587
579
  stderr | test/components/search/SearchInputComponent.test.tsx > SearchInput (OES integration) > renders without crashing
588
580
  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.
589
581
  at div
@@ -644,10 +636,10 @@ Warning: React does not recognize the `providerProps` prop on a DOM element. If
644
636
  at Suspense
645
637
  at Wrapper (/home/runner/work/faststore/faststore/packages/core/test/components/search/SearchInputComponent.test.tsx:106:20)
646
638
 
647
- ✓  node  test/components/search/SearchInputComponent.test.tsx (6 tests) 55ms
648
- ✓  node  test/sdk/account/refreshToken.test.ts (21 tests) 8ms
649
- ✓  node  test/components/quotes/MyAccountListQuotesTable.test.tsx (15 tests) 337ms
650
- ✓  node  test/sdk/search/useSearchHistory.test.ts (13 tests) 35ms
639
+ ✓  node  test/components/search/SearchInputComponent.test.tsx (6 tests) 58ms
640
+ ✓  node  test/sdk/account/refreshToken.test.ts (21 tests) 6ms
641
+ ✓  node  test/components/quotes/MyAccountListQuotesTable.test.tsx (15 tests) 269ms
642
+ ✓  node  test/sdk/search/useSearchHistory.test.ts (13 tests) 34ms
651
643
  stderr | test/pages/pvt/account/cards/index.test.ts > Cards page getServerSideProps > redirects to /pvt/account/403 when the query fails with 401/403
652
644
  { extensions: { status: 401 } }
653
645
 
@@ -655,52 +647,53 @@ Warning: React does not recognize the `providerProps` prop on a DOM element. If
655
647
  { extensions: { status: 502 } }
656
648
 
657
649
  ✓  node  test/pages/pvt/account/cards/index.test.ts (8 tests) 6ms
658
- ✓  node  test/components/quotes/MyAccountListQuotes.test.tsx (11 tests) 809ms
659
- ✓ navigates with the search term on blur  358ms
660
- ✓ navigates without a label param when the search is cleared  358ms
661
- ✓  node  test/components/quotes/quoteFilters.test.ts (26 tests) 23ms
662
- ✓  node  test/utils/productJsonLd.test.ts (36 tests) 11ms
663
- ✓  node  test/utils/cookieCacheBusting.test.ts (10 tests) 10ms
664
- ✓  node  test/experimental/myAccountCmsServerSideProps.test.ts (5 tests) 7ms
665
- ✓  node  test/utils/clearCookies.test.ts (20 tests) 24ms
666
- ✓  node  test/utils/multipleTemplates.test.ts (8 tests) 6ms
650
+ ✓  node  test/components/quotes/quoteFilters.test.ts (26 tests) 16ms
651
+ ✓  node  test/utils/cookieCacheBusting.test.ts (10 tests) 6ms
652
+ ✓  node  test/utils/productJsonLd.test.ts (36 tests) 5ms
653
+ ✓  node  test/experimental/myAccountCmsServerSideProps.test.ts (5 tests) 4ms
654
+ ✓  node  test/components/quotes/MyAccountListQuotes.test.tsx (11 tests) 788ms
655
+ ✓ navigates with the search term on blur  355ms
656
+ ✓ navigates without a label param when the search is cleared  356ms
657
+ ✓  node  test/utils/clearCookies.test.ts (20 tests) 16ms
658
+ ✓  node  test/utils/multipleTemplates.test.ts (8 tests) 4ms
667
659
  stderr | test/sdk/account/useSetPassword.test.ts > useSetPassword > maps wrongcredentials error responses to the existing message
668
660
  Set password request failed: Bad Request
669
661
 
670
- ✓  node  test/sdk/account/useSetPassword.test.ts (6 tests) 35ms
671
- ✓  node  test/sdk/orderEntry/useOrderEntryOperation.test.ts (8 tests) 36ms
672
- ✓  node  test/utils/localization/localizeRedirectDestination.test.ts (11 tests) 7ms
673
- ✓  node  test/components/quotes/MyAccountQuotesFilterSlider.test.tsx (8 tests) 141ms
674
- ✓  node  test/utils/localization/hreflang.test.ts (8 tests) 5ms
675
- ✓  node  test/components/quotes/MyAccountQuotesStatusSelector.test.tsx (14 tests) 151ms
676
- ✓  node  test/components/quotes/MyAccountQuotesSelectedTags.test.tsx (10 tests) 83ms
662
+ ✓  node  test/sdk/account/useSetPassword.test.ts (6 tests) 27ms
663
+ ✓  node  test/sdk/orderEntry/useOrderEntryOperation.test.ts (8 tests) 24ms
664
+ ✓  node  test/utils/localization/localizeRedirectDestination.test.ts (11 tests) 4ms
665
+ ✓  node  test/components/quotes/MyAccountQuotesFilterSlider.test.tsx (8 tests) 90ms
666
+ ✓  node  test/components/quotes/MyAccountQuotesStatusSelector.test.tsx (14 tests) 82ms
667
+ ✓  node  test/utils/localization/hreflang.test.ts (8 tests) 6ms
677
668
  ✓  node  test/sdk/account/getMyAccountRoutes.test.ts (13 tests) 6ms
678
- ✓  node  test/server/cms/index.test.ts (7 tests) 10ms
679
- ✓  node  test/server/content/promiseCache.test.ts (10 tests) 9ms
680
- ✓  node  test/sdk/redirects/index.test.ts (7 tests) 26ms
681
- ✓  node  test/sdk/orderEntry/useOrderEntryUpload.test.ts (8 tests) 40ms
682
- ✓  node  test/sdk/orderEntry/useOrderEntry.test.ts (8 tests) 35ms
683
- ✓  node  test/proxy.localization.test.ts (5 tests) 38ms
684
- ✓  node  test/utils/trustedForwardedHost.test.ts (36 tests) 8ms
685
- ✓  node  test/components/account/orders/getDeliveryOptionLabel.test.ts (21 tests) 6ms
686
- ✓  node  test/sdk/graphql/retryPolicy.test.ts (18 tests) 17ms
687
- ✓  node  test/server/cms/myAccountDefaultSections.test.ts (9 tests) 4ms
688
- ✓  node  test/utils/productJsonLdRendering.test.tsx (5 tests) 13ms
689
- ✓  node  test/server/index.test.ts (7 tests) 1059ms
690
- ✓ should handle options and execute  636ms
691
- ✓  node  test/sdk/analytics/useStartRecommendationSession.test.ts (6 tests) 41ms
692
- ✓  node  test/proxy.test.ts (4 tests) 16ms
693
- ✓  node  test/sdk/orderEntry/useOrderFormItems.test.ts (7 tests) 31ms
694
- ✓  node  test/pages/api/logout.test.ts (4 tests) 31ms
695
- ✓  node  test/utils/shouldBypassRefreshToken.test.ts (14 tests) 6ms
696
- ✓  node  test/server/webops-api.test.ts (9 tests) 12ms
697
- ✓  node  test/components/account/orders/StatusCard.test.ts (3 tests) 21ms
698
- ✓  node  test/sdk/localization/store-url.test.ts (4 tests) 4ms
699
- ✓  node  test/sdk/deliveryPromise/queries.test.ts (4 tests) 7ms
700
- ✓  node  test/sdk/cart/waitForSessionValidated.test.ts (5 tests) 9ms
701
- ✓  node  test/server/cms/global.test.ts (3 tests) 3ms
702
- ✓  node  test/sdk/deliveryPromise/provider.test.ts (11 tests) 10ms
703
- ✓  node  test/sdk/auth/useAuth.test.ts (5 tests) 28ms
669
+ ✓  node  test/server/cms/index.test.ts (7 tests) 5ms
670
+ ✓  node  test/components/quotes/MyAccountQuotesSelectedTags.test.tsx (10 tests) 60ms
671
+ ✓  node  test/server/content/promiseCache.test.ts (10 tests) 7ms
672
+ ✓  node  test/sdk/redirects/index.test.ts (7 tests) 23ms
673
+ ✓  node  test/sdk/orderEntry/useOrderEntryUpload.test.ts (8 tests) 32ms
674
+ ✓  node  test/utils/toRevalidate.test.ts (16 tests) 30ms
675
+ ✓  node  test/sdk/orderEntry/useOrderEntry.test.ts (8 tests) 30ms
676
+ ✓  node  test/utils/trustedForwardedHost.test.ts (36 tests) 6ms
677
+ ✓  node  test/proxy.localization.test.ts (5 tests) 58ms
678
+ ✓  node  test/components/account/orders/getDeliveryOptionLabel.test.ts (21 tests) 5ms
679
+ ✓  node  test/sdk/graphql/retryPolicy.test.ts (18 tests) 9ms
680
+ ✓  node  test/server/cms/myAccountDefaultSections.test.ts (9 tests) 3ms
681
+ ✓  node  test/utils/productJsonLdRendering.test.tsx (5 tests) 7ms
682
+ ✓  node  test/server/index.test.ts (7 tests) 761ms
683
+ ✓ should handle options and execute  463ms
684
+ ✓  node  test/proxy.test.ts (4 tests) 15ms
685
+ ✓  node  test/sdk/analytics/useStartRecommendationSession.test.ts (6 tests) 32ms
686
+ ✓  node  test/sdk/orderEntry/useOrderFormItems.test.ts (7 tests) 22ms
687
+ ✓  node  test/pages/api/logout.test.ts (4 tests) 21ms
688
+ ✓  node  test/utils/shouldBypassRefreshToken.test.ts (14 tests) 4ms
689
+ ✓  node  test/server/webops-api.test.ts (9 tests) 7ms
690
+ ✓  node  test/components/account/orders/StatusCard.test.ts (3 tests) 17ms
691
+ ✓  node  test/sdk/localization/store-url.test.ts (4 tests) 3ms
692
+ ✓  node  test/sdk/deliveryPromise/queries.test.ts (4 tests) 5ms
693
+ ✓  node  test/sdk/cart/waitForSessionValidated.test.ts (5 tests) 7ms
694
+ ✓  node  test/server/cms/global.test.ts (3 tests) 2ms
695
+ ✓  node  test/sdk/deliveryPromise/provider.test.ts (11 tests) 3ms
696
+ ✓  node  test/sdk/auth/useAuth.test.ts (5 tests) 20ms
704
697
  stderr | test/server/storeDirectives.test.ts > store directives through the core server > applies @auth from a store field and validates the session once
705
698
  https://storeframework.vtexcommercestable.com.br/api/vtexid/credential/validate {
706
699
  headers: { 'content-type': 'application/json', 'X-FORWARDED-HOST': '' },
@@ -708,43 +701,43 @@ Warning: React does not recognize the `providerProps` prop on a DOM element. If
708
701
  method: 'POST'
709
702
  } { status: 401, statusText: 'Unauthorized', headers: {} }
710
703
 
711
- ✓  node  test/server/storeDirectives.test.ts (2 tests) 54ms
704
+ ✓  node  test/server/storeDirectives.test.ts (2 tests) 78ms
712
705
  ✓  node  test/utils/mergeDiscoveryConfig.test.ts (8 tests) 7ms
713
- ✓  node  test/server/rootSpan.test.ts (4 tests) 28ms
714
- ✓  node  test/utils/getRequestHostname.test.ts (12 tests) 5ms
715
- ✓  node  test/pages/api/preview.test.ts (2 tests) 10ms
716
- ✓  node  test/components/search/SearchInput.test.ts (6 tests) 6ms
717
- ✓  node  test/components/account/Layout.test.tsx (6 tests) 50ms
718
- ✓  node  test/utils/validateSessionRefreshToken.test.ts (6 tests) 4ms
719
- ✓  node  test/pages/pvt/account/403.test.ts (5 tests) 4ms
720
- ✓  node  test/sdk/recommendations/vrn.test.ts (5 tests) 4ms
721
- ✓  node  test/components/region/useRegion.test.ts (1 test) 16ms
722
- ✓  node  test/utils/retry.test.ts (5 tests) 11ms
706
+ ✓  node  test/server/rootSpan.test.ts (4 tests) 22ms
707
+ ✓  node  test/utils/getRequestHostname.test.ts (12 tests) 3ms
708
+ ✓  node  test/pages/api/preview.test.ts (2 tests) 4ms
709
+ ✓  node  test/components/account/Layout.test.tsx (6 tests) 45ms
710
+ ✓  node  test/components/search/SearchInput.test.ts (6 tests) 7ms
711
+ ✓  node  test/utils/validateSessionRefreshToken.test.ts (6 tests) 3ms
712
+ ✓  node  test/pages/pvt/account/403.test.ts (5 tests) 5ms
713
+ ✓  node  test/components/region/useRegion.test.ts (1 test) 18ms
714
+ ✓  node  test/sdk/recommendations/vrn.test.ts (5 tests) 3ms
715
+ ✓  node  test/utils/retry.test.ts (5 tests) 12ms
723
716
  ✓  node  test/sdk/account/getIsB2BBuyer.test.ts (7 tests) 3ms
724
- ✓  node  test/sdk/recommendations/useRecommendationUserId.test.ts (4 tests) 186ms
725
- ✓  node  test/sdk/account/getB2BSessionClaims.test.ts (4 tests) 3ms
726
- ✓  node  test/utils/subDomainPrefixWarning.test.ts (6 tests) 3ms
727
- ✓  node  test/utils/userOrderStatus.test.ts (4 tests) 4ms
728
- ✓  node  test/utils/unlockResponse.test.ts (11 tests) 4ms
729
- ✓  node  test/sdk/recommendations/useRecommendations.test.ts (2 tests) 4ms
730
- ✓  node  test/components/account/OrganizationDrawerBody.test.tsx (3 tests) 45ms
731
- ✓  node  test/sdk/deliveryPromise/reducer.test.ts (2 tests) 4ms
732
- ✓  node  test/utils/isLocalHost.test.ts (7 tests) 4ms
733
- ✓  node  test/components/quotes/MyAccountQuoteStatusBadge.test.tsx (4 tests) 33ms
734
- ✓  node  test/sdk/session/toSessionInput.test.ts (3 tests) 3ms
735
- ✓  node  test/components/account/orders/getOrderTotalLabel.test.ts (6 tests) 4ms
736
- ✓  node  test/components/account/orders/listOrdersLabels.test.ts (2 tests) 4ms
737
- ✓  node  test/utils/getCookie.test.ts (4 tests) 4ms
738
- ✓  node  test/sdk/session/isSignInAreaResolved.test.ts (3 tests) 3ms
739
- ✓  node  test/components/auth/ProfileChallenge.test.tsx (3 tests) 27ms
740
- ✓  node  test/utils/filterChannel.test.ts (2 tests) 4ms
741
- ✓  node  test/instrumentation.test.ts (3 tests) 5ms
742
- ✓  node  test/sdk/analytics/utils.test.ts (2 tests) 3ms
717
+ ✓  node  test/sdk/account/getB2BSessionClaims.test.ts (4 tests) 2ms
718
+ ✓  node  test/sdk/recommendations/useRecommendationUserId.test.ts (4 tests) 173ms
719
+ ✓  node  test/utils/subDomainPrefixWarning.test.ts (6 tests) 2ms
720
+ ✓  node  test/utils/userOrderStatus.test.ts (4 tests) 3ms
721
+ ✓  node  test/utils/unlockResponse.test.ts (11 tests) 3ms
722
+ ✓  node  test/sdk/recommendations/useRecommendations.test.ts (2 tests) 2ms
723
+ ✓  node  test/components/account/OrganizationDrawerBody.test.tsx (3 tests) 30ms
724
+ ✓  node  test/sdk/deliveryPromise/reducer.test.ts (2 tests) 3ms
725
+ ✓  node  test/components/quotes/MyAccountQuoteStatusBadge.test.tsx (4 tests) 26ms
726
+ ✓  node  test/utils/isLocalHost.test.ts (7 tests) 3ms
727
+ ✓  node  test/sdk/session/toSessionInput.test.ts (3 tests) 4ms
728
+ ✓  node  test/components/account/orders/getOrderTotalLabel.test.ts (6 tests) 3ms
729
+ ✓  node  test/components/account/orders/listOrdersLabels.test.ts (2 tests) 2ms
730
+ ✓  node  test/utils/getCookie.test.ts (4 tests) 3ms
731
+ ✓  node  test/components/auth/ProfileChallenge.test.tsx (3 tests) 23ms
732
+ ✓  node  test/sdk/session/isSignInAreaResolved.test.ts (3 tests) 2ms
733
+ ✓  node  test/utils/filterChannel.test.ts (2 tests) 3ms
734
+ ✓  node  test/sdk/analytics/utils.test.ts (2 tests) 2ms
735
+ ✓  node  test/instrumentation.test.ts (3 tests) 3ms
743
736
  ✓  node  test/components/account/orders/orderDetailsLabels.test.ts (1 test) 2ms
744
- ✓  node  test/sdk/account/clearPersistedSessionState.test.ts (1 test) 7ms
737
+ ✓  node  test/sdk/account/clearPersistedSessionState.test.ts (1 test) 6ms
745
738
 
746
-  Test Files  149 passed (149)
747
-  Tests  1270 passed (1270)
748
-  Start at  15:53:26
749
-  Duration  56.75s (transform 15.45s, setup 0ms, import 53.08s, tests 20.98s, environment 67.55s)
739
+  Test Files  150 passed (150)
740
+  Tests  1286 passed (1286)
741
+  Start at  15:25:42
742
+  Duration  43.72s (transform 11.41s, setup 0ms, import 40.25s, tests 15.33s, environment 51.80s)
750
743
 
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.11.4-dev.3](https://github.com/vtex/faststore/compare/v4.11.4-dev.2...v4.11.4-dev.3) (2026-11-18)
7
+
8
+ ### Bug Fixes
9
+
10
+ - **core:** add experimental.revalidatePLP to refresh cached PLPs ([#3595](https://github.com/vtex/faststore/issues/3595)) ([f14ca23](https://github.com/vtex/faststore/commit/f14ca23c3581d94961eac3bdc6839207066eff74)), closes [#3553](https://github.com/vtex/faststore/issues/3553) [#3553](https://github.com/vtex/faststore/issues/3553)
11
+
12
+ ## [4.11.4-dev.2](https://github.com/vtex/faststore/compare/v4.11.4-dev.1...v4.11.4-dev.2) (2026-11-17)
13
+
14
+ **Note:** Version bump only for package @faststore/core
15
+
6
16
  ## [4.11.4-dev.1](https://github.com/vtex/faststore/compare/v4.11.4-dev.0...v4.11.4-dev.1) (2026-11-16)
7
17
 
8
18
  **Note:** Version bump only for package @faststore/core
@@ -196,6 +196,11 @@ module.exports = {
196
196
  enableRedirects: false,
197
197
  // ISR window (seconds) for notFound PDP/PLP paths.
198
198
  revalidate404: 60 * 5, // 5 minutes
199
+ // ISR window (seconds) for PLPs served by `[...slug]`. `false` (default)
200
+ // caches the page until the next deploy. Set a positive integer number of
201
+ // seconds (values below 60 are raised to 60) to refresh the
202
+ // server-rendered first page (price, stock, order).
203
+ revalidatePLP: false,
199
204
  enableSearchSSR: false,
200
205
  enableFaststoreMyAccount: false,
201
206
  useIsGiftFromOrderForm: false,
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@faststore/core",
3
- "version": "4.11.4-dev.1",
3
+ "version": "4.11.4-dev.3",
4
4
  "license": "MIT",
5
5
  "repository": {
6
6
  "type": "git",
@@ -70,11 +70,11 @@
70
70
  "style-loader": "^3.3.1",
71
71
  "swr": "^2.2.5",
72
72
  "use-sync-external-store": "^1.6.0",
73
- "@faststore/lighthouse": "4.11.4-dev.1",
74
- "@faststore/sdk": "4.11.4-dev.1",
75
- "@faststore/diagnostics": "4.11.4-dev.1",
76
- "@faststore/ui": "4.11.4-dev.1",
77
- "@faststore/api": "4.11.4-dev.1"
73
+ "@faststore/api": "4.11.4-dev.3",
74
+ "@faststore/sdk": "4.11.4-dev.3",
75
+ "@faststore/ui": "4.11.4-dev.3",
76
+ "@faststore/diagnostics": "4.11.4-dev.3",
77
+ "@faststore/lighthouse": "4.11.4-dev.3"
78
78
  },
79
79
  "devDependencies": {
80
80
  "@cypress/code-coverage": "^3.12.1",
@@ -32,6 +32,7 @@ import { contentService } from 'src/server/content/service'
32
32
  import type { PreviewData } from 'src/server/content/types'
33
33
  import { getDynamicContent } from 'src/utils/dynamicContent'
34
34
  import { fetchServerManyProducts } from 'src/utils/fetchProductGallerySSR'
35
+ import { toRevalidate } from 'src/utils/toRevalidate'
35
36
 
36
37
  const LandingPage = dynamic(
37
38
  () => import('src/components/templates/LandingPage')
@@ -244,6 +245,15 @@ export const getStaticProps: GetStaticProps<
244
245
  type: 'plp',
245
246
  key: slug,
246
247
  },
248
+ // Without a window, the first page's products (price, stock, order) stay
249
+ // frozen at the state of their first render until the next deploy. Each
250
+ // regeneration reruns the CMS, collection and first-page search queries,
251
+ // so the window has a floor to bound the upstream load.
252
+ revalidate: toRevalidate(
253
+ storeConfig.experimental.revalidatePLP,
254
+ 'experimental.revalidatePLP',
255
+ { min: 60 }
256
+ ),
247
257
  }
248
258
  }
249
259
 
@@ -0,0 +1,74 @@
1
+ /**
2
+ * Config keys already warned about in this process. `getStaticProps` runs on
3
+ * every regeneration, so a per-call warning would repeat for every hot page.
4
+ */
5
+ const warnedKeys = new Set<string>()
6
+
7
+ function warnOnce(key: string, message: string) {
8
+ if (warnedKeys.has(key)) {
9
+ return
10
+ }
11
+
12
+ warnedKeys.add(key)
13
+ console.warn(message)
14
+ }
15
+
16
+ /**
17
+ * Normalizes an ISR `revalidate` window read from the store config.
18
+ *
19
+ * Returns the value when it is a positive integer number of seconds, raised
20
+ * to `min` when it is lower. Any other value returns `false`, which keeps
21
+ * Next.js' default for static pages: the page is cached until the next
22
+ * deploy. Next.js rejects `0`, negative and fractional windows at render
23
+ * time, so those fall back to `false` with a warning instead of breaking the
24
+ * page.
25
+ *
26
+ * @param value The configured window, e.g. `experimental.revalidatePLP`.
27
+ * @param key The config key, used in the warnings.
28
+ * @param options.min The shortest window allowed, in seconds. Defaults to 1.
29
+ */
30
+ export function toRevalidate(
31
+ value: unknown,
32
+ key: string,
33
+ { min = 1 }: { min?: number } = {}
34
+ ): number | false {
35
+ if (typeof value === 'number' && Number.isInteger(value) && value > 0) {
36
+ if (value < min) {
37
+ warnOnce(
38
+ key,
39
+ `[FastStore] ${key} is ${value}s. Using the minimum of ${min}s.`
40
+ )
41
+
42
+ return min
43
+ }
44
+
45
+ return value
46
+ }
47
+
48
+ if (value !== false && value !== undefined && value !== null) {
49
+ warnOnce(
50
+ key,
51
+ `[FastStore] Invalid ${key}: ${describeValue(value)}. Expected a positive integer number of seconds or false. The page will be cached until the next deploy.`
52
+ )
53
+ }
54
+
55
+ return false
56
+ }
57
+
58
+ /**
59
+ * Describes a config value for a warning without ever throwing: objects can
60
+ * be circular or hold bigints, which JSON.stringify rejects, so only their
61
+ * type is printed.
62
+ */
63
+ function describeValue(value: unknown): string {
64
+ switch (typeof value) {
65
+ case 'number':
66
+ case 'bigint':
67
+ case 'boolean':
68
+ return `${value}`
69
+ case 'string':
70
+ return JSON.stringify(value)
71
+ default:
72
+ return `a value of type ${typeof value}`
73
+ }
74
+ }
@@ -0,0 +1,118 @@
1
+ import { afterEach, beforeEach, describe, expect, it, vi } from 'vitest'
2
+
3
+ import type { toRevalidate as ToRevalidate } from 'src/utils/toRevalidate'
4
+
5
+ const KEY = 'experimental.revalidatePLP'
6
+
7
+ // The helper warns once per key per process, so each test loads a fresh
8
+ // module to start with no warnings recorded.
9
+ let toRevalidate: typeof ToRevalidate
10
+
11
+ beforeEach(async () => {
12
+ vi.resetModules()
13
+ ;({ toRevalidate } = await import('src/utils/toRevalidate'))
14
+ })
15
+
16
+ afterEach(() => {
17
+ vi.restoreAllMocks()
18
+ })
19
+
20
+ describe('toRevalidate', () => {
21
+ it('returns the number of seconds when it is a positive integer', () => {
22
+ expect(toRevalidate(300, KEY)).toBe(300)
23
+ expect(toRevalidate(1, KEY)).toBe(1)
24
+ })
25
+
26
+ it('returns false without a warning when the window is disabled or unset', () => {
27
+ const warn = vi.spyOn(console, 'warn').mockImplementation(() => {})
28
+
29
+ expect(toRevalidate(false, KEY)).toBe(false)
30
+ expect(toRevalidate(undefined, KEY)).toBe(false)
31
+ expect(toRevalidate(null, KEY)).toBe(false)
32
+ expect(warn).not.toHaveBeenCalled()
33
+ })
34
+
35
+ it.each([
36
+ // Next.js throws for these.
37
+ 0,
38
+ -60,
39
+ 90.5,
40
+ 0.5,
41
+ Number.NaN,
42
+ Number.POSITIVE_INFINITY,
43
+ '300',
44
+ // Next.js reads `true` as 1 second; the config expects explicit seconds.
45
+ true,
46
+ ])('returns false and warns for %s', (value) => {
47
+ const warn = vi.spyOn(console, 'warn').mockImplementation(() => {})
48
+
49
+ expect(toRevalidate(value, KEY)).toBe(false)
50
+ expect(warn).toHaveBeenCalledWith(expect.stringContaining(KEY))
51
+ })
52
+
53
+ it('prints the received value in the warning', () => {
54
+ const warn = vi.spyOn(console, 'warn').mockImplementation(() => {})
55
+
56
+ toRevalidate('300', 'a')
57
+ toRevalidate(Number.NaN, 'b')
58
+ toRevalidate({ seconds: 300 }, 'c')
59
+
60
+ expect(warn).toHaveBeenNthCalledWith(1, expect.stringContaining('"300"'))
61
+ expect(warn).toHaveBeenNthCalledWith(2, expect.stringContaining(': NaN.'))
62
+ expect(warn).toHaveBeenNthCalledWith(
63
+ 3,
64
+ expect.stringContaining('a value of type object')
65
+ )
66
+ })
67
+
68
+ it('does not throw for values JSON.stringify rejects', () => {
69
+ vi.spyOn(console, 'warn').mockImplementation(() => {})
70
+
71
+ const circular: Record<string, unknown> = {}
72
+ circular.self = circular
73
+
74
+ expect(toRevalidate(circular, 'a')).toBe(false)
75
+ expect(toRevalidate({ seconds: BigInt(300) }, 'b')).toBe(false)
76
+ expect(toRevalidate(BigInt(300), 'c')).toBe(false)
77
+ })
78
+
79
+ it('warns about an invalid value once per key', () => {
80
+ const warn = vi.spyOn(console, 'warn').mockImplementation(() => {})
81
+
82
+ toRevalidate('300', KEY)
83
+ toRevalidate('300', KEY)
84
+
85
+ expect(warn).toHaveBeenCalledTimes(1)
86
+ })
87
+
88
+ describe('with a minimum', () => {
89
+ it('raises a lower window to the minimum and warns once', () => {
90
+ const warn = vi.spyOn(console, 'warn').mockImplementation(() => {})
91
+
92
+ expect(toRevalidate(30, KEY, { min: 60 })).toBe(60)
93
+ expect(toRevalidate(30, KEY, { min: 60 })).toBe(60)
94
+ expect(toRevalidate(1, KEY, { min: 60 })).toBe(60)
95
+ expect(warn).toHaveBeenCalledTimes(1)
96
+ expect(warn).toHaveBeenCalledWith(
97
+ `[FastStore] ${KEY} is 30s. Using the minimum of 60s.`
98
+ )
99
+ })
100
+
101
+ it('keeps windows at or above the minimum', () => {
102
+ const warn = vi.spyOn(console, 'warn').mockImplementation(() => {})
103
+
104
+ expect(toRevalidate(60, KEY, { min: 60 })).toBe(60)
105
+ expect(toRevalidate(120, KEY, { min: 60 })).toBe(120)
106
+ expect(warn).not.toHaveBeenCalled()
107
+ })
108
+
109
+ it('still returns false for invalid values', () => {
110
+ vi.spyOn(console, 'warn').mockImplementation(() => {})
111
+
112
+ expect(toRevalidate(0, KEY, { min: 60 })).toBe(false)
113
+ expect(toRevalidate(30.5, 'a', { min: 60 })).toBe(false)
114
+ expect(toRevalidate('30', 'b', { min: 60 })).toBe(false)
115
+ expect(toRevalidate(false, 'c', { min: 60 })).toBe(false)
116
+ })
117
+ })
118
+ })