@faststore/core 4.9.1-dev.0 → 4.9.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/.turbo/turbo-generate.log +3 -3
- package/.turbo/turbo-test.log +158 -144
- package/@generated/graphql.ts +1 -1
- package/@generated/schema.graphql +1 -1
- package/CHANGELOG.md +10 -2
- package/package.json +6 -6
- package/src/components/region/RegionModal/RegionModal.tsx +1 -1
- package/src/components/region/RegionModal/useRegion.ts +3 -2
- package/src/components/region/RegionPopover/RegionPopover.tsx +1 -1
- package/src/components/region/RegionSlider/RegionSlider.tsx +1 -1
- package/src/pages/[slug]/p.tsx +7 -6
- package/src/sdk/account/useReorder.ts +2 -2
- package/src/sdk/cart/index.ts +8 -2
- package/src/sdk/session/index.ts +19 -19
- package/src/sdk/session/toSessionInput.ts +27 -0
- package/src/utils/productJsonLd.ts +100 -1
- package/test/components/region/useRegion.browser.test.ts +64 -0
- package/test/sdk/session/sessionStore.browser.test.ts +63 -0
- package/test/sdk/session/toSessionInput.test.ts +43 -0
- package/test/sdk/session/validateSession.browser.test.ts +47 -0
- package/test/utils/productJsonLd.test.ts +101 -1
- package/test/utils/productJsonLdRendering.test.tsx +24 -4
|
@@ -1,14 +1,17 @@
|
|
|
1
1
|
import { ProductJsonLd } from 'next-seo'
|
|
2
2
|
import { renderToStaticMarkup } from 'react-dom/server'
|
|
3
3
|
import { describe, expect, it } from 'vitest'
|
|
4
|
-
import {
|
|
4
|
+
import {
|
|
5
|
+
toProductJsonLdIdentifiers,
|
|
6
|
+
toProductJsonLdOffer,
|
|
7
|
+
} from '../../src/utils/productJsonLd'
|
|
5
8
|
|
|
6
9
|
/**
|
|
7
10
|
* Pins the next-seo behaviour the PDP's JSON-LD depends on.
|
|
8
11
|
*
|
|
9
|
-
* `p.tsx` omits `mpn`, `gtin` and `releaseDate`
|
|
10
|
-
* than passing empty strings, and drops
|
|
11
|
-
* choices only work because of how next-seo builds the script — it forwards
|
|
12
|
+
* `p.tsx` omits empty `mpn`, `gtin` and `releaseDate` (via
|
|
13
|
+
* `toProductJsonLdIdentifiers`) rather than passing empty strings, and drops
|
|
14
|
+
* `seller` from the offer allowlist. Both choices only work because of how next-seo builds the script — it forwards
|
|
12
15
|
* unknown props untouched (so `""` would be published) and turns any truthy
|
|
13
16
|
* `seller` into an `Organization`, even when it has no name. A next-seo upgrade
|
|
14
17
|
* that changed either would silently reintroduce the defects from ticket
|
|
@@ -71,4 +74,21 @@ describe('next-seo ProductJsonLd contract', () => {
|
|
|
71
74
|
url: 'https://store.example/p',
|
|
72
75
|
})
|
|
73
76
|
})
|
|
77
|
+
|
|
78
|
+
// `p.tsx` spreads `toProductJsonLdIdentifiers(product)` into ProductJsonLd,
|
|
79
|
+
// and `StoreProduct.releaseDate` is the raw upstream epoch. This pins what
|
|
80
|
+
// actually lands in the published script for that input.
|
|
81
|
+
it('publishes an epoch releaseDate as an ISO calendar date', () => {
|
|
82
|
+
const jsonLd = renderJsonLd(
|
|
83
|
+
toProductJsonLdIdentifiers({
|
|
84
|
+
gtin: '',
|
|
85
|
+
mpn: '',
|
|
86
|
+
releaseDate: '1774224000000',
|
|
87
|
+
})
|
|
88
|
+
)
|
|
89
|
+
|
|
90
|
+
expect(jsonLd.releaseDate).toBe('2026-03-23')
|
|
91
|
+
expect(jsonLd).not.toHaveProperty('gtin')
|
|
92
|
+
expect(jsonLd).not.toHaveProperty('mpn')
|
|
93
|
+
})
|
|
74
94
|
})
|