@shopify/ui-extensions 2025.10.0-rc.45 → 2025.10.0-rc.47
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/build/cjs/surfaces/checkout/preact/api.js +1 -1
- package/build/cjs/surfaces/checkout/shared.js +1 -1
- package/build/esm/surfaces/checkout/preact/api.mjs +1 -1
- package/build/esm/surfaces/checkout/shared.mjs +1 -1
- package/build/esnext/surfaces/checkout/preact/api.esnext +1 -1
- package/build/esnext/surfaces/checkout/shared.esnext +1 -1
- package/build/ts/docs/shared/components/ConsentCheckbox.d.ts +4 -0
- package/build/ts/docs/shared/components/ConsentCheckbox.d.ts.map +1 -0
- package/build/ts/docs/shared/components/ConsentPhoneField.d.ts +4 -0
- package/build/ts/docs/shared/components/ConsentPhoneField.d.ts.map +1 -0
- package/build/ts/docs/shared/components/index.d.ts +2 -0
- package/build/ts/docs/shared/components/index.d.ts.map +1 -1
- package/build/ts/surfaces/checkout/components/ConsentCheckbox/ConsentCheckbox.doc.d.ts +4 -0
- package/build/ts/surfaces/checkout/components/ConsentCheckbox/ConsentCheckbox.doc.d.ts.map +1 -0
- package/build/ts/surfaces/checkout/components/ConsentCheckbox.d.ts +84 -0
- package/build/ts/surfaces/checkout/components/ConsentPhoneField/ConsentPhoneField.doc.d.ts +4 -0
- package/build/ts/surfaces/checkout/components/ConsentPhoneField/ConsentPhoneField.doc.d.ts.map +1 -0
- package/build/ts/surfaces/checkout/components/ConsentPhoneField.d.ts +129 -0
- package/build/ts/surfaces/checkout/components/NumberField/NumberField.doc.d.ts +4 -0
- package/build/ts/surfaces/checkout/components/NumberField/NumberField.doc.d.ts.map +1 -0
- package/build/ts/surfaces/checkout/components/NumberField.d.ts +98 -0
- package/build/ts/surfaces/checkout/components/PasswordField.d.ts +1 -1
- package/build/ts/surfaces/checkout/components/components-shared.d.ts +17 -0
- package/build/ts/surfaces/checkout/components/components.d.ts +216 -144
- package/build/ts/surfaces/checkout/shared.d.ts +1 -1
- package/build/ts/surfaces/checkout/shared.d.ts.map +1 -1
- package/build/ts/surfaces/checkout/targets/Checkout::Actions::RenderBefore.d.ts +3 -0
- package/build/ts/surfaces/checkout/targets/Checkout::CartLineDetails::RenderAfter.d.ts +3 -0
- package/build/ts/surfaces/checkout/targets/Checkout::CartLineDetails::RenderLineComponents.d.ts +3 -0
- package/build/ts/surfaces/checkout/targets/Checkout::CartLines::RenderAfter.d.ts +3 -0
- package/build/ts/surfaces/checkout/targets/Checkout::Contact::RenderAfter.d.ts +3 -0
- package/build/ts/surfaces/checkout/targets/Checkout::CustomerInformation::RenderAfter.d.ts +3 -0
- package/build/ts/surfaces/checkout/targets/Checkout::DeliveryAddress::RenderBefore.d.ts +3 -0
- package/build/ts/surfaces/checkout/targets/Checkout::Dynamic::Render.d.ts +3 -0
- package/build/ts/surfaces/checkout/targets/Checkout::GiftCard::Render.d.ts +3 -0
- package/build/ts/surfaces/checkout/targets/Checkout::PaymentMethod::HostedFields::RenderAfter.d.ts +3 -0
- package/build/ts/surfaces/checkout/targets/Checkout::PaymentMethod::Render.d.ts +3 -0
- package/build/ts/surfaces/checkout/targets/Checkout::PaymentMethod::RenderRequiredAction.d.ts +3 -0
- package/build/ts/surfaces/checkout/targets/Checkout::PickupLocations::RenderAfter.d.ts +3 -0
- package/build/ts/surfaces/checkout/targets/Checkout::PickupLocations::RenderBefore.d.ts +3 -0
- package/build/ts/surfaces/checkout/targets/Checkout::PickupPoints::RenderAfter.d.ts +3 -0
- package/build/ts/surfaces/checkout/targets/Checkout::PickupPoints::RenderBefore.d.ts +3 -0
- package/build/ts/surfaces/checkout/targets/Checkout::Reductions::RenderAfter.d.ts +3 -0
- package/build/ts/surfaces/checkout/targets/Checkout::Reductions::RenderBefore.d.ts +3 -0
- package/build/ts/surfaces/checkout/targets/Checkout::ShippingMethodDetails::RenderAfter.d.ts +3 -0
- package/build/ts/surfaces/checkout/targets/Checkout::ShippingMethodDetails::RenderExpanded.d.ts +3 -0
- package/build/ts/surfaces/checkout/targets/Checkout::ShippingMethods::RenderAfter.d.ts +3 -0
- package/build/ts/surfaces/checkout/targets/Checkout::ShippingMethods::RenderBefore.d.ts +3 -0
- package/build/ts/surfaces/checkout/targets/Checkout::ThankYou::CartLineDetails::RenderAfter.d.ts +3 -0
- package/build/ts/surfaces/checkout/targets/Checkout::ThankYou::CartLines::RenderAfter.d.ts +3 -0
- package/build/ts/surfaces/checkout/targets/Checkout::ThankYou::CustomerInformation::RenderAfter.d.ts +3 -0
- package/build/ts/surfaces/checkout/targets/Checkout::ThankYou::Dynamic::Render.d.ts +3 -0
- package/build/ts/surfaces/checkout/targets/purchase.cart-line-item.line-components.render.d.ts +3 -0
- package/build/ts/surfaces/checkout/targets/purchase.checkout.actions.render-before.d.ts +3 -0
- package/build/ts/surfaces/checkout/targets/purchase.checkout.block.render.d.ts +3 -0
- package/build/ts/surfaces/checkout/targets/purchase.checkout.cart-line-item.render-after.d.ts +3 -0
- package/build/ts/surfaces/checkout/targets/purchase.checkout.cart-line-list.render-after.d.ts +3 -0
- package/build/ts/surfaces/checkout/targets/purchase.checkout.contact.render-after.d.ts +3 -0
- package/build/ts/surfaces/checkout/targets/purchase.checkout.delivery-address.render-after.d.ts +3 -0
- package/build/ts/surfaces/checkout/targets/purchase.checkout.delivery-address.render-before.d.ts +3 -0
- package/build/ts/surfaces/checkout/targets/purchase.checkout.footer.render-after.d.ts +3 -0
- package/build/ts/surfaces/checkout/targets/purchase.checkout.gift-card.render.d.ts +3 -0
- package/build/ts/surfaces/checkout/targets/purchase.checkout.header.render-after.d.ts +3 -0
- package/build/ts/surfaces/checkout/targets/purchase.checkout.payment-method-list.render-after.d.ts +3 -0
- package/build/ts/surfaces/checkout/targets/purchase.checkout.payment-method-list.render-before.d.ts +3 -0
- package/build/ts/surfaces/checkout/targets/purchase.checkout.payment-option-item.action-required.render.d.ts +3 -0
- package/build/ts/surfaces/checkout/targets/purchase.checkout.payment-option-item.details.render.d.ts +3 -0
- package/build/ts/surfaces/checkout/targets/purchase.checkout.payment-option-item.hosted-fields.render-after.d.ts +3 -0
- package/build/ts/surfaces/checkout/targets/purchase.checkout.pickup-location-list.render-after.d.ts +3 -0
- package/build/ts/surfaces/checkout/targets/purchase.checkout.pickup-location-list.render-before.d.ts +3 -0
- package/build/ts/surfaces/checkout/targets/purchase.checkout.pickup-location-option-item.render-after.d.ts +3 -0
- package/build/ts/surfaces/checkout/targets/purchase.checkout.pickup-point-list.render-after.d.ts +3 -0
- package/build/ts/surfaces/checkout/targets/purchase.checkout.pickup-point-list.render-before.d.ts +3 -0
- package/build/ts/surfaces/checkout/targets/purchase.checkout.reductions.render-after.d.ts +3 -0
- package/build/ts/surfaces/checkout/targets/purchase.checkout.reductions.render-before.d.ts +3 -0
- package/build/ts/surfaces/checkout/targets/purchase.checkout.shipping-option-item.details.render.d.ts +3 -0
- package/build/ts/surfaces/checkout/targets/purchase.checkout.shipping-option-item.render-after.d.ts +3 -0
- package/build/ts/surfaces/checkout/targets/purchase.checkout.shipping-option-list.render-after.d.ts +3 -0
- package/build/ts/surfaces/checkout/targets/purchase.checkout.shipping-option-list.render-before.d.ts +3 -0
- package/build/ts/surfaces/checkout/targets/purchase.thank-you.announcement.render.d.ts +3 -0
- package/build/ts/surfaces/checkout/targets/purchase.thank-you.block.render.d.ts +3 -0
- package/build/ts/surfaces/checkout/targets/purchase.thank-you.cart-line-item.render-after.d.ts +3 -0
- package/build/ts/surfaces/checkout/targets/purchase.thank-you.cart-line-list.render-after.d.ts +3 -0
- package/build/ts/surfaces/checkout/targets/purchase.thank-you.customer-information.render-after.d.ts +3 -0
- package/build/ts/surfaces/checkout/targets/purchase.thank-you.footer.render-after.d.ts +3 -0
- package/build/ts/surfaces/checkout/targets/purchase.thank-you.header.render-after.d.ts +3 -0
- package/build/ts/surfaces/customer-account/components/ConsentCheckbox.d.ts +84 -0
- package/build/ts/surfaces/customer-account/components/ConsentPhoneField.d.ts +129 -0
- package/build/ts/surfaces/customer-account/components/NumberField.d.ts +98 -0
- package/build/ts/surfaces/customer-account/components/PasswordField.d.ts +1 -1
- package/build/ts/surfaces/customer-account/components/components-shared.d.ts +17 -0
- package/build/ts/surfaces/customer-account/components/components.d.ts +216 -144
- package/build/ts/surfaces/customer-account/targets/customer-account.footer.render-after.d.ts +3 -0
- package/build/ts/surfaces/customer-account/targets/customer-account.order-index.announcement.render.d.ts +3 -0
- package/build/ts/surfaces/customer-account/targets/customer-account.order-index.block.render.d.ts +3 -0
- package/build/ts/surfaces/customer-account/targets/customer-account.order-status.announcement.render.d.ts +3 -0
- package/build/ts/surfaces/customer-account/targets/customer-account.order-status.block.render.d.ts +3 -0
- package/build/ts/surfaces/customer-account/targets/customer-account.order-status.cart-line-item.render-after.d.ts +3 -0
- package/build/ts/surfaces/customer-account/targets/customer-account.order-status.cart-line-list.render-after.d.ts +3 -0
- package/build/ts/surfaces/customer-account/targets/customer-account.order-status.customer-information.render-after.d.ts +3 -0
- package/build/ts/surfaces/customer-account/targets/customer-account.order-status.fulfillment-details.render-after.d.ts +3 -0
- package/build/ts/surfaces/customer-account/targets/customer-account.order-status.payment-details.render-after.d.ts +3 -0
- package/build/ts/surfaces/customer-account/targets/customer-account.order-status.return-details.render-after.d.ts +3 -0
- package/build/ts/surfaces/customer-account/targets/customer-account.order-status.unfulfilled-items.render-after.d.ts +3 -0
- package/build/ts/surfaces/customer-account/targets/customer-account.order.action.menu-item.render.d.ts +3 -0
- package/build/ts/surfaces/customer-account/targets/customer-account.order.action.render.d.ts +3 -0
- package/build/ts/surfaces/customer-account/targets/customer-account.order.page.render.d.ts +3 -0
- package/build/ts/surfaces/customer-account/targets/customer-account.page.render.d.ts +3 -0
- package/build/ts/surfaces/customer-account/targets/customer-account.profile.addresses.render-after.d.ts +3 -0
- package/build/ts/surfaces/customer-account/targets/customer-account.profile.announcement.render.d.ts +3 -0
- package/build/ts/surfaces/customer-account/targets/customer-account.profile.block.render.d.ts +3 -0
- package/build/ts/surfaces/customer-account/targets/customer-account.profile.company-details.render-after.d.ts +3 -0
- package/build/ts/surfaces/customer-account/targets/customer-account.profile.company-location-addresses.render-after.d.ts +3 -0
- package/build/ts/surfaces/customer-account/targets/customer-account.profile.company-location-payment.render-after.d.ts +3 -0
- package/build/ts/surfaces/customer-account/targets/customer-account.profile.company-location-staff.render-after.d.ts +3 -0
- package/build/ts/surfaces/customer-account/targets/customer-account.profile.payment.render-after.d.ts +3 -0
- package/build/ts/surfaces/point-of-sale/components/Badge.d.ts +10 -1
- package/build/ts/surfaces/point-of-sale/components/Banner.d.ts +12 -4
- package/build/ts/surfaces/point-of-sale/components/Box.d.ts +51 -14
- package/build/ts/surfaces/point-of-sale/components/Button.d.ts +12 -2
- package/build/ts/surfaces/point-of-sale/components/Choice.d.ts +3 -2
- package/build/ts/surfaces/point-of-sale/components/ChoiceList/ChoiceList.doc.d.ts.map +1 -1
- package/build/ts/surfaces/point-of-sale/components/ChoiceList.d.ts +13 -4
- package/build/ts/surfaces/point-of-sale/components/Clickable.d.ts +11 -4
- package/build/ts/surfaces/point-of-sale/components/DateField/DateField.doc.d.ts.map +1 -1
- package/build/ts/surfaces/point-of-sale/components/DateField.d.ts +20 -13
- package/build/ts/surfaces/point-of-sale/components/DatePicker/DatePicker.doc.d.ts.map +1 -1
- package/build/ts/surfaces/point-of-sale/components/DatePicker.d.ts +16 -4
- package/build/ts/surfaces/point-of-sale/components/DateSpinner/DateSpinner.doc.d.ts.map +1 -1
- package/build/ts/surfaces/point-of-sale/components/DateSpinner.d.ts +16 -4
- package/build/ts/surfaces/point-of-sale/components/Divider/Divider.doc.d.ts +4 -0
- package/build/ts/surfaces/point-of-sale/components/Divider/Divider.doc.d.ts.map +1 -0
- package/build/ts/surfaces/point-of-sale/components/Divider.d.ts +4 -3
- package/build/ts/surfaces/point-of-sale/components/EmailField/EmailField.doc.d.ts.map +1 -1
- package/build/ts/surfaces/point-of-sale/components/EmailField.d.ts +22 -5
- package/build/ts/surfaces/point-of-sale/components/Heading.d.ts +7 -4
- package/build/ts/surfaces/point-of-sale/components/Icon.d.ts +13 -3
- package/build/ts/surfaces/point-of-sale/components/Image.d.ts +12 -5
- package/build/ts/surfaces/point-of-sale/components/Modal.d.ts +28 -7
- package/build/ts/surfaces/point-of-sale/components/NumberField/NumberField.doc.d.ts.map +1 -1
- package/build/ts/surfaces/point-of-sale/components/NumberField.d.ts +32 -23
- package/build/ts/surfaces/point-of-sale/components/Page.d.ts +25 -11
- package/build/ts/surfaces/point-of-sale/components/PosBlock.d.ts +12 -13
- package/build/ts/surfaces/point-of-sale/components/QrCode.d.ts +12 -8
- package/build/ts/surfaces/point-of-sale/components/ScrollBox.d.ts +47 -15
- package/build/ts/surfaces/point-of-sale/components/SearchField/SearchField.doc.d.ts.map +1 -1
- package/build/ts/surfaces/point-of-sale/components/SearchField.d.ts +17 -5
- package/build/ts/surfaces/point-of-sale/components/Section.d.ts +15 -9
- package/build/ts/surfaces/point-of-sale/components/Stack.d.ts +67 -7
- package/build/ts/surfaces/point-of-sale/components/Text.d.ts +25 -4
- package/build/ts/surfaces/point-of-sale/components/TextArea/TextArea.doc.d.ts.map +1 -1
- package/build/ts/surfaces/point-of-sale/components/TextArea.d.ts +22 -5
- package/build/ts/surfaces/point-of-sale/components/TextField/TextField.doc.d.ts.map +1 -1
- package/build/ts/surfaces/point-of-sale/components/TextField.d.ts +22 -5
- package/build/ts/surfaces/point-of-sale/components/Tile.d.ts +12 -2
- package/build/ts/surfaces/point-of-sale/components/TimeField/TimeField.doc.d.ts.map +1 -1
- package/build/ts/surfaces/point-of-sale/components/TimeField.d.ts +18 -6
- package/build/ts/surfaces/point-of-sale/components/TimePicker/TimePicker.doc.d.ts.map +1 -1
- package/build/ts/surfaces/point-of-sale/components/TimePicker.d.ts +16 -4
- package/build/ts/surfaces/point-of-sale/components/components-shared.d.ts +102 -1
- package/build/tsconfig.tsbuildinfo +1 -1
- package/package.json +14 -3
- package/src/docs/shared/components/ConsentCheckbox.ts +12 -0
- package/src/docs/shared/components/ConsentPhoneField.ts +12 -0
- package/src/docs/shared/components/index.ts +2 -0
- package/src/surfaces/checkout/components/ConsentCheckbox/examples/basic-consent-checkbox.example.html +5 -0
- package/src/surfaces/checkout/components/ConsentCheckbox.d.ts +84 -0
- package/src/surfaces/checkout/components/ConsentPhoneField/examples/basic-consent-phone-field.example.html +5 -0
- package/src/surfaces/checkout/components/ConsentPhoneField.d.ts +129 -0
- package/src/surfaces/checkout/components/NumberField/examples/basic-number-field.example.html +8 -0
- package/src/surfaces/checkout/components/NumberField.d.ts +98 -0
- package/src/surfaces/checkout/components/PasswordField.d.ts +1 -1
- package/src/surfaces/checkout/components/PhoneField/examples/basic-phone-field.example.html +2 -1
- package/src/surfaces/checkout/components/ProductThumbnail/examples/basic-product-thumbnail.example.html +4 -1
- package/src/surfaces/checkout/components/Stack/examples/basic-stack.example.html +20 -4
- package/src/surfaces/checkout/components/TextArea/examples/basic-text-area.example.html +5 -1
- package/src/surfaces/checkout/components/TextField/examples/basic-text-field.example.html +4 -1
- package/src/surfaces/checkout/components/components-shared.d.ts +17 -0
- package/src/surfaces/checkout/components/components.d.ts +216 -144
- package/src/surfaces/checkout/preact/api.ts +1 -1
- package/src/surfaces/checkout/preact/tests/api.test.tsx +22 -13
- package/src/surfaces/checkout/preact/tests/app-metafields.test.ts +52 -56
- package/src/surfaces/checkout/preact/tests/attributes.test.ts +34 -24
- package/src/surfaces/checkout/preact/tests/billing-address.test.ts +17 -7
- package/src/surfaces/checkout/preact/tests/buyer-identity-businessCustomer.test.ts +16 -9
- package/src/surfaces/checkout/preact/tests/buyer-identity.test.tsx +57 -26
- package/src/surfaces/checkout/preact/tests/buyer-journey.test.ts +71 -74
- package/src/surfaces/checkout/preact/tests/capabilities.test.ts +32 -28
- package/src/surfaces/checkout/preact/tests/cart-line-target.test.ts +31 -24
- package/src/surfaces/checkout/preact/tests/checkout-settings.test.ts +17 -9
- package/src/surfaces/checkout/preact/tests/checkout-token.test.ts +16 -6
- package/src/surfaces/checkout/preact/tests/configuration.test.ts +16 -6
- package/src/surfaces/checkout/preact/tests/country.test.tsx +18 -8
- package/src/surfaces/checkout/preact/tests/currency.test.tsx +18 -8
- package/src/surfaces/checkout/preact/tests/customer-privacy.test.ts +17 -8
- package/src/surfaces/checkout/preact/tests/delivery-group-list-target.test.ts +24 -18
- package/src/surfaces/checkout/preact/tests/delivery-group-target.test.ts +25 -19
- package/src/surfaces/checkout/preact/tests/delivery-group.test.ts +22 -16
- package/src/surfaces/checkout/preact/tests/delivery-groups.test.ts +17 -11
- package/src/surfaces/checkout/preact/tests/delivery-selection-groups.test.ts +31 -24
- package/src/surfaces/checkout/preact/tests/discounts.test.tsx +21 -14
- package/src/surfaces/checkout/preact/tests/extension-language.test.tsx +17 -8
- package/src/surfaces/checkout/preact/tests/gift-cards.test.tsx +17 -8
- package/src/surfaces/checkout/preact/tests/localized-fields.test.ts +58 -59
- package/src/surfaces/checkout/preact/tests/market.test.tsx +17 -7
- package/src/surfaces/checkout/preact/tests/metafield.test.tsx +33 -36
- package/src/surfaces/checkout/preact/tests/metafields.test.tsx +36 -53
- package/src/surfaces/checkout/preact/tests/mount.tsx +60 -17
- package/src/surfaces/checkout/preact/tests/notes.test.tsx +16 -6
- package/src/surfaces/checkout/preact/tests/payment-method.test.ts +87 -60
- package/src/surfaces/checkout/preact/tests/payment-options.test.tsx +26 -24
- package/src/surfaces/checkout/preact/tests/pickup-location-option-target.test.tsx +55 -46
- package/src/surfaces/checkout/preact/tests/redeemable.test.ts +30 -23
- package/src/surfaces/checkout/preact/tests/session-token.test.tsx +12 -6
- package/src/surfaces/checkout/preact/tests/shipping-address.test.ts +17 -7
- package/src/surfaces/checkout/preact/tests/shipping-option-target.test.ts +54 -50
- package/src/surfaces/checkout/preact/tests/shopping-address.test.tsx +18 -10
- package/src/surfaces/checkout/preact/tests/timezone.test.tsx +17 -7
- package/src/surfaces/checkout/preact/tests/translate.test.tsx +18 -13
- package/src/surfaces/checkout/preact/tests/tsconfig.json +1 -1
- package/src/surfaces/checkout/shared.ts +2 -0
- package/src/surfaces/point-of-sale/components/Badge.d.ts +10 -1
- package/src/surfaces/point-of-sale/components/Banner/examples/default.html +8 -8
- package/src/surfaces/point-of-sale/components/Banner.d.ts +12 -4
- package/src/surfaces/point-of-sale/components/Box/examples/default.html +2 -2
- package/src/surfaces/point-of-sale/components/Box.d.ts +51 -14
- package/src/surfaces/point-of-sale/components/Button/examples/default.html +2 -4
- package/src/surfaces/point-of-sale/components/Button.d.ts +12 -2
- package/src/surfaces/point-of-sale/components/Choice.d.ts +3 -2
- package/src/surfaces/point-of-sale/components/ChoiceList/examples/default.html +5 -4
- package/src/surfaces/point-of-sale/components/ChoiceList/examples/event-handling.jsx +8 -0
- package/src/surfaces/point-of-sale/components/ChoiceList/examples/multiple-selection.jsx +9 -0
- package/src/surfaces/point-of-sale/components/ChoiceList.d.ts +13 -4
- package/src/surfaces/point-of-sale/components/Clickable/examples/default.html +5 -2
- package/src/surfaces/point-of-sale/components/Clickable.d.ts +11 -4
- package/src/surfaces/point-of-sale/components/DateField/examples/default.html +2 -10
- package/src/surfaces/point-of-sale/components/DateField/examples/event-handling.jsx +8 -0
- package/src/surfaces/point-of-sale/components/DateField.d.ts +20 -13
- package/src/surfaces/point-of-sale/components/DatePicker/examples/command-system.jsx +10 -0
- package/src/surfaces/point-of-sale/components/DatePicker/examples/default.html +4 -5
- package/src/surfaces/point-of-sale/components/DatePicker/examples/event-handling.jsx +7 -0
- package/src/surfaces/point-of-sale/components/DatePicker.d.ts +16 -4
- package/src/surfaces/point-of-sale/components/DateSpinner/examples/command-system.jsx +10 -0
- package/src/surfaces/point-of-sale/components/DateSpinner/examples/default.html +1 -2
- package/src/surfaces/point-of-sale/components/DateSpinner/examples/event-handling.jsx +7 -0
- package/src/surfaces/point-of-sale/components/DateSpinner.d.ts +16 -4
- package/src/surfaces/point-of-sale/components/Divider/examples/default.html +1 -0
- package/src/surfaces/point-of-sale/components/Divider.d.ts +4 -3
- package/src/surfaces/point-of-sale/components/EmailField/examples/accessory-slot.jsx +9 -0
- package/src/surfaces/point-of-sale/components/EmailField/examples/default.html +3 -10
- package/src/surfaces/point-of-sale/components/EmailField/examples/event-handling.jsx +8 -0
- package/src/surfaces/point-of-sale/components/EmailField.d.ts +22 -5
- package/src/surfaces/point-of-sale/components/Heading/examples/default.html +4 -5
- package/src/surfaces/point-of-sale/components/Heading.d.ts +7 -4
- package/src/surfaces/point-of-sale/components/Icon/examples/default.html +4 -1
- package/src/surfaces/point-of-sale/components/Icon.d.ts +13 -3
- package/src/surfaces/point-of-sale/components/Image/examples/default.html +1 -1
- package/src/surfaces/point-of-sale/components/Image.d.ts +12 -5
- package/src/surfaces/point-of-sale/components/Modal/examples/default.html +6 -8
- package/src/surfaces/point-of-sale/components/Modal.d.ts +28 -7
- package/src/surfaces/point-of-sale/components/NumberField/examples/controls-constraints.jsx +9 -0
- package/src/surfaces/point-of-sale/components/NumberField/examples/default.html +5 -2
- package/src/surfaces/point-of-sale/components/NumberField/examples/input-mode.jsx +15 -0
- package/src/surfaces/point-of-sale/components/NumberField.d.ts +32 -23
- package/src/surfaces/point-of-sale/components/Page/examples/default.html +3 -4
- package/src/surfaces/point-of-sale/components/Page.d.ts +25 -11
- package/src/surfaces/point-of-sale/components/PosBlock/examples/default.html +3 -9
- package/src/surfaces/point-of-sale/components/PosBlock.d.ts +12 -13
- package/src/surfaces/point-of-sale/components/QrCode.d.ts +12 -8
- package/src/surfaces/point-of-sale/components/ScrollBox/examples/default.html +5 -4
- package/src/surfaces/point-of-sale/components/ScrollBox.d.ts +47 -15
- package/src/surfaces/point-of-sale/components/SearchField/examples/default.html +1 -1
- package/src/surfaces/point-of-sale/components/SearchField/examples/event-handling.jsx +8 -0
- package/src/surfaces/point-of-sale/components/SearchField.d.ts +17 -5
- package/src/surfaces/point-of-sale/components/Section/examples/default.html +6 -8
- package/src/surfaces/point-of-sale/components/Section.d.ts +15 -9
- package/src/surfaces/point-of-sale/components/Stack/examples/default.html +3 -3
- package/src/surfaces/point-of-sale/components/Stack.d.ts +67 -7
- package/src/surfaces/point-of-sale/components/Text/examples/default.html +3 -6
- package/src/surfaces/point-of-sale/components/Text.d.ts +25 -4
- package/src/surfaces/point-of-sale/components/TextArea/examples/accessory-slot.jsx +9 -0
- package/src/surfaces/point-of-sale/components/TextArea/examples/default.html +4 -1
- package/src/surfaces/point-of-sale/components/TextArea/examples/event-handling.jsx +8 -0
- package/src/surfaces/point-of-sale/components/TextArea/examples/rows-configuration.jsx +7 -0
- package/src/surfaces/point-of-sale/components/TextArea.d.ts +22 -5
- package/src/surfaces/point-of-sale/components/TextField/examples/accessory-slot.jsx +5 -0
- package/src/surfaces/point-of-sale/components/TextField/examples/common-props.jsx +11 -0
- package/src/surfaces/point-of-sale/components/TextField/examples/default.html +5 -3
- package/src/surfaces/point-of-sale/components/TextField/examples/event-handling.jsx +17 -0
- package/src/surfaces/point-of-sale/components/TextField.d.ts +22 -5
- package/src/surfaces/point-of-sale/components/Tile/examples/default.html +2 -5
- package/src/surfaces/point-of-sale/components/Tile.d.ts +12 -2
- package/src/surfaces/point-of-sale/components/TimeField/examples/default.html +1 -9
- package/src/surfaces/point-of-sale/components/TimeField/examples/event-handling.jsx +8 -0
- package/src/surfaces/point-of-sale/components/TimeField.d.ts +18 -6
- package/src/surfaces/point-of-sale/components/TimePicker/examples/command-system.jsx +10 -0
- package/src/surfaces/point-of-sale/components/TimePicker/examples/default.html +4 -1
- package/src/surfaces/point-of-sale/components/TimePicker/examples/event-handling.jsx +7 -0
- package/src/surfaces/point-of-sale/components/TimePicker.d.ts +16 -4
- package/src/surfaces/point-of-sale/components/components-shared.d.ts +102 -1
- package/src/surfaces/point-of-sale/components.d.ts +957 -472
- package/build/ts/surfaces/checkout/errors.d.ts +0 -10
- package/build/ts/surfaces/checkout/errors.d.ts.map +0 -1
- package/src/surfaces/checkout/errors.ts +0 -13
|
@@ -26,7 +26,7 @@ export function useApi<
|
|
|
26
26
|
|
|
27
27
|
if (!api) {
|
|
28
28
|
throw new CheckoutUIExtensionError(
|
|
29
|
-
'You can only call this hook when running as a checkout UI extension on at least API version 2025-
|
|
29
|
+
'You can only call this hook when running as a checkout UI extension on at least API version 2025-10.',
|
|
30
30
|
);
|
|
31
31
|
}
|
|
32
32
|
return api;
|
|
@@ -1,30 +1,39 @@
|
|
|
1
|
-
/* eslint-disable jest/no-disabled-tests */
|
|
2
1
|
import {useApi} from '../api';
|
|
3
2
|
|
|
4
|
-
import {
|
|
3
|
+
import {
|
|
4
|
+
mount,
|
|
5
|
+
setupGlobalShopifyMock,
|
|
6
|
+
tearDownGlobalShopifyMock,
|
|
7
|
+
} from './mount';
|
|
8
|
+
|
|
9
|
+
describe('useApi', () => {
|
|
10
|
+
beforeEach(() => {
|
|
11
|
+
setupGlobalShopifyMock({});
|
|
12
|
+
});
|
|
13
|
+
|
|
14
|
+
afterEach(tearDownGlobalShopifyMock);
|
|
5
15
|
|
|
6
|
-
describe.skip('useApi', () => {
|
|
7
16
|
it('returns api', async () => {
|
|
8
|
-
const
|
|
9
|
-
|
|
10
|
-
};
|
|
11
|
-
const {value} = mount.hook(
|
|
12
|
-
() => useApi<'purchase.checkout.block.render'>(),
|
|
13
|
-
{
|
|
14
|
-
extensionApi,
|
|
15
|
-
},
|
|
17
|
+
const {value} = mount.hook(() =>
|
|
18
|
+
useApi<'purchase.checkout.block.render'>(),
|
|
16
19
|
);
|
|
17
20
|
|
|
18
|
-
expect(value).toMatchObject(
|
|
21
|
+
expect(value).toMatchObject({
|
|
22
|
+
extension: {target: 'purchase.checkout.block.render'},
|
|
23
|
+
});
|
|
19
24
|
});
|
|
20
25
|
|
|
21
26
|
it('throws when not run inside a checkout UI extension', async () => {
|
|
27
|
+
tearDownGlobalShopifyMock();
|
|
28
|
+
|
|
22
29
|
const runner = async () => {
|
|
23
30
|
return mount.hook(() => useApi());
|
|
24
31
|
};
|
|
25
32
|
|
|
26
33
|
await expect(runner).rejects.toThrow(
|
|
27
|
-
|
|
34
|
+
expect.objectContaining({
|
|
35
|
+
name: 'CheckoutUIExtensionError',
|
|
36
|
+
}),
|
|
28
37
|
);
|
|
29
38
|
});
|
|
30
39
|
});
|
|
@@ -1,22 +1,28 @@
|
|
|
1
1
|
import {faker} from '@faker-js/faker';
|
|
2
2
|
|
|
3
|
-
import type {
|
|
4
|
-
|
|
3
|
+
import type {AppMetafield} from '../../api/standard/standard';
|
|
5
4
|
import {useAppMetafields} from '../app-metafields';
|
|
6
5
|
|
|
7
|
-
import {
|
|
6
|
+
import {
|
|
7
|
+
mount,
|
|
8
|
+
createMockSubscribableSignalLike,
|
|
9
|
+
setupGlobalShopifyMock,
|
|
10
|
+
tearDownGlobalShopifyMock,
|
|
11
|
+
} from './mount';
|
|
8
12
|
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
+
// See __mocks__/preact/hooks
|
|
14
|
+
jest.mock('preact/hooks');
|
|
15
|
+
|
|
16
|
+
describe('useAppMetafields', () => {
|
|
17
|
+
afterEach(tearDownGlobalShopifyMock);
|
|
13
18
|
|
|
14
|
-
function createMetafield(props: Partial<
|
|
19
|
+
function createMetafield(props: Partial<AppMetafield> = {}): AppMetafield {
|
|
15
20
|
return {
|
|
16
21
|
key: `key-${faker.string.uuid()}`,
|
|
17
22
|
namespace: 'example-namespace',
|
|
18
23
|
value: 'example-value',
|
|
19
24
|
valueType: 'string',
|
|
25
|
+
type: 'string' as const,
|
|
20
26
|
...props,
|
|
21
27
|
};
|
|
22
28
|
}
|
|
@@ -33,25 +39,23 @@ describe.skip('useAppMetafields', () => {
|
|
|
33
39
|
|
|
34
40
|
it('returns all app metafield entries', () => {
|
|
35
41
|
const appMetaFieldEntries = [productEntry, variantEntry];
|
|
36
|
-
|
|
37
|
-
appMetafields:
|
|
38
|
-
};
|
|
42
|
+
setupGlobalShopifyMock({
|
|
43
|
+
appMetafields: createMockSubscribableSignalLike(appMetaFieldEntries),
|
|
44
|
+
});
|
|
39
45
|
|
|
40
|
-
const {value} = mount.hook(() => useAppMetafields()
|
|
46
|
+
const {value} = mount.hook(() => useAppMetafields());
|
|
41
47
|
|
|
42
48
|
expect(value).toMatchObject(appMetaFieldEntries);
|
|
43
49
|
});
|
|
44
50
|
|
|
45
51
|
it('returns filtered app metafield entries based on type', () => {
|
|
46
52
|
const appMetaFieldEntries = [productEntry, variantEntry];
|
|
47
|
-
|
|
48
|
-
appMetafields:
|
|
49
|
-
};
|
|
50
|
-
|
|
51
|
-
const {value} = mount.hook(() => useAppMetafields({type: 'product'}), {
|
|
52
|
-
extensionApi,
|
|
53
|
+
setupGlobalShopifyMock({
|
|
54
|
+
appMetafields: createMockSubscribableSignalLike(appMetaFieldEntries),
|
|
53
55
|
});
|
|
54
56
|
|
|
57
|
+
const {value} = mount.hook(() => useAppMetafields({type: 'product'}));
|
|
58
|
+
|
|
55
59
|
expect(value).toMatchObject([productEntry]);
|
|
56
60
|
});
|
|
57
61
|
|
|
@@ -63,14 +67,12 @@ describe.skip('useAppMetafields', () => {
|
|
|
63
67
|
};
|
|
64
68
|
|
|
65
69
|
const appMetaFieldEntries = [newEntry, variantEntry];
|
|
66
|
-
|
|
67
|
-
appMetafields:
|
|
68
|
-
};
|
|
69
|
-
|
|
70
|
-
const {value} = mount.hook(() => useAppMetafields({id: testId}), {
|
|
71
|
-
extensionApi,
|
|
70
|
+
setupGlobalShopifyMock({
|
|
71
|
+
appMetafields: createMockSubscribableSignalLike(appMetaFieldEntries),
|
|
72
72
|
});
|
|
73
73
|
|
|
74
|
+
const {value} = mount.hook(() => useAppMetafields({id: testId}));
|
|
75
|
+
|
|
74
76
|
expect(value).toMatchObject([newEntry]);
|
|
75
77
|
});
|
|
76
78
|
|
|
@@ -82,13 +84,12 @@ describe.skip('useAppMetafields', () => {
|
|
|
82
84
|
};
|
|
83
85
|
|
|
84
86
|
const appMetaFieldEntries = [newEntry, productEntry, variantEntry];
|
|
85
|
-
|
|
86
|
-
appMetafields:
|
|
87
|
-
};
|
|
87
|
+
setupGlobalShopifyMock({
|
|
88
|
+
appMetafields: createMockSubscribableSignalLike(appMetaFieldEntries),
|
|
89
|
+
});
|
|
88
90
|
|
|
89
|
-
const {value} = mount.hook(
|
|
90
|
-
|
|
91
|
-
{extensionApi},
|
|
91
|
+
const {value} = mount.hook(() =>
|
|
92
|
+
useAppMetafields({namespace: testNamespace}),
|
|
92
93
|
);
|
|
93
94
|
|
|
94
95
|
expect(value).toMatchObject([newEntry]);
|
|
@@ -103,13 +104,12 @@ describe.skip('useAppMetafields', () => {
|
|
|
103
104
|
};
|
|
104
105
|
|
|
105
106
|
const appMetaFieldEntries = [newEntry, productEntry, variantEntry];
|
|
106
|
-
|
|
107
|
-
appMetafields:
|
|
108
|
-
};
|
|
107
|
+
setupGlobalShopifyMock({
|
|
108
|
+
appMetafields: createMockSubscribableSignalLike(appMetaFieldEntries),
|
|
109
|
+
});
|
|
109
110
|
|
|
110
|
-
const {value} = mount.hook(
|
|
111
|
-
|
|
112
|
-
{extensionApi},
|
|
111
|
+
const {value} = mount.hook(() =>
|
|
112
|
+
useAppMetafields({namespace: testNamespace, key: testKey}),
|
|
113
113
|
);
|
|
114
114
|
|
|
115
115
|
expect(value).toMatchObject([newEntry]);
|
|
@@ -119,15 +119,13 @@ describe.skip('useAppMetafields', () => {
|
|
|
119
119
|
jest.spyOn(console, 'error').mockImplementation();
|
|
120
120
|
|
|
121
121
|
const appMetaFieldEntries = [productEntry, variantEntry];
|
|
122
|
-
|
|
123
|
-
appMetafields:
|
|
124
|
-
};
|
|
122
|
+
setupGlobalShopifyMock({
|
|
123
|
+
appMetafields: createMockSubscribableSignalLike(appMetaFieldEntries),
|
|
124
|
+
});
|
|
125
125
|
|
|
126
|
-
expect(() =>
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
}),
|
|
130
|
-
).toThrow('You must pass in a namespace with a key');
|
|
126
|
+
expect(() => mount.hook(() => useAppMetafields({key: 'test_key'}))).toThrow(
|
|
127
|
+
'You must pass in a namespace with a key',
|
|
128
|
+
);
|
|
131
129
|
});
|
|
132
130
|
|
|
133
131
|
it('returns filtered app metafield entries based on all searchable fields', () => {
|
|
@@ -141,19 +139,17 @@ describe.skip('useAppMetafields', () => {
|
|
|
141
139
|
};
|
|
142
140
|
|
|
143
141
|
const appMetaFieldEntries = [newEntry, productEntry, variantEntry];
|
|
144
|
-
|
|
145
|
-
appMetafields:
|
|
146
|
-
};
|
|
142
|
+
setupGlobalShopifyMock({
|
|
143
|
+
appMetafields: createMockSubscribableSignalLike(appMetaFieldEntries),
|
|
144
|
+
});
|
|
147
145
|
|
|
148
|
-
const {value} = mount.hook(
|
|
149
|
-
(
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
}),
|
|
156
|
-
{extensionApi},
|
|
146
|
+
const {value} = mount.hook(() =>
|
|
147
|
+
useAppMetafields({
|
|
148
|
+
namespace: testNamespace,
|
|
149
|
+
key: testKey,
|
|
150
|
+
id: testId,
|
|
151
|
+
type: 'product',
|
|
152
|
+
}),
|
|
157
153
|
);
|
|
158
154
|
|
|
159
155
|
expect(value).toMatchObject([newEntry]);
|
|
@@ -1,54 +1,64 @@
|
|
|
1
1
|
import {useAttributeValues, useAttributes} from '../attributes';
|
|
2
2
|
|
|
3
|
-
|
|
3
|
+
// See __mocks__/preact/hooks
|
|
4
|
+
jest.mock('preact/hooks');
|
|
5
|
+
|
|
6
|
+
import {
|
|
7
|
+
mount,
|
|
8
|
+
createMockSubscribableSignalLike,
|
|
9
|
+
setupGlobalShopifyMock,
|
|
10
|
+
tearDownGlobalShopifyMock,
|
|
11
|
+
} from './mount';
|
|
12
|
+
|
|
13
|
+
describe('Attributes API hooks', () => {
|
|
14
|
+
afterEach(tearDownGlobalShopifyMock);
|
|
4
15
|
|
|
5
|
-
describe.skip('Attributes API hooks', () => {
|
|
6
16
|
describe('useAttributes', () => {
|
|
7
17
|
it('returns an empty array if no attributes are available', () => {
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
attributes: createMockStatefulRemoteSubscribable([]),
|
|
11
|
-
},
|
|
18
|
+
setupGlobalShopifyMock({
|
|
19
|
+
attributes: createMockSubscribableSignalLike([]),
|
|
12
20
|
});
|
|
13
21
|
|
|
22
|
+
const {value} = mount.hook(() => useAttributes());
|
|
23
|
+
|
|
14
24
|
expect(value).toStrictEqual([]);
|
|
15
25
|
});
|
|
16
26
|
|
|
17
27
|
it('returns an array of attributes if available', () => {
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
]),
|
|
23
|
-
},
|
|
28
|
+
setupGlobalShopifyMock({
|
|
29
|
+
attributes: createMockSubscribableSignalLike([
|
|
30
|
+
{key: 'foo', value: 'bar'},
|
|
31
|
+
]),
|
|
24
32
|
});
|
|
25
33
|
|
|
34
|
+
const {value} = mount.hook(() => useAttributes());
|
|
35
|
+
|
|
26
36
|
expect(value).toStrictEqual([{key: 'foo', value: 'bar'}]);
|
|
27
37
|
});
|
|
28
38
|
});
|
|
29
39
|
|
|
30
40
|
describe('useAttributeValues', () => {
|
|
31
41
|
it('returns an array of attribute values if available', () => {
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
]),
|
|
37
|
-
},
|
|
42
|
+
setupGlobalShopifyMock({
|
|
43
|
+
attributes: createMockSubscribableSignalLike([
|
|
44
|
+
{key: 'foo', value: 'bar'},
|
|
45
|
+
]),
|
|
38
46
|
});
|
|
39
47
|
|
|
48
|
+
const {value} = mount.hook(() => useAttributeValues(['foo']));
|
|
49
|
+
|
|
40
50
|
expect(value).toStrictEqual(['bar']);
|
|
41
51
|
});
|
|
42
52
|
|
|
43
53
|
it('returns an array with undefined values if a non-existent attribute is requested', () => {
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
]),
|
|
49
|
-
},
|
|
54
|
+
setupGlobalShopifyMock({
|
|
55
|
+
attributes: createMockSubscribableSignalLike([
|
|
56
|
+
{key: 'bar', value: 'baz'},
|
|
57
|
+
]),
|
|
50
58
|
});
|
|
51
59
|
|
|
60
|
+
const {value} = mount.hook(() => useAttributeValues(['foo', 'bar']));
|
|
61
|
+
|
|
52
62
|
expect(value).toStrictEqual([undefined, 'baz']);
|
|
53
63
|
});
|
|
54
64
|
});
|
|
@@ -1,17 +1,27 @@
|
|
|
1
|
-
import type {MailingAddress} from '
|
|
1
|
+
import type {MailingAddress} from '../../api/shared';
|
|
2
2
|
|
|
3
3
|
import {useBillingAddress} from '../billing-address';
|
|
4
4
|
|
|
5
|
-
|
|
5
|
+
// See __mocks__/preact/hooks
|
|
6
|
+
jest.mock('preact/hooks');
|
|
7
|
+
|
|
8
|
+
import {
|
|
9
|
+
mount,
|
|
10
|
+
createMockSubscribableSignalLike,
|
|
11
|
+
setupGlobalShopifyMock,
|
|
12
|
+
tearDownGlobalShopifyMock,
|
|
13
|
+
} from './mount';
|
|
14
|
+
|
|
15
|
+
describe('useBillingAddress', () => {
|
|
16
|
+
afterEach(tearDownGlobalShopifyMock);
|
|
6
17
|
|
|
7
|
-
describe.skip('useBillingAddress', () => {
|
|
8
18
|
it('returns latest billing address', async () => {
|
|
9
19
|
const address: MailingAddress = {countryCode: 'CA'};
|
|
10
|
-
|
|
11
|
-
billingAddress:
|
|
12
|
-
};
|
|
20
|
+
setupGlobalShopifyMock({
|
|
21
|
+
billingAddress: createMockSubscribableSignalLike(address),
|
|
22
|
+
});
|
|
13
23
|
|
|
14
|
-
const {value} = mount.hook(() => useBillingAddress()
|
|
24
|
+
const {value} = mount.hook(() => useBillingAddress());
|
|
15
25
|
|
|
16
26
|
expect(value).toMatchObject(address);
|
|
17
27
|
});
|
|
@@ -1,8 +1,18 @@
|
|
|
1
1
|
import {usePurchasingCompany} from '../buyer-identity';
|
|
2
2
|
|
|
3
|
-
|
|
3
|
+
// See __mocks__/preact/hooks
|
|
4
|
+
jest.mock('preact/hooks');
|
|
5
|
+
|
|
6
|
+
import {
|
|
7
|
+
mount,
|
|
8
|
+
createMockSubscribableSignalLike,
|
|
9
|
+
setupGlobalShopifyMock,
|
|
10
|
+
tearDownGlobalShopifyMock,
|
|
11
|
+
} from './mount';
|
|
12
|
+
|
|
13
|
+
describe('usePurchasingCompany', () => {
|
|
14
|
+
afterEach(tearDownGlobalShopifyMock);
|
|
4
15
|
|
|
5
|
-
describe.skip('usePurchasingCompany', () => {
|
|
6
16
|
it('returns purchasing company from the api', () => {
|
|
7
17
|
const purchasingCompany = {
|
|
8
18
|
company: {
|
|
@@ -17,17 +27,14 @@ describe.skip('usePurchasingCompany', () => {
|
|
|
17
27
|
},
|
|
18
28
|
};
|
|
19
29
|
|
|
20
|
-
|
|
30
|
+
setupGlobalShopifyMock({
|
|
21
31
|
buyerIdentity: {
|
|
22
|
-
purchasingCompany:
|
|
23
|
-
createMockStatefulRemoteSubscribable(purchasingCompany),
|
|
32
|
+
purchasingCompany: createMockSubscribableSignalLike(purchasingCompany),
|
|
24
33
|
},
|
|
25
|
-
};
|
|
26
|
-
|
|
27
|
-
const {value} = mount.hook(() => usePurchasingCompany(), {
|
|
28
|
-
extensionApi,
|
|
29
34
|
});
|
|
30
35
|
|
|
36
|
+
const {value} = mount.hook(() => usePurchasingCompany());
|
|
37
|
+
|
|
31
38
|
expect(value).toStrictEqual(purchasingCompany);
|
|
32
39
|
});
|
|
33
40
|
});
|
|
@@ -1,11 +1,18 @@
|
|
|
1
|
-
import type {SubscribableSignalLike} from '../../shared';
|
|
2
1
|
import {faker} from '@faker-js/faker';
|
|
3
2
|
|
|
4
|
-
import {
|
|
3
|
+
import type {SubscribableSignalLike} from '../../shared';
|
|
5
4
|
import {useCustomer, useEmail, usePhone} from '../buyer-identity';
|
|
6
5
|
|
|
7
|
-
import {
|
|
8
|
-
|
|
6
|
+
import {
|
|
7
|
+
mount,
|
|
8
|
+
setupGlobalShopifyMock,
|
|
9
|
+
tearDownGlobalShopifyMock,
|
|
10
|
+
} from './mount';
|
|
11
|
+
|
|
12
|
+
// See __mocks__/preact/hooks
|
|
13
|
+
jest.mock('preact/hooks');
|
|
14
|
+
|
|
15
|
+
function createMockCustomer(customer = {}): any {
|
|
9
16
|
const firstName = faker.person.firstName();
|
|
10
17
|
const lastName = faker.person.lastName();
|
|
11
18
|
|
|
@@ -21,26 +28,29 @@ function createMockCustomer(customer = {}) {
|
|
|
21
28
|
}
|
|
22
29
|
|
|
23
30
|
function createEmptyContext() {
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
};
|
|
31
|
+
// Set up a global shopify object without buyerIdentity to trigger ScopeNotGrantedError
|
|
32
|
+
setupGlobalShopifyMock({
|
|
33
|
+
buyerIdentity: undefined,
|
|
34
|
+
});
|
|
35
|
+
return {};
|
|
29
36
|
}
|
|
30
37
|
|
|
31
38
|
function createUseEmailContext(email?: string) {
|
|
32
|
-
|
|
39
|
+
setupGlobalShopify(email, undefined, undefined);
|
|
40
|
+
return {};
|
|
33
41
|
}
|
|
34
42
|
|
|
35
43
|
function createUseCustomerContext(customer = {}) {
|
|
36
|
-
|
|
44
|
+
setupGlobalShopify(undefined, undefined, customer);
|
|
45
|
+
return {};
|
|
37
46
|
}
|
|
38
47
|
|
|
39
48
|
function createUsePhoneContext(phone?: string) {
|
|
40
|
-
|
|
49
|
+
setupGlobalShopify(undefined, phone, undefined);
|
|
50
|
+
return {};
|
|
41
51
|
}
|
|
42
52
|
|
|
43
|
-
function
|
|
53
|
+
function createMockSubscribable<T>(data: T): SubscribableSignalLike<T> {
|
|
44
54
|
return {
|
|
45
55
|
current: data,
|
|
46
56
|
value: data,
|
|
@@ -49,24 +59,37 @@ function createMockSuscribable<T>(data: T): SubscribableSignalLike<T> {
|
|
|
49
59
|
};
|
|
50
60
|
}
|
|
51
61
|
|
|
52
|
-
function
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
62
|
+
function setupGlobalShopify(
|
|
63
|
+
email?: string,
|
|
64
|
+
phone?: string,
|
|
65
|
+
customer: any = {},
|
|
66
|
+
) {
|
|
67
|
+
const customerData =
|
|
68
|
+
email || Object.keys(customer).length > 0
|
|
69
|
+
? createMockCustomer(customer)
|
|
70
|
+
: undefined;
|
|
71
|
+
setupGlobalShopifyMock({
|
|
72
|
+
buyerIdentity: {
|
|
73
|
+
customer: createMockSubscribable(customerData),
|
|
74
|
+
email: createMockSubscribable(email),
|
|
75
|
+
phone: createMockSubscribable(phone),
|
|
76
|
+
purchasingCompany: createMockSubscribable(undefined),
|
|
60
77
|
},
|
|
61
|
-
};
|
|
78
|
+
});
|
|
62
79
|
}
|
|
63
80
|
|
|
64
|
-
describe
|
|
81
|
+
describe('buyerIdentity Hooks', () => {
|
|
82
|
+
afterEach(tearDownGlobalShopifyMock);
|
|
83
|
+
|
|
65
84
|
describe('useCustomer()', () => {
|
|
66
85
|
it('raises an exception without CustomerPersonalData ApprovalScope', () => {
|
|
67
86
|
expect(() => {
|
|
68
87
|
mount.hook(() => useCustomer(), createEmptyContext());
|
|
69
|
-
}).toThrow(
|
|
88
|
+
}).toThrow(
|
|
89
|
+
expect.objectContaining({
|
|
90
|
+
name: 'ScopeNotGrantedError',
|
|
91
|
+
}),
|
|
92
|
+
);
|
|
70
93
|
});
|
|
71
94
|
|
|
72
95
|
it('returns undefined fields with CustomerPersonalData ApprovalScopes only', () => {
|
|
@@ -113,7 +136,11 @@ describe.skip('buyerIdentity Hooks', () => {
|
|
|
113
136
|
it('raises an exception without CustomerPersonalData ApprovalScope', () => {
|
|
114
137
|
expect(() => {
|
|
115
138
|
mount.hook(() => useEmail(), createEmptyContext());
|
|
116
|
-
}).toThrow(
|
|
139
|
+
}).toThrow(
|
|
140
|
+
expect.objectContaining({
|
|
141
|
+
name: 'ScopeNotGrantedError',
|
|
142
|
+
}),
|
|
143
|
+
);
|
|
117
144
|
});
|
|
118
145
|
|
|
119
146
|
it('returns undefined with CustomerPersonalData ApprovalScope only', () => {
|
|
@@ -135,7 +162,11 @@ describe.skip('buyerIdentity Hooks', () => {
|
|
|
135
162
|
it('raises an exception without CustomerPersonalData ApprovalScope', () => {
|
|
136
163
|
expect(() => {
|
|
137
164
|
mount.hook(() => usePhone(), createEmptyContext());
|
|
138
|
-
}).toThrow(
|
|
165
|
+
}).toThrow(
|
|
166
|
+
expect.objectContaining({
|
|
167
|
+
name: 'ScopeNotGrantedError',
|
|
168
|
+
}),
|
|
169
|
+
);
|
|
139
170
|
});
|
|
140
171
|
|
|
141
172
|
it('returns undefined with CustomerPersonalData ApprovalScope only', () => {
|