fontdue-js 3.14.0 → 3.15.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.
- package/CHANGELOG.md +9 -0
- package/dist/__generated__/CartOrderCompleteOrderMutation.graphql.d.ts +1 -1
- package/dist/__generated__/CartOrderCompleteOrderMutation.graphql.js +3 -3
- package/dist/__generated__/CartOrderRemoveDiscountMutation.graphql.d.ts +1 -1
- package/dist/__generated__/CartOrderRemoveDiscountMutation.graphql.js +3 -3
- package/dist/__generated__/CartOrderUpdateMutation.graphql.d.ts +1 -1
- package/dist/__generated__/CartOrderUpdateMutation.graphql.js +3 -3
- package/dist/__generated__/CartQuery.graphql.d.ts +1 -1
- package/dist/__generated__/CartQuery.graphql.js +3 -3
- package/dist/__generated__/CartStateUpdateMutation.graphql.d.ts +5 -1
- package/dist/__generated__/CartStateUpdateMutation.graphql.js +132 -117
- package/dist/__generated__/CartState_order.graphql.d.ts +4 -1
- package/dist/__generated__/CartState_order.graphql.js +11 -2
- package/dist/__generated__/CheckoutUpdateCustomerMutation.graphql.d.ts +1 -1
- package/dist/__generated__/CheckoutUpdateCustomerMutation.graphql.js +3 -3
- package/dist/__generated__/CheckoutUpdateOrderMutation.graphql.d.ts +1 -1
- package/dist/__generated__/CheckoutUpdateOrderMutation.graphql.js +3 -3
- package/dist/__generated__/FamilyList_node.graphql.d.ts +3 -1
- package/dist/__generated__/FamilyList_node.graphql.js +8 -2
- package/dist/__generated__/FontFamiliesQuery.graphql.d.ts +1 -1
- package/dist/__generated__/FontFamiliesQuery.graphql.js +5 -5
- package/dist/__generated__/PrecartAddToCartMutation.graphql.d.ts +1 -1
- package/dist/__generated__/PrecartAddToCartMutation.graphql.js +3 -3
- package/dist/__generated__/StoreModalCartQuery.graphql.d.ts +1 -1
- package/dist/__generated__/StoreModalCartQuery.graphql.js +69 -69
- package/dist/__generated__/StoreModalFamily_collection.graphql.d.ts +2 -1
- package/dist/__generated__/StoreModalFamily_collection.graphql.js +16 -15
- package/dist/__generated__/StoreModalIndexItem_fontCollection.graphql.d.ts +19 -1
- package/dist/__generated__/StoreModalIndexItem_fontCollection.graphql.js +39 -4
- package/dist/__generated__/StoreModalIndexPaginationQuery.graphql.d.ts +1 -1
- package/dist/__generated__/StoreModalIndexPaginationQuery.graphql.js +40 -5
- package/dist/__generated__/StoreModalIndexQuery.graphql.d.ts +1 -1
- package/dist/__generated__/StoreModalIndexQuery.graphql.js +40 -5
- package/dist/__generated__/StoreModalProductContent_collection.graphql.d.ts +19 -1
- package/dist/__generated__/StoreModalProductContent_collection.graphql.js +46 -11
- package/dist/__generated__/StoreModalProductQuery.graphql.d.ts +1 -1
- package/dist/__generated__/StoreModalProductQuery.graphql.js +198 -167
- package/dist/__generated__/StoreModalProductRefetchQuery.graphql.d.ts +1 -1
- package/dist/__generated__/StoreModalProductRefetchQuery.graphql.js +171 -140
- package/dist/__generated__/StoreModalProductSlugQuery.graphql.d.ts +1 -1
- package/dist/__generated__/StoreModalProductSlugQuery.graphql.js +201 -170
- package/dist/__generated__/StripeProviderCreateCheckoutSessionMutation.graphql.d.ts +5 -2
- package/dist/__generated__/StripeProviderCreateCheckoutSessionMutation.graphql.js +41 -22
- package/dist/__generated__/TestFontsFormUpdateCustomerMutation.graphql.d.ts +1 -1
- package/dist/__generated__/TestFontsFormUpdateCustomerMutation.graphql.js +3 -3
- package/dist/__generated__/TypeTesterStandaloneChangedStylesQuery.graphql.d.ts +1 -1
- package/dist/__generated__/TypeTesterStandaloneChangedStylesQuery.graphql.js +9 -3
- package/dist/__generated__/TypeTesterStandaloneQuery.graphql.d.ts +1 -1
- package/dist/__generated__/TypeTesterStandaloneQuery.graphql.js +9 -3
- package/dist/__generated__/TypeTester_fontStyle.graphql.d.ts +3 -1
- package/dist/__generated__/TypeTester_fontStyle.graphql.js +8 -2
- package/dist/__generated__/TypeTestersChangedStylesQuery.graphql.d.ts +1 -1
- package/dist/__generated__/TypeTestersChangedStylesQuery.graphql.js +9 -3
- package/dist/__generated__/TypeTestersIDQuery.graphql.d.ts +1 -1
- package/dist/__generated__/TypeTestersIDQuery.graphql.js +39 -39
- package/dist/__generated__/TypeTestersRefetchQuery.graphql.d.ts +1 -1
- package/dist/__generated__/TypeTestersRefetchQuery.graphql.js +37 -37
- package/dist/__generated__/TypeTestersSlugQuery.graphql.d.ts +1 -1
- package/dist/__generated__/TypeTestersSlugQuery.graphql.js +39 -39
- package/dist/__tests__/cartDiscountRemoved.test.js +195 -0
- package/dist/__tests__/characterViewerCollapse.test.js +199 -0
- package/dist/__tests__/characterViewerStyleSelect.test.js +52 -0
- package/dist/__tests__/checkoutReturn.test.js +66 -0
- package/dist/__tests__/familyStyleCounts.test.js +71 -0
- package/dist/__tests__/i18n.test.js +171 -0
- package/dist/__tests__/i18nComponents.test.js +408 -0
- package/dist/__tests__/localeEnvironments.test.js +275 -0
- package/dist/__tests__/localeMiddleware.test.js +68 -0
- package/dist/__tests__/localeTransport.test.js +209 -0
- package/dist/__tests__/recaptchaLocale.test.js +62 -0
- package/dist/__tests__/serverEntryLocale.test.js +124 -0
- package/dist/__tests__/storeModalIndexUnlisted.test.js +69 -11
- package/dist/__tests__/useSerializablePreloadedQuery.test.js +4 -3
- package/dist/components/AddToCartBanner/index.js +8 -2
- package/dist/components/BuyButton/index.d.ts +1 -0
- package/dist/components/BuyButton/index.js +8 -2
- package/dist/components/BuyButton/index.server.d.ts +1 -0
- package/dist/components/BuyButton/index.server.js +8 -0
- package/dist/components/BuyingOptions/index.js +3 -1
- package/dist/components/Cart/AddressFields.js +5 -3
- package/dist/components/Cart/CartCouponNotice.d.ts +7 -0
- package/dist/components/Cart/CartCouponNotice.js +21 -0
- package/dist/components/Cart/CartItem/CartItemAdditionalLicenses.js +3 -1
- package/dist/components/Cart/CartItem/CartItemLicense.js +3 -1
- package/dist/components/Cart/CartItem/CartItemProduct.js +6 -3
- package/dist/components/Cart/CartItem/VariableTextInput.js +7 -3
- package/dist/components/Cart/CartItem/index.js +5 -1
- package/dist/components/Cart/CartOrder.js +27 -17
- package/dist/components/Cart/CartState.d.ts +1 -0
- package/dist/components/Cart/CartState.js +18 -3
- package/dist/components/Cart/CartTotals.js +17 -9
- package/dist/components/Cart/Checkout.js +18 -15
- package/dist/components/Cart/CouponCodeInput.js +5 -3
- package/dist/components/Cart/CustomerFields.js +6 -4
- package/dist/components/Cart/EmptyCart.js +4 -2
- package/dist/components/Cart/IdentityBox.js +6 -2
- package/dist/components/Cart/ShareCart.js +8 -6
- package/dist/components/Cart/checkoutReturn.d.ts +17 -0
- package/dist/components/Cart/checkoutReturn.js +38 -0
- package/dist/components/CartButton/index.d.ts +2 -1
- package/dist/components/CartButton/index.js +6 -2
- package/dist/components/CharacterViewer/StyleSelect.js +6 -2
- package/dist/components/CharacterViewer/collapse.d.ts +10 -0
- package/dist/components/CharacterViewer/collapse.js +39 -0
- package/dist/components/CharacterViewer/index.d.ts +4 -0
- package/dist/components/CharacterViewer/index.js +78 -24
- package/dist/components/CharacterViewer/index.server.d.ts +1 -0
- package/dist/components/CharacterViewer/index.server.js +4 -0
- package/dist/components/ConfigContext.d.ts +14 -10
- package/dist/components/ConfigContext.js +12 -7
- package/dist/components/ConsentBanner/index.js +6 -5
- package/dist/components/CookieNotification/index.js +11 -5
- package/dist/components/CouponText/index.js +15 -7
- package/dist/components/CustomerLoginForm/index.js +14 -9
- package/dist/components/CustomerSignIn/CustomerSignInElement.d.ts +1 -1
- package/dist/components/CustomerSignIn/CustomerSignInElement.js +8 -2
- package/dist/components/CustomerSignIn/index.d.ts +6 -1
- package/dist/components/CustomerSignIn/index.js +27 -15
- package/dist/components/Family/FamilyList.js +5 -2
- package/dist/components/Family/index.js +21 -12
- package/dist/components/FeatureTester/FeatureTesters.d.ts +2 -1
- package/dist/components/FeatureTester/FeatureTesters.js +4 -1
- package/dist/components/FeatureTester/FeatureTesters.server.js +4 -0
- package/dist/components/FeatureTester/index.d.ts +1 -0
- package/dist/components/FeatureTester/index.js +3 -1
- package/dist/components/FeatureTester/index.server.js +2 -0
- package/dist/components/FontdueContextProvider/index.d.ts +12 -2
- package/dist/components/FontdueContextProvider/index.js +85 -11
- package/dist/components/FontdueProvider/index.js +7 -1
- package/dist/components/FontdueProvider/index.server.js +21 -3
- package/dist/components/LocaleContext.d.ts +9 -0
- package/dist/components/LocaleContext.js +20 -0
- package/dist/components/NewsletterSignup/index.d.ts +2 -1
- package/dist/components/NewsletterSignup/index.js +20 -11
- package/dist/components/NewsletterSignup/index.server.d.ts +1 -0
- package/dist/components/NewsletterSignup/index.server.js +3 -1
- package/dist/components/NodePasswordForm/index.d.ts +6 -1
- package/dist/components/NodePasswordForm/index.js +14 -6
- package/dist/components/OrderVariableSelection/index.js +7 -5
- package/dist/components/Precart/License.js +4 -2
- package/dist/components/Precart/index.js +15 -12
- package/dist/components/Price/index.d.ts +1 -0
- package/dist/components/Price/index.js +15 -5
- package/dist/components/Root/index.js +2 -1
- package/dist/components/Select/index.d.ts +1 -1
- package/dist/components/Select/index.js +4 -1
- package/dist/components/SelectButton/index.js +3 -1
- package/dist/components/SpecimenLink/index.js +3 -1
- package/dist/components/StoreModal/StoreModalCart.js +6 -0
- package/dist/components/StoreModal/StoreModalContainer.js +14 -12
- package/dist/components/StoreModal/StoreModalDownload.js +3 -1
- package/dist/components/StoreModal/StoreModalFamily.js +16 -7
- package/dist/components/StoreModal/StoreModalFamilyButton.js +14 -9
- package/dist/components/StoreModal/StoreModalIndexItem.js +21 -10
- package/dist/components/StoreModal/StoreModalIndexPackItem.js +8 -3
- package/dist/components/StoreModal/StoreModalPackButton.js +5 -2
- package/dist/components/StoreModal/StoreModalProduct.js +14 -5
- package/dist/components/StoreModal/index.d.ts +1 -0
- package/dist/components/StoreModal/index.js +4 -2
- package/dist/components/StoreModal/offered.d.ts +31 -0
- package/dist/components/StoreModal/offered.js +21 -0
- package/dist/components/StoreModal/types.d.ts +9 -0
- package/dist/components/StoreModalProductLicenseSelection/LicenseVariableElement.js +3 -1
- package/dist/components/StoreModalProductLicenseSelection/StoreModalProductLicense.js +5 -1
- package/dist/components/StoreModalProductSummary/index.js +37 -23
- package/dist/components/StripeProvider/index.js +18 -5
- package/dist/components/TestFontsForm/index.d.ts +2 -1
- package/dist/components/TestFontsForm/index.js +28 -16
- package/dist/components/TestFontsForm/index.server.d.ts +1 -0
- package/dist/components/TestFontsForm/index.server.js +3 -1
- package/dist/components/TestModeBanner/index.js +3 -1
- package/dist/components/TypeTester/TypeTesterEditAll.js +3 -1
- package/dist/components/TypeTester/TypeTesterFeaturesButton.js +4 -2
- package/dist/components/TypeTester/TypeTesterStandalone.d.ts +1 -0
- package/dist/components/TypeTester/TypeTesterStandalone.js +6 -2
- package/dist/components/TypeTester/TypeTesterStandalone.server.js +2 -0
- package/dist/components/TypeTester/TypeTesterStyleSelect.js +5 -3
- package/dist/components/TypeTester/TypeTesterStyleSelectData.js +3 -1
- package/dist/components/TypeTester/TypeTesterToolbar.js +12 -6
- package/dist/components/TypeTester/index.js +7 -2
- package/dist/components/TypeTesters/index.d.ts +2 -1
- package/dist/components/TypeTesters/index.js +3 -1
- package/dist/components/TypeTesters/index.server.d.ts +1 -0
- package/dist/components/TypeTesters/index.server.js +4 -0
- package/dist/components/elements/EmptyCart/index.js +4 -2
- package/dist/components/elements/StoreModalCartLayout/index.d.ts +1 -0
- package/dist/components/elements/StoreModalCartLayout/index.js +2 -1
- package/dist/components/elements/StoreModalContainer/index.js +4 -2
- package/dist/components/elements/StoreModalDownloadLayout/index.js +3 -1
- package/dist/components/elements/StoreModalIndexItem/index.js +3 -1
- package/dist/components/elements/StoreModalIndexLoadMore/index.js +3 -1
- package/dist/components/elements/StoreModalLicenseeIsBillingIdentityElement.js +4 -2
- package/dist/components/elements/StoreModalLoadingScreen/index.js +7 -3
- package/dist/components/elements/StoreModalUnifiedCheckout.js +44 -27
- package/dist/fontdue.css +58 -0
- package/dist/hooks/useRecaptchaTimeout.d.ts +1 -1
- package/dist/hooks/useRecaptchaTimeout.js +4 -2
- package/dist/i18n/de.d.ts +3 -0
- package/dist/i18n/de.js +279 -0
- package/dist/i18n/en.d.ts +212 -0
- package/dist/i18n/en.js +261 -0
- package/dist/i18n/index.d.ts +42 -0
- package/dist/i18n/index.js +115 -0
- package/dist/i18n/types.d.ts +28 -0
- package/dist/i18n/types.js +1 -0
- package/dist/i18n/useT.d.ts +15 -0
- package/dist/i18n/useT.js +21 -0
- package/dist/locale.d.ts +20 -0
- package/dist/locale.js +52 -0
- package/dist/next/tenant.d.ts +3 -1
- package/dist/next/tenant.js +11 -2
- package/dist/relay/environment.d.ts +8 -2
- package/dist/relay/environment.js +65 -15
- package/dist/relay/loadSerializableQuery.d.ts +17 -0
- package/dist/relay/loadSerializableQuery.js +14 -2
- package/dist/relay/serverConfig.d.ts +9 -0
- package/dist/relay/serverConfig.js +16 -0
- package/dist/relay/useSerializablePreloadedQuery.js +27 -6
- package/dist/server/index.d.ts +11 -0
- package/dist/server/index.js +7 -0
- package/dist/server/middleware.d.ts +19 -1
- package/dist/server/middleware.js +56 -13
- package/dist/utils.d.ts +0 -1
- package/dist/utils.js +0 -5
- package/dist/version.js +1 -1
- package/package.json +1 -1
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
/**
|
|
2
|
-
* @generated SignedSource<<
|
|
2
|
+
* @generated SignedSource<<19446261612b5e1306d83e2fefc313b8>>
|
|
3
3
|
* @lightSyntaxTransform
|
|
4
4
|
* @nogrep
|
|
5
5
|
*/
|
|
@@ -50,65 +50,65 @@ const node = function () {
|
|
|
50
50
|
"alias": null,
|
|
51
51
|
"args": null,
|
|
52
52
|
"kind": "ScalarField",
|
|
53
|
-
"name": "
|
|
53
|
+
"name": "visibility",
|
|
54
54
|
"storageKey": null
|
|
55
55
|
},
|
|
56
56
|
v8 = {
|
|
57
57
|
"alias": null,
|
|
58
58
|
"args": null,
|
|
59
59
|
"kind": "ScalarField",
|
|
60
|
-
"name": "
|
|
60
|
+
"name": "name",
|
|
61
61
|
"storageKey": null
|
|
62
62
|
},
|
|
63
63
|
v9 = {
|
|
64
|
+
"alias": null,
|
|
65
|
+
"args": null,
|
|
66
|
+
"kind": "ScalarField",
|
|
67
|
+
"name": "axis",
|
|
68
|
+
"storageKey": null
|
|
69
|
+
},
|
|
70
|
+
v10 = {
|
|
64
71
|
"alias": null,
|
|
65
72
|
"args": null,
|
|
66
73
|
"kind": "ScalarField",
|
|
67
74
|
"name": "value",
|
|
68
75
|
"storageKey": null
|
|
69
76
|
},
|
|
70
|
-
|
|
71
|
-
|
|
77
|
+
v11 = [v9 /*: any*/, v10 /*: any*/],
|
|
78
|
+
v12 = {
|
|
72
79
|
"kind": "Literal",
|
|
73
80
|
"name": "licenseOptions",
|
|
74
81
|
"value": [] /*: any*/
|
|
75
82
|
},
|
|
76
|
-
|
|
83
|
+
v13 = [v12 /*: any*/, {
|
|
77
84
|
"kind": "Literal",
|
|
78
85
|
"name": "orderVariables",
|
|
79
86
|
"value": [] /*: any*/
|
|
80
87
|
}],
|
|
81
|
-
|
|
88
|
+
v14 = {
|
|
82
89
|
"alias": null,
|
|
83
90
|
"args": null,
|
|
84
91
|
"kind": "ScalarField",
|
|
85
92
|
"name": "amount",
|
|
86
93
|
"storageKey": null
|
|
87
94
|
},
|
|
88
|
-
|
|
95
|
+
v15 = [v14 /*: any*/, {
|
|
89
96
|
"alias": null,
|
|
90
97
|
"args": null,
|
|
91
98
|
"kind": "ScalarField",
|
|
92
99
|
"name": "currency",
|
|
93
100
|
"storageKey": null
|
|
94
101
|
}],
|
|
95
|
-
|
|
102
|
+
v16 = {
|
|
96
103
|
"alias": null,
|
|
97
|
-
"args":
|
|
104
|
+
"args": v13 /*: any*/,
|
|
98
105
|
"concreteType": "Money",
|
|
99
106
|
"kind": "LinkedField",
|
|
100
107
|
"name": "price",
|
|
101
108
|
"plural": false,
|
|
102
|
-
"selections":
|
|
109
|
+
"selections": v15 /*: any*/,
|
|
103
110
|
"storageKey": "price(licenseOptions:[],orderVariables:[])"
|
|
104
111
|
},
|
|
105
|
-
v16 = {
|
|
106
|
-
"alias": null,
|
|
107
|
-
"args": null,
|
|
108
|
-
"kind": "ScalarField",
|
|
109
|
-
"name": "visibility",
|
|
110
|
-
"storageKey": null
|
|
111
|
-
},
|
|
112
112
|
v17 = {
|
|
113
113
|
"alias": null,
|
|
114
114
|
"args": null,
|
|
@@ -123,14 +123,14 @@ const node = function () {
|
|
|
123
123
|
"kind": "LinkedField",
|
|
124
124
|
"name": "sku",
|
|
125
125
|
"plural": false,
|
|
126
|
-
"selections": [v6 /*: any*/,
|
|
126
|
+
"selections": [v6 /*: any*/, v16 /*: any*/, {
|
|
127
127
|
"alias": "priceWithLicenseOptions",
|
|
128
|
-
"args":
|
|
128
|
+
"args": v13 /*: any*/,
|
|
129
129
|
"concreteType": "Money",
|
|
130
130
|
"kind": "LinkedField",
|
|
131
131
|
"name": "price",
|
|
132
132
|
"plural": false,
|
|
133
|
-
"selections":
|
|
133
|
+
"selections": v15 /*: any*/,
|
|
134
134
|
"storageKey": "price(licenseOptions:[],orderVariables:[])"
|
|
135
135
|
}],
|
|
136
136
|
"storageKey": null
|
|
@@ -144,12 +144,12 @@ const node = function () {
|
|
|
144
144
|
},
|
|
145
145
|
v20 = {
|
|
146
146
|
"alias": null,
|
|
147
|
-
"args": [
|
|
147
|
+
"args": [v12 /*: any*/],
|
|
148
148
|
"concreteType": "Money",
|
|
149
149
|
"kind": "LinkedField",
|
|
150
150
|
"name": "totalStylesPrice",
|
|
151
151
|
"plural": false,
|
|
152
|
-
"selections":
|
|
152
|
+
"selections": v15 /*: any*/,
|
|
153
153
|
"storageKey": "totalStylesPrice(licenseOptions:[])"
|
|
154
154
|
},
|
|
155
155
|
v21 = {
|
|
@@ -159,7 +159,7 @@ const node = function () {
|
|
|
159
159
|
"kind": "LinkedField",
|
|
160
160
|
"name": "parent",
|
|
161
161
|
"plural": false,
|
|
162
|
-
"selections": [
|
|
162
|
+
"selections": [v7 /*: any*/, v6 /*: any*/, v8 /*: any*/, v17 /*: any*/, v18 /*: any*/, v19 /*: any*/, v20 /*: any*/],
|
|
163
163
|
"storageKey": null
|
|
164
164
|
};
|
|
165
165
|
return {
|
|
@@ -303,7 +303,7 @@ const node = function () {
|
|
|
303
303
|
"kind": "LinkedField",
|
|
304
304
|
"name": "fontStyle",
|
|
305
305
|
"plural": false,
|
|
306
|
-
"selections": [v6 /*: any*/, {
|
|
306
|
+
"selections": [v6 /*: any*/, v7 /*: any*/, {
|
|
307
307
|
"alias": null,
|
|
308
308
|
"args": null,
|
|
309
309
|
"concreteType": "FontFeatures",
|
|
@@ -329,7 +329,7 @@ const node = function () {
|
|
|
329
329
|
"kind": "ScalarField",
|
|
330
330
|
"name": "tag",
|
|
331
331
|
"storageKey": null
|
|
332
|
-
},
|
|
332
|
+
}, v8 /*: any*/],
|
|
333
333
|
"storageKey": null
|
|
334
334
|
}],
|
|
335
335
|
"storageKey": null
|
|
@@ -340,7 +340,7 @@ const node = function () {
|
|
|
340
340
|
"kind": "LinkedField",
|
|
341
341
|
"name": "variableAxes",
|
|
342
342
|
"plural": true,
|
|
343
|
-
"selections": [
|
|
343
|
+
"selections": [v9 /*: any*/, v8 /*: any*/, {
|
|
344
344
|
"alias": null,
|
|
345
345
|
"args": null,
|
|
346
346
|
"kind": "ScalarField",
|
|
@@ -354,7 +354,7 @@ const node = function () {
|
|
|
354
354
|
"storageKey": null
|
|
355
355
|
}],
|
|
356
356
|
"storageKey": null
|
|
357
|
-
},
|
|
357
|
+
}, v8 /*: any*/, {
|
|
358
358
|
"alias": null,
|
|
359
359
|
"args": null,
|
|
360
360
|
"kind": "ScalarField",
|
|
@@ -385,14 +385,14 @@ const node = function () {
|
|
|
385
385
|
"kind": "LinkedField",
|
|
386
386
|
"name": "variableInstances",
|
|
387
387
|
"plural": true,
|
|
388
|
-
"selections": [
|
|
388
|
+
"selections": [v8 /*: any*/, {
|
|
389
389
|
"alias": null,
|
|
390
390
|
"args": null,
|
|
391
391
|
"concreteType": "VariableSetting",
|
|
392
392
|
"kind": "LinkedField",
|
|
393
393
|
"name": "coordinates",
|
|
394
394
|
"plural": true,
|
|
395
|
-
"selections":
|
|
395
|
+
"selections": v11 /*: any*/,
|
|
396
396
|
"storageKey": null
|
|
397
397
|
}],
|
|
398
398
|
"storageKey": null
|
|
@@ -403,7 +403,7 @@ const node = function () {
|
|
|
403
403
|
"kind": "LinkedField",
|
|
404
404
|
"name": "family",
|
|
405
405
|
"plural": false,
|
|
406
|
-
"selections": [v6 /*: any*/,
|
|
406
|
+
"selections": [v6 /*: any*/, v8 /*: any*/],
|
|
407
407
|
"storageKey": null
|
|
408
408
|
}, {
|
|
409
409
|
"alias": null,
|
|
@@ -484,14 +484,14 @@ const node = function () {
|
|
|
484
484
|
"kind": "LinkedField",
|
|
485
485
|
"name": "sku",
|
|
486
486
|
"plural": false,
|
|
487
|
-
"selections": [v6 /*: any*/,
|
|
487
|
+
"selections": [v6 /*: any*/, v16 /*: any*/, {
|
|
488
488
|
"alias": "basePrice",
|
|
489
489
|
"args": null,
|
|
490
490
|
"concreteType": "Money",
|
|
491
491
|
"kind": "LinkedField",
|
|
492
492
|
"name": "price",
|
|
493
493
|
"plural": false,
|
|
494
|
-
"selections": [
|
|
494
|
+
"selections": [v14 /*: any*/],
|
|
495
495
|
"storageKey": null
|
|
496
496
|
}],
|
|
497
497
|
"storageKey": null
|
|
@@ -504,7 +504,7 @@ const node = function () {
|
|
|
504
504
|
"kind": "LinkedField",
|
|
505
505
|
"name": "variableSettings",
|
|
506
506
|
"plural": true,
|
|
507
|
-
"selections":
|
|
507
|
+
"selections": v11 /*: any*/,
|
|
508
508
|
"storageKey": null
|
|
509
509
|
}, {
|
|
510
510
|
"alias": null,
|
|
@@ -519,7 +519,7 @@ const node = function () {
|
|
|
519
519
|
"kind": "ScalarField",
|
|
520
520
|
"name": "feature",
|
|
521
521
|
"storageKey": null
|
|
522
|
-
},
|
|
522
|
+
}, v10 /*: any*/],
|
|
523
523
|
"storageKey": null
|
|
524
524
|
}, {
|
|
525
525
|
"alias": null,
|
|
@@ -545,7 +545,7 @@ const node = function () {
|
|
|
545
545
|
"kind": "ScalarField",
|
|
546
546
|
"name": "typeTesterAxes",
|
|
547
547
|
"storageKey": null
|
|
548
|
-
}, v6 /*: any*/,
|
|
548
|
+
}, v6 /*: any*/, v7 /*: any*/, v8 /*: any*/, v17 /*: any*/, v18 /*: any*/, v19 /*: any*/, v20 /*: any*/, v21 /*: any*/, {
|
|
549
549
|
"alias": "families",
|
|
550
550
|
"args": [{
|
|
551
551
|
"kind": "Literal",
|
|
@@ -556,7 +556,7 @@ const node = function () {
|
|
|
556
556
|
"kind": "LinkedField",
|
|
557
557
|
"name": "children",
|
|
558
558
|
"plural": true,
|
|
559
|
-
"selections": [v6 /*: any*/,
|
|
559
|
+
"selections": [v6 /*: any*/, v7 /*: any*/, v8 /*: any*/, v17 /*: any*/, v18 /*: any*/, v19 /*: any*/, v20 /*: any*/, v21 /*: any*/],
|
|
560
560
|
"storageKey": "children(collectionTypes:[\"FAMILY\"])"
|
|
561
561
|
}],
|
|
562
562
|
"storageKey": null
|
|
@@ -567,12 +567,12 @@ const node = function () {
|
|
|
567
567
|
}]
|
|
568
568
|
},
|
|
569
569
|
"params": {
|
|
570
|
-
"cacheID": "
|
|
570
|
+
"cacheID": "ea90ef4b9c8e754a0b5b1343f409913b",
|
|
571
571
|
"id": null,
|
|
572
572
|
"metadata": {},
|
|
573
573
|
"name": "TypeTestersSlugQuery",
|
|
574
574
|
"operationKind": "query",
|
|
575
|
-
"text": "query TypeTestersSlugQuery(\n $collectionSlug: String!\n $tags: [String!]\n $excludeTags: [String!]\n) {\n viewer {\n slug(name: $collectionSlug) {\n collection: fontCollection {\n ...TypeTesters_collection_4Goyz5\n id\n }\n id\n }\n id\n }\n}\n\nfragment FontStyle_fontStyle on FontStyle {\n ...useFontStyle_fontStyle\n}\n\nfragment PriceBarSection_node_3BtHDv on FontCollection {\n id\n name\n collectionType\n sku {\n ...SelectButton_sku_3BtHDv\n id\n priceWithLicenseOptions: price(licenseOptions: [], orderVariables: []) {\n ...Price_price\n }\n }\n totalStyles\n totalStylesPrice(licenseOptions: []) {\n ...Price_price\n }\n}\n\nfragment PriceBar_node_3BtHDv on FontCollection {\n visibility\n ...PriceBarSection_node_3BtHDv\n parent {\n visibility\n ...PriceBarSection_node_3BtHDv\n id\n }\n}\n\nfragment Price_price on Money {\n amount\n currency\n}\n\nfragment SKUPrice_sku_3BtHDv on Sku {\n id\n price(licenseOptions: [], orderVariables: []) {\n amount\n ...Price_price\n }\n}\n\nfragment SelectButton_sku_3BtHDv on Sku {\n id\n ...SKUPrice_sku_3BtHDv\n}\n\nfragment TypeTesterFeaturesButton_fontStyle on FontStyle {\n ...useFeaturesData_fontStyle\n}\n\nfragment TypeTesterFeatures_fontStyle on FontStyle {\n ...useFeaturesData_fontStyle\n ...TypeTesterVariableAxes_fontStyle\n}\n\nfragment TypeTesterFloatingToolbar_testers on TypeTester {\n id\n fontStyle {\n ...TypeTesterToolbar_fontStyle\n ...TypeTesterFeatures_fontStyle\n id\n }\n}\n\nfragment TypeTesterStyleSelectData_fontStyle on FontStyle {\n id\n name\n supportedLanguages\n cssWeight\n cssStyle\n cssStretch\n variableInstances {\n name\n coordinates {\n axis\n value\n }\n }\n family {\n id\n name\n }\n}\n\nfragment TypeTesterToolbar_fontStyle on FontStyle {\n ...TypeTesterVariableAxes_fontStyle\n ...TypeTesterFeaturesButton_fontStyle\n}\n\nfragment TypeTesterVariableAxes_fontStyle on FontStyle {\n variableAxes {\n axis\n name\n minValue\n maxValue\n }\n}\n\nfragment TypeTester_fontStyle_3BtHDv on FontStyle {\n id\n ...TypeTesterFeatures_fontStyle\n ...TypeTesterStyleSelectData_fontStyle\n ...FontStyle_fontStyle\n ...TypeTesterVariableAxes_fontStyle\n ...TypeTesterToolbar_fontStyle\n sku {\n ...SelectButton_sku_3BtHDv\n ...SKUPrice_sku_3BtHDv\n id\n basePrice: price {\n amount\n }\n }\n}\n\nfragment TypeTesters_collection_4Goyz5 on FontCollection {\n typeTesters(first: 999, tags: $tags, excludeTags: $excludeTags) {\n edges {\n node {\n id\n content\n size\n lineHeight\n letterSpacing\n autofit\n direction\n alignment\n fontStyle {\n ...TypeTester_fontStyle_3BtHDv\n id\n family {\n id\n }\n }\n variableSettings {\n axis\n value\n }\n featureSettings {\n feature\n value\n }\n tags\n ...TypeTesterFloatingToolbar_testers\n }\n }\n }\n typeTesterFeatures\n typeTesterAxes\n id\n ...PriceBar_node_3BtHDv\n families: children(collectionTypes: [FAMILY]) {\n id\n ...PriceBar_node_3BtHDv\n }\n parent {\n id\n }\n}\n\nfragment useFeaturesData_fontStyle on FontStyle {\n fontFeatures {\n supportedFeatures\n featureNames {\n tag\n name\n }\n }\n}\n\nfragment useFontStyle_fontStyle on FontStyle {\n cssFamily\n name\n webfontSources {\n url\n format\n tech\n }\n verticalMetrics {\n unitsPerEm\n ascender\n descender\n lineGap\n avgCharWidth\n }\n}\n"
|
|
575
|
+
"text": "query TypeTestersSlugQuery(\n $collectionSlug: String!\n $tags: [String!]\n $excludeTags: [String!]\n) {\n viewer {\n slug(name: $collectionSlug) {\n collection: fontCollection {\n ...TypeTesters_collection_4Goyz5\n id\n }\n id\n }\n id\n }\n}\n\nfragment FontStyle_fontStyle on FontStyle {\n ...useFontStyle_fontStyle\n}\n\nfragment PriceBarSection_node_3BtHDv on FontCollection {\n id\n name\n collectionType\n sku {\n ...SelectButton_sku_3BtHDv\n id\n priceWithLicenseOptions: price(licenseOptions: [], orderVariables: []) {\n ...Price_price\n }\n }\n totalStyles\n totalStylesPrice(licenseOptions: []) {\n ...Price_price\n }\n}\n\nfragment PriceBar_node_3BtHDv on FontCollection {\n visibility\n ...PriceBarSection_node_3BtHDv\n parent {\n visibility\n ...PriceBarSection_node_3BtHDv\n id\n }\n}\n\nfragment Price_price on Money {\n amount\n currency\n}\n\nfragment SKUPrice_sku_3BtHDv on Sku {\n id\n price(licenseOptions: [], orderVariables: []) {\n amount\n ...Price_price\n }\n}\n\nfragment SelectButton_sku_3BtHDv on Sku {\n id\n ...SKUPrice_sku_3BtHDv\n}\n\nfragment TypeTesterFeaturesButton_fontStyle on FontStyle {\n ...useFeaturesData_fontStyle\n}\n\nfragment TypeTesterFeatures_fontStyle on FontStyle {\n ...useFeaturesData_fontStyle\n ...TypeTesterVariableAxes_fontStyle\n}\n\nfragment TypeTesterFloatingToolbar_testers on TypeTester {\n id\n fontStyle {\n ...TypeTesterToolbar_fontStyle\n ...TypeTesterFeatures_fontStyle\n id\n }\n}\n\nfragment TypeTesterStyleSelectData_fontStyle on FontStyle {\n id\n name\n supportedLanguages\n cssWeight\n cssStyle\n cssStretch\n variableInstances {\n name\n coordinates {\n axis\n value\n }\n }\n family {\n id\n name\n }\n}\n\nfragment TypeTesterToolbar_fontStyle on FontStyle {\n ...TypeTesterVariableAxes_fontStyle\n ...TypeTesterFeaturesButton_fontStyle\n}\n\nfragment TypeTesterVariableAxes_fontStyle on FontStyle {\n variableAxes {\n axis\n name\n minValue\n maxValue\n }\n}\n\nfragment TypeTester_fontStyle_3BtHDv on FontStyle {\n id\n visibility\n ...TypeTesterFeatures_fontStyle\n ...TypeTesterStyleSelectData_fontStyle\n ...FontStyle_fontStyle\n ...TypeTesterVariableAxes_fontStyle\n ...TypeTesterToolbar_fontStyle\n sku {\n ...SelectButton_sku_3BtHDv\n ...SKUPrice_sku_3BtHDv\n id\n basePrice: price {\n amount\n }\n }\n}\n\nfragment TypeTesters_collection_4Goyz5 on FontCollection {\n typeTesters(first: 999, tags: $tags, excludeTags: $excludeTags) {\n edges {\n node {\n id\n content\n size\n lineHeight\n letterSpacing\n autofit\n direction\n alignment\n fontStyle {\n ...TypeTester_fontStyle_3BtHDv\n id\n family {\n id\n }\n }\n variableSettings {\n axis\n value\n }\n featureSettings {\n feature\n value\n }\n tags\n ...TypeTesterFloatingToolbar_testers\n }\n }\n }\n typeTesterFeatures\n typeTesterAxes\n id\n ...PriceBar_node_3BtHDv\n families: children(collectionTypes: [FAMILY]) {\n id\n ...PriceBar_node_3BtHDv\n }\n parent {\n id\n }\n}\n\nfragment useFeaturesData_fontStyle on FontStyle {\n fontFeatures {\n supportedFeatures\n featureNames {\n tag\n name\n }\n }\n}\n\nfragment useFontStyle_fontStyle on FontStyle {\n cssFamily\n name\n webfontSources {\n url\n format\n tech\n }\n verticalMetrics {\n unitsPerEm\n ascender\n descender\n lineGap\n avgCharWidth\n }\n}\n"
|
|
576
576
|
}
|
|
577
577
|
};
|
|
578
578
|
}();
|
|
@@ -0,0 +1,195 @@
|
|
|
1
|
+
// @vitest-environment happy-dom
|
|
2
|
+
|
|
3
|
+
// Removing the last item a coupon covers takes the discount with it on the
|
|
4
|
+
// server, so the cart has to say where the discount went. A refusal comes back
|
|
5
|
+
// as `errors.coupon` and must be shown too: the × otherwise appears to do nothing.
|
|
6
|
+
|
|
7
|
+
import React, { act } from 'react';
|
|
8
|
+
import { createRoot } from 'react-dom/client';
|
|
9
|
+
import { afterEach, beforeEach, describe, expect, it, vi } from 'vitest';
|
|
10
|
+
const {
|
|
11
|
+
relay
|
|
12
|
+
} = vi.hoisted(() => ({
|
|
13
|
+
relay: {
|
|
14
|
+
order: null,
|
|
15
|
+
response: null,
|
|
16
|
+
inputs: []
|
|
17
|
+
}
|
|
18
|
+
}));
|
|
19
|
+
vi.mock('react-relay', () => ({
|
|
20
|
+
graphql: () => null,
|
|
21
|
+
useRelayEnvironment: () => ({}),
|
|
22
|
+
useFragment: () => relay.order,
|
|
23
|
+
commitMutation: (_env, config) => {
|
|
24
|
+
relay.inputs.push(config.variables.input);
|
|
25
|
+
// Relay writes the response to the store, so the fragment sees it too.
|
|
26
|
+
const updated = relay.response.updateOrder.order;
|
|
27
|
+
if (updated) relay.order = {
|
|
28
|
+
...relay.order,
|
|
29
|
+
...updated
|
|
30
|
+
};
|
|
31
|
+
config.onCompleted(relay.response);
|
|
32
|
+
}
|
|
33
|
+
}));
|
|
34
|
+
import CartState from '../components/Cart/CartState.js';
|
|
35
|
+
import CartCouponNotice from '../components/Cart/CartCouponNotice.js';
|
|
36
|
+
globalThis.IS_REACT_ACT_ENVIRONMENT = true;
|
|
37
|
+
const orderWith = discount => ({
|
|
38
|
+
id: 'order',
|
|
39
|
+
discount,
|
|
40
|
+
orderItems: [{
|
|
41
|
+
id: 'covered',
|
|
42
|
+
licenseSelections: [{
|
|
43
|
+
license: {
|
|
44
|
+
id: 'desktop'
|
|
45
|
+
}
|
|
46
|
+
}]
|
|
47
|
+
}, {
|
|
48
|
+
id: 'other',
|
|
49
|
+
licenseSelections: [{
|
|
50
|
+
license: {
|
|
51
|
+
id: 'desktop'
|
|
52
|
+
}
|
|
53
|
+
}]
|
|
54
|
+
}],
|
|
55
|
+
orderVariableSelections: []
|
|
56
|
+
});
|
|
57
|
+
let container;
|
|
58
|
+
let root;
|
|
59
|
+
let removeItem;
|
|
60
|
+
const render = async () => {
|
|
61
|
+
await act(async () => root.render( /*#__PURE__*/React.createElement(CartState, {
|
|
62
|
+
order: {}
|
|
63
|
+
}, _ref => {
|
|
64
|
+
let {
|
|
65
|
+
onUpdateOrderItem,
|
|
66
|
+
discountRemoved,
|
|
67
|
+
errors
|
|
68
|
+
} = _ref;
|
|
69
|
+
removeItem = () => onUpdateOrderItem({
|
|
70
|
+
id: 'covered',
|
|
71
|
+
licenseSelections: []
|
|
72
|
+
});
|
|
73
|
+
return /*#__PURE__*/React.createElement(CartCouponNotice, {
|
|
74
|
+
discountRemoved: discountRemoved,
|
|
75
|
+
errors: errors === null || errors === void 0 ? void 0 : errors.coupon
|
|
76
|
+
});
|
|
77
|
+
})));
|
|
78
|
+
};
|
|
79
|
+
const clickRemove = async () => {
|
|
80
|
+
await act(async () => removeItem());
|
|
81
|
+
};
|
|
82
|
+
beforeEach(() => {
|
|
83
|
+
relay.order = orderWith({
|
|
84
|
+
id: 'discount'
|
|
85
|
+
});
|
|
86
|
+
relay.response = {
|
|
87
|
+
updateOrder: {
|
|
88
|
+
order: {
|
|
89
|
+
discount: null
|
|
90
|
+
}
|
|
91
|
+
}
|
|
92
|
+
};
|
|
93
|
+
relay.inputs = [];
|
|
94
|
+
container = document.createElement('div');
|
|
95
|
+
document.body.append(container);
|
|
96
|
+
root = createRoot(container);
|
|
97
|
+
});
|
|
98
|
+
afterEach(() => {
|
|
99
|
+
act(() => root.unmount());
|
|
100
|
+
container.remove();
|
|
101
|
+
});
|
|
102
|
+
describe('cart coupon notice', () => {
|
|
103
|
+
it('says so when removing an item takes the discount with it', async () => {
|
|
104
|
+
var _container$querySelec;
|
|
105
|
+
await render();
|
|
106
|
+
expect(container.textContent).toBe('');
|
|
107
|
+
await clickRemove();
|
|
108
|
+
expect((_container$querySelec = container.querySelector('[role="status"]')) === null || _container$querySelec === void 0 ? void 0 : _container$querySelec.textContent).toBe('Your discount was removed because it doesn’t apply to the items left in your cart.');
|
|
109
|
+
expect(relay.inputs).toEqual([{
|
|
110
|
+
orderItems: [{
|
|
111
|
+
id: 'other',
|
|
112
|
+
licenseSelections: [{
|
|
113
|
+
licenseId: 'desktop'
|
|
114
|
+
}]
|
|
115
|
+
}]
|
|
116
|
+
}]);
|
|
117
|
+
});
|
|
118
|
+
it('stays quiet when the discount survives the change', async () => {
|
|
119
|
+
relay.response = {
|
|
120
|
+
updateOrder: {
|
|
121
|
+
order: {
|
|
122
|
+
discount: {
|
|
123
|
+
id: 'discount'
|
|
124
|
+
}
|
|
125
|
+
}
|
|
126
|
+
}
|
|
127
|
+
};
|
|
128
|
+
await render();
|
|
129
|
+
await clickRemove();
|
|
130
|
+
expect(container.textContent).toBe('');
|
|
131
|
+
});
|
|
132
|
+
it('stays quiet when there was no discount to lose', async () => {
|
|
133
|
+
relay.order = orderWith(null);
|
|
134
|
+
await render();
|
|
135
|
+
await clickRemove();
|
|
136
|
+
expect(container.textContent).toBe('');
|
|
137
|
+
});
|
|
138
|
+
it('notices a discount applied after the cart rendered', async () => {
|
|
139
|
+
relay.order = orderWith(null);
|
|
140
|
+
await render();
|
|
141
|
+
relay.order = orderWith({
|
|
142
|
+
id: 'discount'
|
|
143
|
+
});
|
|
144
|
+
await render();
|
|
145
|
+
await clickRemove();
|
|
146
|
+
expect(container.querySelector('[role="status"]')).not.toBeNull();
|
|
147
|
+
});
|
|
148
|
+
it('puts the notice away for good when a coupon is applied again', async () => {
|
|
149
|
+
await render();
|
|
150
|
+
await clickRemove();
|
|
151
|
+
relay.order = orderWith({
|
|
152
|
+
id: 'new-discount'
|
|
153
|
+
});
|
|
154
|
+
await render();
|
|
155
|
+
expect(container.textContent).toBe('');
|
|
156
|
+
|
|
157
|
+
// Taking that one off by hand needs no explanation.
|
|
158
|
+
relay.order = orderWith(null);
|
|
159
|
+
await render();
|
|
160
|
+
expect(container.textContent).toBe('');
|
|
161
|
+
});
|
|
162
|
+
it('survives a render that still has the old order', async () => {
|
|
163
|
+
await render();
|
|
164
|
+
await clickRemove();
|
|
165
|
+
relay.order = orderWith({
|
|
166
|
+
id: 'discount'
|
|
167
|
+
});
|
|
168
|
+
await render();
|
|
169
|
+
relay.order = orderWith(null);
|
|
170
|
+
await render();
|
|
171
|
+
expect(container.querySelector('[role="status"]')).not.toBeNull();
|
|
172
|
+
});
|
|
173
|
+
it('shows why the coupon stopped the change', async () => {
|
|
174
|
+
var _container$querySelec2;
|
|
175
|
+
const message = 'You’ve already used this discount code. Please remove it to continue with your order.';
|
|
176
|
+
relay.response = {
|
|
177
|
+
updateOrder: {
|
|
178
|
+
order: null,
|
|
179
|
+
errors: {
|
|
180
|
+
coupon: [message]
|
|
181
|
+
}
|
|
182
|
+
}
|
|
183
|
+
};
|
|
184
|
+
await render();
|
|
185
|
+
await clickRemove();
|
|
186
|
+
expect((_container$querySelec2 = container.querySelector('[role="alert"]')) === null || _container$querySelec2 === void 0 ? void 0 : _container$querySelec2.textContent).toBe(message);
|
|
187
|
+
expect(container.querySelector('[role="status"]')).toBeNull();
|
|
188
|
+
|
|
189
|
+
// Doing what it asks clears it, without a word about a discount the buyer
|
|
190
|
+
// took off themselves.
|
|
191
|
+
relay.order = orderWith(null);
|
|
192
|
+
await render();
|
|
193
|
+
expect(container.textContent).toBe('');
|
|
194
|
+
});
|
|
195
|
+
});
|
|
@@ -0,0 +1,199 @@
|
|
|
1
|
+
function _extends() { return _extends = Object.assign ? Object.assign.bind() : function (n) { for (var e = 1; e < arguments.length; e++) { var t = arguments[e]; for (var r in t) ({}).hasOwnProperty.call(t, r) && (n[r] = t[r]); } return n; }, _extends.apply(null, arguments); }
|
|
2
|
+
// @vitest-environment happy-dom
|
|
3
|
+
|
|
4
|
+
// A collapsed CharacterViewer cuts its glyph grid short behind a “Load more”
|
|
5
|
+
// button: by default after the first glyph group, or at a given height.
|
|
6
|
+
|
|
7
|
+
import React, { act } from 'react';
|
|
8
|
+
import { createRoot } from 'react-dom/client';
|
|
9
|
+
import { renderToStaticMarkup } from 'react-dom/server';
|
|
10
|
+
import { afterEach, beforeEach, describe, expect, it, vi } from 'vitest';
|
|
11
|
+
|
|
12
|
+
// The fragment readers hand back the data they were given, and the preloaded
|
|
13
|
+
// query resolves to the collection below.
|
|
14
|
+
vi.mock('react-relay', () => ({
|
|
15
|
+
graphql: () => null,
|
|
16
|
+
fetchQuery: () => ({
|
|
17
|
+
subscribe: () => {}
|
|
18
|
+
}),
|
|
19
|
+
useFragment: (_fragment, key) => key,
|
|
20
|
+
useRefetchableFragment: (_fragment, key) => [key, () => {}],
|
|
21
|
+
useRelayEnvironment: () => ({}),
|
|
22
|
+
useLazyLoadQuery: () => null,
|
|
23
|
+
usePreloadedQuery: () => ({
|
|
24
|
+
viewer: {
|
|
25
|
+
slug: {
|
|
26
|
+
fontCollection: collection
|
|
27
|
+
}
|
|
28
|
+
}
|
|
29
|
+
})
|
|
30
|
+
}));
|
|
31
|
+
vi.mock('../relay/useSerializablePreloadedQuery.js', () => ({
|
|
32
|
+
default: () => null
|
|
33
|
+
}));
|
|
34
|
+
vi.mock('../components/useFontStyle.js', () => ({
|
|
35
|
+
default: () => ({
|
|
36
|
+
style: {}
|
|
37
|
+
})
|
|
38
|
+
}));
|
|
39
|
+
vi.mock('../components/TypeTester/useFeaturesData.js', () => ({
|
|
40
|
+
default: () => ({
|
|
41
|
+
featureNames: {}
|
|
42
|
+
})
|
|
43
|
+
}));
|
|
44
|
+
import { CharacterViewerPreloadedSlugQueryRenderer } from '../components/CharacterViewer/index.js';
|
|
45
|
+
import { parseCollapse } from '../components/CharacterViewer/collapse.js';
|
|
46
|
+
const group = (name, first, last) => ({
|
|
47
|
+
name,
|
|
48
|
+
characterSets: [{
|
|
49
|
+
features: null,
|
|
50
|
+
characters: [{
|
|
51
|
+
__typename: 'CharacterRange',
|
|
52
|
+
first,
|
|
53
|
+
last
|
|
54
|
+
}]
|
|
55
|
+
}]
|
|
56
|
+
});
|
|
57
|
+
const glyphNames = ['A', 'B', 'C', 'a', 'b', 'c', '1', '2'].map(characters => ({
|
|
58
|
+
characters,
|
|
59
|
+
features: null,
|
|
60
|
+
name: characters
|
|
61
|
+
}));
|
|
62
|
+
const collection = {
|
|
63
|
+
id: 'collection:1',
|
|
64
|
+
name: 'Sans',
|
|
65
|
+
isVariableFont: false,
|
|
66
|
+
collectionType: 'family',
|
|
67
|
+
fontStyles: [],
|
|
68
|
+
children: [],
|
|
69
|
+
glyphGroups: [group('Uppercase', 'A', 'C'), group('Lowercase', 'a', 'c'), group('Figures', '1', '2')],
|
|
70
|
+
featureStyle: {
|
|
71
|
+
id: 'style:1',
|
|
72
|
+
name: 'Regular',
|
|
73
|
+
cssFamily: 'Sans Regular',
|
|
74
|
+
variableInstances: null,
|
|
75
|
+
glyphNames,
|
|
76
|
+
verticalMetrics: {
|
|
77
|
+
unitsPerEm: 1000,
|
|
78
|
+
ascender: 800,
|
|
79
|
+
descender: -200,
|
|
80
|
+
xHeight: 500,
|
|
81
|
+
capHeight: 700,
|
|
82
|
+
lineGap: 0
|
|
83
|
+
}
|
|
84
|
+
}
|
|
85
|
+
};
|
|
86
|
+
const viewer = function () {
|
|
87
|
+
let props = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {};
|
|
88
|
+
return /*#__PURE__*/React.createElement(CharacterViewerPreloadedSlugQueryRenderer, _extends({
|
|
89
|
+
preloadedQuery: {}
|
|
90
|
+
}, props));
|
|
91
|
+
};
|
|
92
|
+
const groupNames = el => Array.from(el.querySelectorAll('.character-viewer__block')).map(block => block.getAttribute('data-name'));
|
|
93
|
+
describe('parseCollapse', () => {
|
|
94
|
+
it.each([[undefined, {
|
|
95
|
+
kind: 'none'
|
|
96
|
+
}], [false, {
|
|
97
|
+
kind: 'none'
|
|
98
|
+
}], ['false', {
|
|
99
|
+
kind: 'none'
|
|
100
|
+
}], [0, {
|
|
101
|
+
kind: 'none'
|
|
102
|
+
}], [true, {
|
|
103
|
+
kind: 'first-group'
|
|
104
|
+
}], ['', {
|
|
105
|
+
kind: 'first-group'
|
|
106
|
+
}], ['true', {
|
|
107
|
+
kind: 'first-group'
|
|
108
|
+
}], ['first-group', {
|
|
109
|
+
kind: 'first-group'
|
|
110
|
+
}], [480, {
|
|
111
|
+
kind: 'height',
|
|
112
|
+
height: '480px'
|
|
113
|
+
}], ['480', {
|
|
114
|
+
kind: 'height',
|
|
115
|
+
height: '480px'
|
|
116
|
+
}], [' 40vh ', {
|
|
117
|
+
kind: 'height',
|
|
118
|
+
height: '40vh'
|
|
119
|
+
}]])('reads %j', (value, mode) => {
|
|
120
|
+
expect(parseCollapse(value)).toEqual(mode);
|
|
121
|
+
});
|
|
122
|
+
});
|
|
123
|
+
describe('CharacterViewer collapse', () => {
|
|
124
|
+
let container;
|
|
125
|
+
let root;
|
|
126
|
+
beforeEach(() => {
|
|
127
|
+
globalThis.IS_REACT_ACT_ENVIRONMENT = true;
|
|
128
|
+
vi.stubGlobal('fetch', vi.fn(() => new Promise(() => {})));
|
|
129
|
+
container = document.createElement('div');
|
|
130
|
+
document.body.appendChild(container);
|
|
131
|
+
root = createRoot(container);
|
|
132
|
+
});
|
|
133
|
+
afterEach(() => {
|
|
134
|
+
act(() => root.unmount());
|
|
135
|
+
container.remove();
|
|
136
|
+
vi.unstubAllGlobals();
|
|
137
|
+
});
|
|
138
|
+
const render = element => act(() => root.render(element));
|
|
139
|
+
const button = () => container.querySelector('.character-viewer__load-more__button');
|
|
140
|
+
it('renders every group with no button by default', () => {
|
|
141
|
+
render(viewer());
|
|
142
|
+
expect(groupNames(container)).toEqual(['Uppercase', 'Lowercase', 'Figures']);
|
|
143
|
+
expect(button()).toBeNull();
|
|
144
|
+
});
|
|
145
|
+
it('shows only the first group until the visitor loads more', () => {
|
|
146
|
+
var _button;
|
|
147
|
+
render(viewer({
|
|
148
|
+
collapse: ''
|
|
149
|
+
}));
|
|
150
|
+
expect(groupNames(container)).toEqual(['Uppercase']);
|
|
151
|
+
expect((_button = button()) === null || _button === void 0 ? void 0 : _button.textContent).toBe('Load more');
|
|
152
|
+
act(() => button().click());
|
|
153
|
+
expect(groupNames(container)).toEqual(['Uppercase', 'Lowercase', 'Figures']);
|
|
154
|
+
expect(button()).toBeNull();
|
|
155
|
+
});
|
|
156
|
+
it('takes a custom button label', () => {
|
|
157
|
+
var _button2;
|
|
158
|
+
render(viewer({
|
|
159
|
+
collapse: true,
|
|
160
|
+
loadMoreLabel: 'Show all characters'
|
|
161
|
+
}));
|
|
162
|
+
expect((_button2 = button()) === null || _button2 === void 0 ? void 0 : _button2.textContent).toBe('Show all characters');
|
|
163
|
+
});
|
|
164
|
+
it('server-renders the first group and the button', () => {
|
|
165
|
+
const html = renderToStaticMarkup(viewer({
|
|
166
|
+
collapse: true
|
|
167
|
+
}));
|
|
168
|
+
expect(html).toContain('data-name="Uppercase"');
|
|
169
|
+
expect(html).not.toContain('data-name="Lowercase"');
|
|
170
|
+
expect(html).toContain('Load more');
|
|
171
|
+
});
|
|
172
|
+
it('clips every group to a height and drops the button when nothing overflows', () => {
|
|
173
|
+
// happy-dom does no layout, so scrollHeight never exceeds clientHeight.
|
|
174
|
+
const html = renderToStaticMarkup(viewer({
|
|
175
|
+
collapse: '320'
|
|
176
|
+
}));
|
|
177
|
+
expect(html).toContain('data-collapsed="height"');
|
|
178
|
+
expect(html).toContain('--collapsed-height:320px');
|
|
179
|
+
expect(html).toContain('Load more');
|
|
180
|
+
render(viewer({
|
|
181
|
+
collapse: '320'
|
|
182
|
+
}));
|
|
183
|
+
expect(groupNames(container)).toEqual(['Uppercase', 'Lowercase', 'Figures']);
|
|
184
|
+
expect(button()).toBeNull();
|
|
185
|
+
});
|
|
186
|
+
it('keeps the button on a height-clipped grid that overflows', () => {
|
|
187
|
+
vi.spyOn(HTMLElement.prototype, 'scrollHeight', 'get').mockReturnValue(900);
|
|
188
|
+
vi.spyOn(HTMLElement.prototype, 'clientHeight', 'get').mockReturnValue(320);
|
|
189
|
+
render(viewer({
|
|
190
|
+
collapse: 320
|
|
191
|
+
}));
|
|
192
|
+
expect(button()).not.toBeNull();
|
|
193
|
+
act(() => button().click());
|
|
194
|
+
const blocks = container.querySelector('.character-viewer_blocks');
|
|
195
|
+
expect(blocks.hasAttribute('data-collapsed')).toBe(false);
|
|
196
|
+
expect(button()).toBeNull();
|
|
197
|
+
vi.restoreAllMocks();
|
|
198
|
+
});
|
|
199
|
+
});
|