@faststore/core 3.100.11 → 3.100.12

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.
Files changed (41) hide show
  1. package/.next/BUILD_ID +1 -1
  2. package/.next/build-manifest.json +3 -3
  3. package/.next/cache/.tsbuildinfo +1 -1
  4. package/.next/cache/config.json +3 -3
  5. package/.next/cache/webpack/client-production/0.pack +2 -2
  6. package/.next/cache/webpack/client-production/index.pack +0 -0
  7. package/.next/cache/webpack/edge-server-production/0.pack +0 -0
  8. package/.next/cache/webpack/edge-server-production/index.pack +0 -0
  9. package/.next/cache/webpack/server-production/0.pack +2 -2
  10. package/.next/cache/webpack/server-production/index.pack +0 -0
  11. package/.next/prerender-manifest.js +1 -1
  12. package/.next/prerender-manifest.json +1 -1
  13. package/.next/routes-manifest.json +1 -1
  14. package/.next/server/chunks/3951.js +3 -3
  15. package/.next/server/chunks/870.js +1 -1
  16. package/.next/server/middleware-build-manifest.js +1 -1
  17. package/.next/server/pages/en-US/404.html +2 -2
  18. package/.next/server/pages/en-US/500.html +2 -2
  19. package/.next/server/pages/en-US/checkout.html +2 -2
  20. package/.next/server/pages/en-US/login.html +2 -2
  21. package/.next/server/pages/en-US/password-protection.html +2 -2
  22. package/.next/server/pages/en-US/s.html +2 -2
  23. package/.next/server/pages/en-US.html +2 -2
  24. package/.next/server/pages-manifest.json +1 -1
  25. package/.next/server/src/middleware.js +31 -2
  26. package/.next/server/src/middleware.js.map +1 -1
  27. package/.next/static/chunks/pages/_app-61f81ba19dbd0368.js +1 -0
  28. package/.next/trace +157 -156
  29. package/.turbo/turbo-build.log +18 -18
  30. package/.turbo/turbo-test.log +16 -14
  31. package/CHANGELOG.md +10 -0
  32. package/discovery.config.js +2 -2
  33. package/next.config.js +6 -0
  34. package/package.json +2 -2
  35. package/src/utils/mergeDiscoveryConfig.js +23 -0
  36. package/src/utils/subDomainPrefixWarning.js +46 -0
  37. package/test/utils/mergeDiscoveryConfig.test.ts +72 -0
  38. package/test/utils/subDomainPrefixWarning.test.ts +48 -0
  39. package/.next/static/chunks/pages/_app-35e8dda638ee2672.js +0 -1
  40. /package/.next/static/{9RkfNsnC47XELMQYdVE9f → _aCn9YU2PZBxyogihM2ip}/_buildManifest.js +0 -0
  41. /package/.next/static/{9RkfNsnC47XELMQYdVE9f → _aCn9YU2PZBxyogihM2ip}/_ssgManifest.js +0 -0
@@ -1,23 +1,23 @@
1
1
 
2
- > @faststore/core@3.100.10 prebuild /home/runner/work/faststore/faststore/packages/core
2
+ > @faststore/core@3.100.11 prebuild /home/runner/work/faststore/faststore/packages/core
3
3
  > na run partytown && na run generate
4
4
 
5
5
 
6
- > @faststore/core@3.100.10 partytown /home/runner/work/faststore/faststore/packages/core
6
+ > @faststore/core@3.100.11 partytown /home/runner/work/faststore/faststore/packages/core
7
7
  > partytown copylib ./public/~partytown
8
8
 
9
9
  Partytown lib copied to: /home/runner/work/faststore/faststore/packages/core/public/~partytown
10
10
 
11
- > @faststore/core@3.100.10 generate /home/runner/work/faststore/faststore/packages/core
11
+ > @faststore/core@3.100.11 generate /home/runner/work/faststore/faststore/packages/core
12
12
  > na run generate:schema && na run generate:codegen && na run format:generated
13
13
 
14
14
 
15
- > @faststore/core@3.100.10 generate:schema /home/runner/work/faststore/faststore/packages/core
15
+ > @faststore/core@3.100.11 generate:schema /home/runner/work/faststore/faststore/packages/core
16
16
  > tsx src/server/generator/generateGraphQLSchemaFile.ts
17
17
 
18
18
  Schema GraphQL file generated successfully
19
19
 
20
- > @faststore/core@3.100.10 generate:codegen /home/runner/work/faststore/faststore/packages/core
20
+ > @faststore/core@3.100.11 generate:codegen /home/runner/work/faststore/faststore/packages/core
21
21
  > graphql-codegen
22
22
 
23
23
  [STARTED] Parse Configuration
@@ -37,11 +37,11 @@ Running lifecycle hook "afterStart" scripts...
37
37
  [CLI] Loading Documents
38
38
  [CLI] Generating output
39
39
 
40
- > @faststore/core@3.100.10 format:generated /home/runner/work/faststore/faststore/packages/core
40
+ > @faststore/core@3.100.11 format:generated /home/runner/work/faststore/faststore/packages/core
41
41
  > prettier --write "@generated/**/*.{ts,js,tsx,jsx,json}" --loglevel error
42
42
 
43
43
 
44
- > @faststore/core@3.100.10 build /home/runner/work/faststore/faststore/packages/core
44
+ > @faststore/core@3.100.11 build /home/runner/work/faststore/faststore/packages/core
45
45
  > next build
46
46
 
47
47
  ⚠ No build cache found. Please configure build caching for faster rebuilds. Read more: https://nextjs.org/docs/messages/no-cache
@@ -63,6 +63,7 @@ Browserslist: browsers data (caniuse-lite) is 22 months old. Please run:
63
63
  Why you should do it regularly: https://github.com/browserslist/update-db#readme
64
64
  <w> [webpack.cache.PackFileCacheStrategy] Skipped not serializable cache item 'Compilation/modules|/home/runner/work/faststore/faststore/node_modules/.pnpm/next@13.5.11_@babel+core@7.26.7_@opentelemetry+api@1.4.1_react-dom@18.3.1_react@18.3.1__react@18.3.1_sass@1.83.4/node_modules/next/dist/build/webpack/loaders/css-loader/src/index.js??ruleSet[1].rules[7].oneOf[9].use[1]!/home/runner/work/faststore/faststore/node_modules/.pnpm/next@13.5.11_@babel+core@7.26.7_@opentelemetry+api@1.4.1_react-dom@18.3.1_react@18.3.1__react@18.3.1_sass@1.83.4/node_modules/next/dist/build/webpack/loaders/postcss-loader/src/index.js??ruleSet[1].rules[7].oneOf[9].use[2]!/home/runner/work/faststore/faststore/node_modules/.pnpm/next@13.5.11_@babel+core@7.26.7_@opentelemetry+api@1.4.1_react-dom@18.3.1_react@18.3.1__react@18.3.1_sass@1.83.4/node_modules/next/dist/build/webpack/loaders/resolve-url-loader/index.js??ruleSet[1].rules[7].oneOf[9].use[3]!/home/runner/work/faststore/faststore/node_modules/.pnpm/next@13.5.11_@babel+core@7.26.7_@opentelemetry+api@1.4.1_react-dom@18.3.1_react@18.3.1__react@18.3.1_sass@1.83.4/node_modules/next/dist/compiled/sass-loader/cjs.js??ruleSet[1].rules[7].oneOf[9].use[4]!/home/runner/work/faststore/faststore/packages/core/src/components/common/Toast/section.module.scss': No serializer registered for Warning
65
65
  <w> while serializing webpack/lib/cache/PackFileCacheStrategy.PackContentItems -> webpack/lib/NormalModule -> Array { 1 items } -> webpack/lib/ModuleWarning -> Warning
66
+ Collecting page data ...
66
67
  ⚠ Compiled with warnings
67
68
 
68
69
  ./src/components/common/Toast/section.module.scss.webpack[javascript/auto]!=!../../node_modules/.pnpm/next@13.5.11_@babel+core@7.26.7_@opentelemetry+api@1.4.1_react-dom@18.3.1_react@18.3.1__react@18.3.1_sass@1.83.4/node_modules/next/dist/build/webpack/loaders/css-loader/src/index.js??ruleSet[1].rules[7].oneOf[9].use[1]!../../node_modules/.pnpm/next@13.5.11_@babel+core@7.26.7_@opentelemetry+api@1.4.1_react-dom@18.3.1_react@18.3.1__react@18.3.1_sass@1.83.4/node_modules/next/dist/build/webpack/loaders/postcss-loader/src/index.js??ruleSet[1].rules[7].oneOf[9].use[2]!../../node_modules/.pnpm/next@13.5.11_@babel+core@7.26.7_@opentelemetry+api@1.4.1_react-dom@18.3.1_react@18.3.1__react@18.3.1_sass@1.83.4/node_modules/next/dist/build/webpack/loaders/resolve-url-loader/index.js??ruleSet[1].rules[7].oneOf[9].use[3]!../../node_modules/.pnpm/next@13.5.11_@babel+core@7.26.7_@opentelemetry+api@1.4.1_react-dom@18.3.1_react@18.3.1__react@18.3.1_sass@1.83.4/node_modules/next/dist/compiled/sass-loader/cjs.js??ruleSet[1].rules[7].oneOf[9].use[4]!./src/components/common/Toast/section.module.scss
@@ -83,7 +84,7 @@ Learn more: https://nextjs.org/docs/api-reference/edge-runtime
83
84
 
84
85
  Import trace for requested module:
85
86
  ../../node_modules/.pnpm/jose@6.2.3/node_modules/jose/dist/webapi/lib/deflate.js
86
- ../../node_modules/.pnpm/jose@6.2.3/node_modules/jose/dist/webapi/jwe/flattened/decrypt.js
87
+ ../../node_modules/.pnpm/jose@6.2.3/node_modules/jose/dist/webapi/jwe/flattened/encrypt.js
87
88
  ../../node_modules/.pnpm/jose@6.2.3/node_modules/jose/dist/webapi/index.js
88
89
  ./src/server/password-protection-service.ts
89
90
 
@@ -93,11 +94,10 @@ Learn more: https://nextjs.org/docs/api-reference/edge-runtime
93
94
 
94
95
  Import trace for requested module:
95
96
  ../../node_modules/.pnpm/jose@6.2.3/node_modules/jose/dist/webapi/lib/deflate.js
96
- ../../node_modules/.pnpm/jose@6.2.3/node_modules/jose/dist/webapi/jwe/flattened/decrypt.js
97
+ ../../node_modules/.pnpm/jose@6.2.3/node_modules/jose/dist/webapi/jwe/flattened/encrypt.js
97
98
  ../../node_modules/.pnpm/jose@6.2.3/node_modules/jose/dist/webapi/index.js
98
99
  ./src/server/password-protection-service.ts
99
100
 
100
- Collecting page data ...
101
101
  Generating static pages (0/8) ...
102
102
 
103
103
  Generating static pages (2/8)
104
104
  Search not found. Add a new component for this section or remove it from the CMS
@@ -114,11 +114,11 @@ Search not found. Add a new component for this section or remove it from the CMS
114
114
  Collecting build traces ...
115
115
 
116
116
  Route (pages) Size First Load JS
117
- ┌ ● / 7.38 kB 165 kB
117
+ ┌ ● / 7.38 kB 166 kB
118
118
  ├ └ css/02259c549b2179f2.css 3.1 kB
119
119
  ├ /_app 0 B 109 kB
120
120
  ├ ● /[...slug] 2.55 kB 175 kB
121
- ├ ● /[slug]/p 97.3 kB 255 kB
121
+ ├ ● /[slug]/p 97.3 kB 256 kB
122
122
  ├ ├ css/1c4983f11b861ea0.css 6.34 kB
123
123
  ├ └ css/54cedf4b65e5863f.css 16.7 kB
124
124
  ├ ○ /404 1.58 kB 160 kB
@@ -131,10 +131,10 @@ Route (pages) Size First Load JS
131
131
  ├ λ /api/preview 0 B 109 kB
132
132
  ├ ● /checkout 750 B 159 kB
133
133
  ├ ● /login 1.7 kB 160 kB
134
- ├ ○ /password-protection 2.18 kB 111 kB
134
+ ├ ○ /password-protection 2.18 kB 112 kB
135
135
  ├ └ css/033b9397a0c0cf71.css 3.2 kB
136
- ├ λ /pvt/account 247 B 109 kB
137
- ├ ● /pvt/account/[...unknown] 287 B 109 kB
136
+ ├ λ /pvt/account 247 B 110 kB
137
+ ├ ● /pvt/account/[...unknown] 287 B 110 kB
138
138
  ├ λ /pvt/account/403 3 kB 161 kB
139
139
  ├ └ css/6819dddf2b1b5ea7.css 4.84 kB
140
140
  ├ λ /pvt/account/404 2.18 kB 160 kB
@@ -150,14 +150,14 @@ Route (pages) Size First Load JS
150
150
  ├ λ /pvt/account/user-details 1.91 kB 160 kB
151
151
  ├ └ css/16d65422bfa80f51.css 4.7 kB
152
152
  └ ● /s 3.44 kB 176 kB
153
- + First Load JS shared by all 118 kB
153
+ + First Load JS shared by all 119 kB
154
154
  ├ chunks/framework-d514426edf885c68.js 45.4 kB
155
155
  ├ chunks/main-a2d1cfe626f2fef1.js 33.4 kB
156
- ├ chunks/pages/_app-35e8dda638ee2672.js 26.6 kB
156
+ ├ chunks/pages/_app-61f81ba19dbd0368.js 26.7 kB
157
157
  ├ chunks/webpack-62bcb2a452e15476.js 3.9 kB
158
158
  └ css/146a8678babc61bf.css 9.2 kB
159
159
 
160
- ƒ Middleware 44.8 kB
160
+ ƒ Middleware 45.1 kB
161
161
 
162
162
  λ (Server) server-side renders at runtime (uses getInitialProps or getServerSideProps)
163
163
  ○ (Static) automatically rendered as static HTML (uses no initial props)
@@ -1,16 +1,15 @@
1
1
 
2
- > @faststore/core@3.100.10 test /home/runner/work/faststore/faststore/packages/core
2
+ > @faststore/core@3.100.11 test /home/runner/work/faststore/faststore/packages/core
3
3
  > jest
4
4
 
5
- PASS test/utils/cookieCacheBusting.test.ts (10.073 s)
6
- PASS test/server/password-protection-service.test.ts (12.538 s)
7
- PASS test/server/content/service.test.ts (12.882 s)
8
- PASS test/utils/multipleTemplates.test.ts
5
+ PASS test/server/content/service.test.ts (18.595 s)
6
+ PASS test/utils/cookieCacheBusting.test.ts (16.87 s)
7
+ PASS test/server/password-protection-service.test.ts (19.254 s)
9
8
  PASS test/utils/clearCookies.test.ts
10
- PASS test/server/cms/index.test.ts
9
+ PASS test/utils/multipleTemplates.test.ts
10
+ PASS test/server/cms/index.test.ts (6.111 s)
11
11
  PASS test/server/content/promiseCache.test.ts
12
- PASS test/sdk/redirects/index.test.ts
13
- PASS test/components/templates/SearchPage/SearchWrapper.browser.test.tsx (5.665 s)
12
+ PASS test/components/templates/SearchPage/SearchWrapper.browser.test.tsx (8.797 s)
14
13
  ● Console
15
14
 
16
15
  console.error
@@ -40,15 +39,18 @@ PASS test/components/templates/SearchPage/SearchWrapper.browser.test.tsx (5.665
40
39
  at Object.<anonymous>.__awaiter (test/components/templates/SearchPage/SearchWrapper.browser.test.tsx:15:12)
41
40
  at Object.<anonymous> (test/components/templates/SearchPage/SearchWrapper.browser.test.tsx:110:65)
42
41
 
42
+ PASS test/sdk/redirects/index.test.ts
43
43
  PASS test/utils/trustedForwardedHost.test.ts
44
- PASS test/utils/validateSessionRefreshToken.test.ts
45
44
  PASS test/server/cms/global.test.ts
46
- PASS test/utils/isLocalHost.browser.test.ts
45
+ PASS test/server/index.test.ts (10.516 s)
46
+ PASS test/utils/mergeDiscoveryConfig.test.ts
47
+ PASS test/utils/validateSessionRefreshToken.test.ts
48
+ PASS test/utils/subDomainPrefixWarning.test.ts
47
49
  PASS test/utils/isLocalHost.test.ts
48
- PASS test/server/index.test.ts
50
+ PASS test/utils/isLocalHost.browser.test.ts
49
51
 
50
- Test Suites: 15 passed, 15 total
51
- Tests: 165 passed, 165 total
52
+ Test Suites: 17 passed, 17 total
53
+ Tests: 179 passed, 179 total
52
54
  Snapshots: 0 total
53
- Time: 20.318 s
55
+ Time: 33.784 s
54
56
  Ran all test suites.
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
+ ## [3.100.12](https://github.com/vtex/faststore/compare/v3.100.11...v3.100.12) (2026-11-09)
7
+
8
+ ### Bug Fixes
9
+
10
+ - **core:** let the store config override api.subDomainPrefix ([3a7fc56](https://github.com/vtex/faststore/commit/3a7fc56c82d948a96cf7caaf30ceeeb9e06a2f17))
11
+ - **core:** move the subDomainPrefix warning to its own module ([1089003](https://github.com/vtex/faststore/commit/1089003c5ec4e02b49e9d5517debb970dde20d36))
12
+ - **core:** only let an empty subDomainPrefix replace the default ([ad9569a](https://github.com/vtex/faststore/commit/ad9569a1136b3ce1d8cc424d1ea81d823bda9805))
13
+ - **core:** scope the subDomainPrefix override to api and warn on invalid URLs ([a364048](https://github.com/vtex/faststore/commit/a364048def174f2a987ed4cef5571272cdfaf9ce))
14
+ - **core:** use a Set for the overridden discovery config keys ([48e1db6](https://github.com/vtex/faststore/commit/48e1db6b5c20783f99a1ccf421d12b602476a8b1))
15
+
6
16
  ## [3.100.11](https://github.com/vtex/faststore/compare/v3.100.10...v3.100.11) (2026-11-05)
7
17
 
8
18
  ### Bug Fixes
@@ -1,11 +1,11 @@
1
1
  const defaultConfig = require('./discovery.config.default')
2
2
  const starterConfig = require('./src/customizations/discovery.config')
3
3
 
4
- const deepmerge = require('deepmerge')
4
+ const { mergeDiscoveryConfig } = require('./src/utils/mergeDiscoveryConfig')
5
5
 
6
6
  /**
7
7
  * @type {typeof defaultConfig & Record<string, any>}
8
8
  * */
9
- const finalConfig = deepmerge(defaultConfig, starterConfig)
9
+ const finalConfig = mergeDiscoveryConfig(defaultConfig, starterConfig)
10
10
 
11
11
  module.exports = finalConfig
package/next.config.js CHANGED
@@ -1,6 +1,12 @@
1
1
  // @ts-check
2
2
  const path = require('path')
3
3
  const storeConfig = require('./discovery.config')
4
+ const {
5
+ getSubDomainPrefixWarning,
6
+ } = require('./src/utils/subDomainPrefixWarning')
7
+
8
+ const subDomainPrefixWarning = getSubDomainPrefixWarning(storeConfig)
9
+ if (subDomainPrefixWarning) console.warn(subDomainPrefixWarning)
4
10
 
5
11
  /**
6
12
  * @type {import('next').NextConfig}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@faststore/core",
3
- "version": "3.100.11",
3
+ "version": "3.100.12",
4
4
  "license": "MIT",
5
5
  "repository": {
6
6
  "type": "git",
@@ -128,5 +128,5 @@
128
128
  "ts-jest": "29.1.1",
129
129
  "typescript": "5.3.2"
130
130
  },
131
- "gitHead": "f3c857fbeeafcc49f3c25372a4dd55ec5709d5a5"
131
+ "gitHead": "4cc55e7845f8a3f70de376dac5c5e16877ee5489"
132
132
  }
@@ -0,0 +1,23 @@
1
+ const deepmerge = require('deepmerge')
2
+
3
+ /**
4
+ * Merges discovery configs like `deepmerge`, except that an empty
5
+ * `api.subDomainPrefix` replaces the default instead of being appended to it.
6
+ *
7
+ * deepmerge concatenates arrays, so the default `['www']` is always kept. An
8
+ * empty array is how a store asks for no prefix to be stripped from the host
9
+ * sent to Checkout. Any other value is still appended to the default, as
10
+ * before, to keep the current behavior of existing stores.
11
+ */
12
+ function mergeDiscoveryConfig(target, source) {
13
+ const merged = deepmerge(target, source)
14
+ const subDomainPrefix = source?.api?.subDomainPrefix
15
+
16
+ if (Array.isArray(subDomainPrefix) && subDomainPrefix.length === 0) {
17
+ merged.api.subDomainPrefix = []
18
+ }
19
+
20
+ return merged
21
+ }
22
+
23
+ module.exports = { mergeDiscoveryConfig }
@@ -0,0 +1,46 @@
1
+ const getHostname = (url) => {
2
+ try {
3
+ return new URL(url).hostname
4
+ } catch {
5
+ return undefined
6
+ }
7
+ }
8
+
9
+ /**
10
+ * With `api.subDomainPrefix: []`, Checkout cookies are set on the storefront
11
+ * host only, so a checkout served from another host (`secureSubdomain`) does
12
+ * not receive them. Returns a warning for that setup, or `undefined`.
13
+ */
14
+ function getSubDomainPrefixWarning(config) {
15
+ const prefixes = config?.api?.subDomainPrefix
16
+
17
+ if (!Array.isArray(prefixes) || prefixes.length > 0) {
18
+ return undefined
19
+ }
20
+
21
+ const invalidUrls = ['storeUrl', 'secureSubdomain'].filter(
22
+ (key) => config[key] && !getHostname(config[key])
23
+ )
24
+
25
+ if (invalidUrls.length > 0) {
26
+ return (
27
+ `[FastStore] api.subDomainPrefix is [], but ${invalidUrls.join(' and ')} could not be parsed as a URL, ` +
28
+ `so it was not possible to check where Checkout cookies are sent. Use a full URL (e.g. https://www.store.com).`
29
+ )
30
+ }
31
+
32
+ const storeHost = getHostname(config.storeUrl)
33
+ const secureHost = getHostname(config.secureSubdomain)
34
+
35
+ if (!storeHost || !secureHost || storeHost === secureHost) {
36
+ return undefined
37
+ }
38
+
39
+ return (
40
+ `[FastStore] api.subDomainPrefix is [], so Checkout cookies are set on ${storeHost} only ` +
41
+ `and are not sent to the secureSubdomain (${secureHost}). If the checkout runs on ${secureHost}, ` +
42
+ `remove api.subDomainPrefix or set it to the prefixes to strip (e.g. ['www']).`
43
+ )
44
+ }
45
+
46
+ module.exports = { getSubDomainPrefixWarning }
@@ -0,0 +1,72 @@
1
+ import defaultConfig from '../../discovery.config.default'
2
+ import { mergeDiscoveryConfig } from '../../src/utils/mergeDiscoveryConfig'
3
+
4
+ describe('mergeDiscoveryConfig', () => {
5
+ describe('api.subDomainPrefix', () => {
6
+ it('keeps the default when the store does not set it', () => {
7
+ const config = mergeDiscoveryConfig(defaultConfig, {
8
+ api: { storeId: 'store' },
9
+ })
10
+
11
+ expect(config.api.subDomainPrefix).toEqual(['www'])
12
+ })
13
+
14
+ it('lets the store clear the prefixes with an empty array', () => {
15
+ const config = mergeDiscoveryConfig(defaultConfig, {
16
+ api: { subDomainPrefix: [] },
17
+ })
18
+
19
+ expect(config.api.subDomainPrefix).toEqual([])
20
+ })
21
+
22
+ it('keeps appending non-empty arrays to the default', () => {
23
+ const config = mergeDiscoveryConfig(defaultConfig, {
24
+ api: { subDomainPrefix: ['shop'] },
25
+ })
26
+
27
+ expect(config.api.subDomainPrefix).toEqual(['www', 'shop'])
28
+ })
29
+
30
+ it('applies to every merge in the chain', () => {
31
+ const storeConfig = mergeDiscoveryConfig(defaultConfig, {
32
+ api: { subDomainPrefix: ['shop'] },
33
+ })
34
+ const config = mergeDiscoveryConfig(storeConfig, {
35
+ api: { subDomainPrefix: [] },
36
+ })
37
+
38
+ expect(config.api.subDomainPrefix).toEqual([])
39
+ })
40
+ })
41
+
42
+ it('keeps merging the other api fields', () => {
43
+ const config = mergeDiscoveryConfig(defaultConfig, {
44
+ api: { storeId: 'store', subDomainPrefix: [] },
45
+ })
46
+
47
+ expect(config.api.storeId).toBe('store')
48
+ expect(config.api.environment).toBe(defaultConfig.api.environment)
49
+ })
50
+
51
+ it('keeps concatenating the other arrays', () => {
52
+ const config = mergeDiscoveryConfig({ list: ['a'] }, { list: [] })
53
+
54
+ expect(config.list).toEqual(['a'])
55
+ })
56
+
57
+ it('only clears subDomainPrefix under api', () => {
58
+ const config = mergeDiscoveryConfig(
59
+ { api: { subDomainPrefix: ['www'] }, other: { subDomainPrefix: ['a'] } },
60
+ { api: { subDomainPrefix: [] }, other: { subDomainPrefix: [] } }
61
+ )
62
+
63
+ expect(config.api.subDomainPrefix).toEqual([])
64
+ expect(config.other.subDomainPrefix).toEqual(['a'])
65
+ })
66
+
67
+ it('does not mutate the default config', () => {
68
+ mergeDiscoveryConfig(defaultConfig, { api: { subDomainPrefix: [] } })
69
+
70
+ expect(defaultConfig.api.subDomainPrefix).toEqual(['www'])
71
+ })
72
+ })
@@ -0,0 +1,48 @@
1
+ import { getSubDomainPrefixWarning } from '../../src/utils/subDomainPrefixWarning'
2
+
3
+ describe('getSubDomainPrefixWarning', () => {
4
+ const store = (
5
+ subDomainPrefix: string[] | undefined,
6
+ secureSubdomain: string,
7
+ storeUrl = 'https://www.store.com'
8
+ ) => ({ storeUrl, secureSubdomain, api: { subDomainPrefix } })
9
+
10
+ it('warns when the prefixes are cleared and checkout is on another host', () => {
11
+ expect(
12
+ getSubDomainPrefixWarning(store([], 'https://secure.store.com'))
13
+ ).toContain('secure.store.com')
14
+ })
15
+
16
+ it('does not warn when checkout is on the storefront host', () => {
17
+ expect(
18
+ getSubDomainPrefixWarning(store([], 'https://www.store.com'))
19
+ ).toBeUndefined()
20
+ })
21
+
22
+ it('does not warn when the store keeps any prefix', () => {
23
+ expect(
24
+ getSubDomainPrefixWarning(store(['www'], 'https://secure.store.com'))
25
+ ).toBeUndefined()
26
+ expect(
27
+ getSubDomainPrefixWarning(store(undefined, 'https://secure.store.com'))
28
+ ).toBeUndefined()
29
+ })
30
+
31
+ it('does not warn when secureSubdomain is not set', () => {
32
+ expect(getSubDomainPrefixWarning(store([], ''))).toBeUndefined()
33
+ })
34
+
35
+ it('warns when secureSubdomain is not a valid URL', () => {
36
+ expect(getSubDomainPrefixWarning(store([], 'secure.store.com'))).toContain(
37
+ 'secureSubdomain could not be parsed'
38
+ )
39
+ })
40
+
41
+ it('warns when storeUrl is not a valid URL', () => {
42
+ expect(
43
+ getSubDomainPrefixWarning(
44
+ store([], 'https://secure.store.com', 'www.store.com')
45
+ )
46
+ ).toContain('storeUrl could not be parsed')
47
+ })
48
+ })