@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
|
@@ -1,19 +1,29 @@
|
|
|
1
1
|
import {useLocalizationMarket} from '../market';
|
|
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('useLocalizationMarket', () => {
|
|
14
|
+
afterEach(tearDownGlobalShopifyMock);
|
|
4
15
|
|
|
5
|
-
describe.skip('useLocalizationMarket', () => {
|
|
6
16
|
it('returns market from the api', () => {
|
|
7
17
|
const market = {id: 'gid://shopify/Market/123', handle: 'apac'};
|
|
8
18
|
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
market: createMockStatefulRemoteSubscribable(market),
|
|
13
|
-
},
|
|
19
|
+
setupGlobalShopifyMock({
|
|
20
|
+
localization: {
|
|
21
|
+
market: createMockSubscribableSignalLike(market),
|
|
14
22
|
},
|
|
15
23
|
});
|
|
16
24
|
|
|
25
|
+
const {value} = mount.hook(() => useLocalizationMarket());
|
|
26
|
+
|
|
17
27
|
expect(value).toStrictEqual(market);
|
|
18
28
|
});
|
|
19
29
|
});
|
|
@@ -1,15 +1,21 @@
|
|
|
1
1
|
import {faker} from '@faker-js/faker';
|
|
2
2
|
|
|
3
|
-
import type {Metafield} from '
|
|
3
|
+
import type {Metafield} from '../../api/standard/standard';
|
|
4
4
|
|
|
5
5
|
import {useMetafield} from '../metafield';
|
|
6
6
|
|
|
7
|
-
import {
|
|
7
|
+
import {
|
|
8
|
+
createMockSubscribableSignalLike,
|
|
9
|
+
mount,
|
|
10
|
+
setupGlobalShopifyMock,
|
|
11
|
+
tearDownGlobalShopifyMock,
|
|
12
|
+
} from './mount';
|
|
8
13
|
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
14
|
+
// See __mocks__/preact/hooks
|
|
15
|
+
jest.mock('preact/hooks');
|
|
16
|
+
|
|
17
|
+
describe('useMetafields', () => {
|
|
18
|
+
afterEach(tearDownGlobalShopifyMock);
|
|
13
19
|
|
|
14
20
|
function createMetafield(props: Partial<Metafield> = {}): Metafield {
|
|
15
21
|
return {
|
|
@@ -28,18 +34,16 @@ describe.skip('useMetafields', () => {
|
|
|
28
34
|
it('returns undefined metafield', () => {
|
|
29
35
|
const metafieldCount = 10;
|
|
30
36
|
|
|
31
|
-
|
|
32
|
-
metafields:
|
|
37
|
+
setupGlobalShopifyMock({
|
|
38
|
+
metafields: createMockSubscribableSignalLike(
|
|
33
39
|
createMetafields(metafieldCount),
|
|
34
|
-
),
|
|
35
|
-
};
|
|
40
|
+
) as any,
|
|
41
|
+
});
|
|
36
42
|
|
|
37
43
|
const namespace = 'test_namespace';
|
|
38
44
|
const key = 'test_key';
|
|
39
45
|
|
|
40
|
-
const {value} = mount.hook(() => useMetafield({namespace, key})
|
|
41
|
-
extensionApi,
|
|
42
|
-
});
|
|
46
|
+
const {value} = mount.hook(() => useMetafield({namespace, key}));
|
|
43
47
|
|
|
44
48
|
expect(value).toBeUndefined();
|
|
45
49
|
});
|
|
@@ -51,12 +55,12 @@ describe.skip('useMetafields', () => {
|
|
|
51
55
|
|
|
52
56
|
const metafields = [newNamespace, ...createMetafields()];
|
|
53
57
|
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
metafields: createMockStatefulRemoteSubscribable(metafields),
|
|
57
|
-
},
|
|
58
|
+
setupGlobalShopifyMock({
|
|
59
|
+
metafields: createMockSubscribableSignalLike(metafields),
|
|
58
60
|
});
|
|
59
61
|
|
|
62
|
+
const {value} = mount.hook(() => useMetafield({namespace, key}));
|
|
63
|
+
|
|
60
64
|
expect(value?.namespace).toStrictEqual(namespace);
|
|
61
65
|
expect(value?.key).toStrictEqual(key);
|
|
62
66
|
});
|
|
@@ -64,21 +68,16 @@ describe.skip('useMetafields', () => {
|
|
|
64
68
|
it('throws an error if no namespace is provided with key', () => {
|
|
65
69
|
jest.spyOn(console, 'error').mockImplementation();
|
|
66
70
|
|
|
67
|
-
|
|
68
|
-
metafields:
|
|
69
|
-
};
|
|
71
|
+
setupGlobalShopifyMock({
|
|
72
|
+
metafields: createMockSubscribableSignalLike(createMetafields()) as any,
|
|
73
|
+
});
|
|
70
74
|
|
|
71
75
|
expect(() =>
|
|
72
|
-
mount.hook(
|
|
73
|
-
(
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
key: 'test_key',
|
|
78
|
-
}),
|
|
79
|
-
{
|
|
80
|
-
extensionApi,
|
|
81
|
-
},
|
|
76
|
+
mount.hook(() =>
|
|
77
|
+
useMetafield({
|
|
78
|
+
namespace: undefined as unknown as string,
|
|
79
|
+
key: 'test_key',
|
|
80
|
+
}),
|
|
82
81
|
),
|
|
83
82
|
).toThrow('You must pass in both a namespace and key');
|
|
84
83
|
});
|
|
@@ -86,16 +85,14 @@ describe.skip('useMetafields', () => {
|
|
|
86
85
|
it('throws an error if no key is provided with namespace', () => {
|
|
87
86
|
jest.spyOn(console, 'error').mockImplementation();
|
|
88
87
|
|
|
89
|
-
|
|
90
|
-
metafields:
|
|
91
|
-
};
|
|
88
|
+
setupGlobalShopifyMock({
|
|
89
|
+
metafields: createMockSubscribableSignalLike(createMetafields()) as any,
|
|
90
|
+
});
|
|
92
91
|
|
|
93
92
|
const key = undefined as unknown as string;
|
|
94
93
|
|
|
95
94
|
expect(() =>
|
|
96
|
-
mount.hook(() => useMetafield({namespace: 'test_namespace', key}),
|
|
97
|
-
extensionApi,
|
|
98
|
-
}),
|
|
95
|
+
mount.hook(() => useMetafield({namespace: 'test_namespace', key})),
|
|
99
96
|
).toThrow('You must pass in both a namespace and key');
|
|
100
97
|
});
|
|
101
98
|
});
|
|
@@ -1,15 +1,21 @@
|
|
|
1
1
|
import {faker} from '@faker-js/faker';
|
|
2
2
|
|
|
3
|
-
import type {Metafield} from '
|
|
3
|
+
import type {Metafield} from '../../api/standard/standard';
|
|
4
4
|
|
|
5
5
|
import {useMetafields} from '../metafields';
|
|
6
6
|
|
|
7
|
-
import {
|
|
7
|
+
import {
|
|
8
|
+
createMockSubscribableSignalLike,
|
|
9
|
+
mount,
|
|
10
|
+
setupGlobalShopifyMock,
|
|
11
|
+
tearDownGlobalShopifyMock,
|
|
12
|
+
} from './mount';
|
|
8
13
|
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
14
|
+
// See __mocks__/preact/hooks
|
|
15
|
+
jest.mock('preact/hooks');
|
|
16
|
+
|
|
17
|
+
describe('useMetafields', () => {
|
|
18
|
+
afterEach(tearDownGlobalShopifyMock);
|
|
13
19
|
|
|
14
20
|
function createMetafield(props: Partial<Metafield> = {}): Metafield {
|
|
15
21
|
return {
|
|
@@ -28,14 +34,14 @@ describe.skip('useMetafields', () => {
|
|
|
28
34
|
it('returns all metafields', () => {
|
|
29
35
|
const metafieldCount = 10;
|
|
30
36
|
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
),
|
|
36
|
-
},
|
|
37
|
+
setupGlobalShopifyMock({
|
|
38
|
+
metafields: createMockSubscribableSignalLike(
|
|
39
|
+
createMetafields(metafieldCount),
|
|
40
|
+
) as any,
|
|
37
41
|
});
|
|
38
42
|
|
|
43
|
+
const {value} = mount.hook(() => useMetafields());
|
|
44
|
+
|
|
39
45
|
expect(value).toHaveLength(metafieldCount);
|
|
40
46
|
});
|
|
41
47
|
|
|
@@ -49,18 +55,18 @@ describe.skip('useMetafields', () => {
|
|
|
49
55
|
|
|
50
56
|
const metafields = [newNamespace, newNamespace2, ...createMetafields()];
|
|
51
57
|
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
metafields: createMockStatefulRemoteSubscribable(metafields),
|
|
55
|
-
},
|
|
58
|
+
setupGlobalShopifyMock({
|
|
59
|
+
metafields: createMockSubscribableSignalLike(metafields),
|
|
56
60
|
});
|
|
57
61
|
|
|
62
|
+
const {value} = mount.hook(() => useMetafields({namespace}));
|
|
63
|
+
|
|
58
64
|
expect(value).toHaveLength(2);
|
|
59
65
|
|
|
60
66
|
expect(value[0].namespace).toStrictEqual(namespace);
|
|
61
|
-
expect(value[1].namespace).toStrictEqual(namespace);
|
|
62
|
-
|
|
63
67
|
expect(value[0].key).toStrictEqual(key);
|
|
68
|
+
|
|
69
|
+
expect(value[1].namespace).toStrictEqual(namespace);
|
|
64
70
|
expect(value[1].key).toStrictEqual(key2);
|
|
65
71
|
});
|
|
66
72
|
|
|
@@ -69,54 +75,31 @@ describe.skip('useMetafields', () => {
|
|
|
69
75
|
const key = 'test_key';
|
|
70
76
|
const newNamespace = createMetafield({namespace, key});
|
|
71
77
|
|
|
72
|
-
const
|
|
78
|
+
const key2 = 'test_key2';
|
|
79
|
+
const newNamespace2 = createMetafield({namespace, key: key2});
|
|
73
80
|
|
|
74
|
-
const
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
81
|
+
const metafields = [newNamespace, newNamespace2, ...createMetafields()];
|
|
82
|
+
|
|
83
|
+
setupGlobalShopifyMock({
|
|
84
|
+
metafields: createMockSubscribableSignalLike(metafields),
|
|
78
85
|
});
|
|
79
86
|
|
|
87
|
+
const {value} = mount.hook(() => useMetafields({namespace, key}));
|
|
88
|
+
|
|
80
89
|
expect(value).toHaveLength(1);
|
|
81
90
|
expect(value[0].namespace).toStrictEqual(namespace);
|
|
82
91
|
expect(value[0].key).toStrictEqual(key);
|
|
83
92
|
});
|
|
84
93
|
|
|
85
|
-
it('returns an empty array if no matches are found', () => {
|
|
86
|
-
const namespace = 'test_namespace';
|
|
87
|
-
const key = 'test_key';
|
|
88
|
-
|
|
89
|
-
const metafields = createMetafields();
|
|
90
|
-
|
|
91
|
-
const extensionApi = {
|
|
92
|
-
metafields: createMockStatefulRemoteSubscribable(metafields),
|
|
93
|
-
};
|
|
94
|
-
|
|
95
|
-
const namespaceSearch = mount.hook(() => useMetafields({namespace}), {
|
|
96
|
-
extensionApi,
|
|
97
|
-
});
|
|
98
|
-
|
|
99
|
-
const keySearch = mount.hook(() => useMetafields({namespace, key}), {
|
|
100
|
-
extensionApi,
|
|
101
|
-
});
|
|
102
|
-
|
|
103
|
-
expect(namespaceSearch.value).toHaveLength(0);
|
|
104
|
-
expect(keySearch.value).toHaveLength(0);
|
|
105
|
-
});
|
|
106
|
-
|
|
107
94
|
it('throws an error if no namespace is provided with key', () => {
|
|
108
95
|
jest.spyOn(console, 'error').mockImplementation();
|
|
109
96
|
|
|
110
|
-
|
|
111
|
-
metafields:
|
|
112
|
-
};
|
|
113
|
-
|
|
114
|
-
const namespace = undefined as unknown as string;
|
|
97
|
+
setupGlobalShopifyMock({
|
|
98
|
+
metafields: createMockSubscribableSignalLike(createMetafields()) as any,
|
|
99
|
+
});
|
|
115
100
|
|
|
116
101
|
expect(() =>
|
|
117
|
-
mount.hook(() => useMetafields({
|
|
118
|
-
extensionApi,
|
|
119
|
-
}),
|
|
102
|
+
mount.hook(() => useMetafields({key: 'test_key'} as any)),
|
|
120
103
|
).toThrow('You must pass in a namespace with a key');
|
|
121
104
|
});
|
|
122
105
|
});
|
|
@@ -1,27 +1,28 @@
|
|
|
1
1
|
import {createRender} from '@quilted/react-testing';
|
|
2
2
|
import type {SubscribableSignalLike} from '../../shared';
|
|
3
|
+
import type {ExtensionTargets} from '../../extension-targets';
|
|
3
4
|
|
|
4
5
|
import type {
|
|
5
6
|
ApiForExtension,
|
|
6
7
|
RenderExtensionTarget,
|
|
7
|
-
} from '
|
|
8
|
+
} from '../../extension-targets';
|
|
9
|
+
import type {Extension} from '../../api/standard/standard';
|
|
8
10
|
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
11
|
+
declare global {
|
|
12
|
+
namespace NodeJS {
|
|
13
|
+
interface Global {
|
|
14
|
+
shopify: any;
|
|
15
|
+
}
|
|
16
|
+
}
|
|
17
|
+
}
|
|
13
18
|
|
|
14
19
|
export const mount = createRender<Options, Options>({
|
|
15
|
-
context(options) {
|
|
20
|
+
context(options: Options) {
|
|
16
21
|
return options;
|
|
17
22
|
},
|
|
18
23
|
|
|
19
|
-
render(element
|
|
20
|
-
return
|
|
21
|
-
<ExtensionApiContext.Provider value={extensionApi as any}>
|
|
22
|
-
{element}
|
|
23
|
-
</ExtensionApiContext.Provider>
|
|
24
|
-
);
|
|
24
|
+
render(element: any) {
|
|
25
|
+
return element;
|
|
25
26
|
},
|
|
26
27
|
});
|
|
27
28
|
|
|
@@ -33,20 +34,62 @@ export type PartialExtensionApi = DeepPartial<
|
|
|
33
34
|
ApiForExtension<RenderExtensionTarget>
|
|
34
35
|
>;
|
|
35
36
|
|
|
36
|
-
interface Options {
|
|
37
|
-
extensionApi?: PartialExtensionApi;
|
|
38
|
-
}
|
|
37
|
+
interface Options {}
|
|
39
38
|
|
|
40
|
-
export function
|
|
39
|
+
export function createMockSubscribableSignalLike<T>(
|
|
41
40
|
value: T,
|
|
42
41
|
): SubscribableSignalLike<T> {
|
|
43
42
|
const subscribable: SubscribableSignalLike<T> = {
|
|
44
43
|
get current() {
|
|
45
44
|
return value;
|
|
46
45
|
},
|
|
47
|
-
|
|
46
|
+
get value() {
|
|
47
|
+
return value;
|
|
48
|
+
},
|
|
49
|
+
subscribe: jest.fn(() => () => {}),
|
|
48
50
|
destroy: jest.fn(),
|
|
49
51
|
};
|
|
50
52
|
|
|
51
53
|
return subscribable;
|
|
52
54
|
}
|
|
55
|
+
|
|
56
|
+
/**
|
|
57
|
+
* Helper function to set up the global shopify mock with type safety
|
|
58
|
+
* @param mockData Deep partial mock data for the API
|
|
59
|
+
*/
|
|
60
|
+
export function setupGlobalShopifyMock<
|
|
61
|
+
Target extends RenderExtensionTarget = 'purchase.checkout.block.render',
|
|
62
|
+
>(mockData: DeepPartial<ExtensionTargets[Target]['api']>): void {
|
|
63
|
+
const finalMockData = {
|
|
64
|
+
extension: createMockExtension<Target>(
|
|
65
|
+
'purchase.checkout.block.render' as Target,
|
|
66
|
+
),
|
|
67
|
+
...mockData,
|
|
68
|
+
} as DeepPartial<ExtensionTargets[Target]['api']>;
|
|
69
|
+
|
|
70
|
+
(globalThis as any).shopify = finalMockData;
|
|
71
|
+
}
|
|
72
|
+
|
|
73
|
+
/**
|
|
74
|
+
* Helper function to tear down the global shopify mock
|
|
75
|
+
* Call this in afterEach() to clean up the global shopify object and clear all mocks
|
|
76
|
+
*/
|
|
77
|
+
export function tearDownGlobalShopifyMock(): void {
|
|
78
|
+
delete (globalThis as any).shopify;
|
|
79
|
+
jest.clearAllMocks();
|
|
80
|
+
}
|
|
81
|
+
|
|
82
|
+
/**
|
|
83
|
+
* Helper function to create a minimal extension object for testing
|
|
84
|
+
*/
|
|
85
|
+
export function createMockExtension<Target extends RenderExtensionTarget>(
|
|
86
|
+
target: Target,
|
|
87
|
+
): Extension<Target> {
|
|
88
|
+
return {
|
|
89
|
+
target,
|
|
90
|
+
apiVersion: '2023-07',
|
|
91
|
+
capabilities: createMockSubscribableSignalLike([]),
|
|
92
|
+
rendered: createMockSubscribableSignalLike(true),
|
|
93
|
+
scriptUrl: 'https://example.com/script.js',
|
|
94
|
+
};
|
|
95
|
+
}
|
|
@@ -1,15 +1,25 @@
|
|
|
1
1
|
import {useNote} from '../note';
|
|
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('useNote', () => {
|
|
14
|
+
afterEach(tearDownGlobalShopifyMock);
|
|
4
15
|
|
|
5
|
-
describe.skip('useNote', () => {
|
|
6
16
|
it('returns the current order note', async () => {
|
|
7
17
|
const note = 'the note';
|
|
8
|
-
|
|
9
|
-
note:
|
|
10
|
-
};
|
|
18
|
+
setupGlobalShopifyMock({
|
|
19
|
+
note: createMockSubscribableSignalLike(note),
|
|
20
|
+
});
|
|
11
21
|
|
|
12
|
-
const {value} = mount.hook(() => useNote()
|
|
22
|
+
const {value} = mount.hook(() => useNote());
|
|
13
23
|
|
|
14
24
|
expect(value).toBe(note);
|
|
15
25
|
});
|
|
@@ -1,116 +1,143 @@
|
|
|
1
|
-
import type {ExtensionTarget} from '
|
|
1
|
+
import type {ExtensionTarget} from '../../extension-targets';
|
|
2
|
+
|
|
3
|
+
// See __mocks__/preact/hooks
|
|
4
|
+
jest.mock('preact/hooks');
|
|
2
5
|
|
|
3
6
|
import {
|
|
4
7
|
useApplyPaymentMethodAttributesChange,
|
|
5
8
|
usePaymentMethodAttributeValues,
|
|
6
9
|
usePaymentMethodAttributes,
|
|
7
10
|
} from '../payment-method';
|
|
8
|
-
import {
|
|
11
|
+
import {
|
|
12
|
+
createMockSubscribableSignalLike,
|
|
13
|
+
mount,
|
|
14
|
+
setupGlobalShopifyMock,
|
|
15
|
+
tearDownGlobalShopifyMock,
|
|
16
|
+
createMockExtension,
|
|
17
|
+
} from './mount';
|
|
9
18
|
|
|
10
|
-
|
|
19
|
+
describe('Payment Method API hooks', () => {
|
|
20
|
+
afterEach(tearDownGlobalShopifyMock);
|
|
11
21
|
|
|
12
|
-
describe.skip('Payment Method API hooks', () => {
|
|
13
22
|
describe('usePaymentMethodAttributes', () => {
|
|
14
23
|
const paymentMethodAttributes = [{key: 'test_key', value: 'test_value'}];
|
|
15
24
|
|
|
16
25
|
it('returns the paymentMethodAttributes value', async () => {
|
|
17
|
-
const
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
26
|
+
const target =
|
|
27
|
+
'purchase.checkout.payment-option-item.details.render' as const;
|
|
28
|
+
setupGlobalShopifyMock<typeof target>({
|
|
29
|
+
paymentMethodAttributes: createMockSubscribableSignalLike(
|
|
30
|
+
paymentMethodAttributes,
|
|
31
|
+
),
|
|
32
|
+
extension: createMockExtension(target),
|
|
23
33
|
});
|
|
34
|
+
|
|
35
|
+
const {value} = mount.hook(() => usePaymentMethodAttributes());
|
|
24
36
|
expect(value).toBe(paymentMethodAttributes);
|
|
25
37
|
});
|
|
26
38
|
|
|
27
39
|
it('raises when paymentMethodAttributes is not available', async () => {
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
}
|
|
33
|
-
|
|
40
|
+
setupGlobalShopifyMock({});
|
|
41
|
+
|
|
42
|
+
expect(() => {
|
|
43
|
+
mount.hook(() => usePaymentMethodAttributes());
|
|
44
|
+
}).toThrow(
|
|
45
|
+
expect.objectContaining({
|
|
46
|
+
name: 'ScopeNotGrantedError',
|
|
47
|
+
}),
|
|
48
|
+
);
|
|
34
49
|
});
|
|
35
50
|
});
|
|
36
51
|
|
|
37
52
|
describe('usePaymentMethodAttributeValues', () => {
|
|
38
53
|
const paymentMethodAttributes = [{key: 'test_key', value: 'test_value'}];
|
|
39
|
-
const extensionApi = {
|
|
40
|
-
paymentMethodAttributes: createMockStatefulRemoteSubscribable(
|
|
41
|
-
paymentMethodAttributes,
|
|
42
|
-
),
|
|
43
|
-
};
|
|
44
54
|
|
|
45
55
|
it('returns the paymentMethodAttributes values', async () => {
|
|
46
|
-
const
|
|
47
|
-
|
|
48
|
-
|
|
56
|
+
const target =
|
|
57
|
+
'purchase.checkout.payment-option-item.details.render' as const;
|
|
58
|
+
setupGlobalShopifyMock<typeof target>({
|
|
59
|
+
paymentMethodAttributes: createMockSubscribableSignalLike(
|
|
60
|
+
paymentMethodAttributes,
|
|
61
|
+
),
|
|
62
|
+
extension: createMockExtension(target),
|
|
63
|
+
});
|
|
64
|
+
|
|
65
|
+
const {value} = mount.hook(() =>
|
|
66
|
+
usePaymentMethodAttributeValues(['test_key']),
|
|
49
67
|
);
|
|
50
68
|
expect(value).toStrictEqual(['test_value']);
|
|
51
69
|
});
|
|
52
70
|
|
|
53
71
|
it('returns undefined for not found keys', async () => {
|
|
54
|
-
const
|
|
55
|
-
|
|
56
|
-
|
|
72
|
+
const target =
|
|
73
|
+
'purchase.checkout.payment-option-item.details.render' as const;
|
|
74
|
+
setupGlobalShopifyMock<typeof target>({
|
|
75
|
+
paymentMethodAttributes: createMockSubscribableSignalLike(
|
|
76
|
+
paymentMethodAttributes,
|
|
77
|
+
),
|
|
78
|
+
extension: createMockExtension(target),
|
|
79
|
+
});
|
|
80
|
+
|
|
81
|
+
const {value} = mount.hook(() =>
|
|
82
|
+
usePaymentMethodAttributeValues(['test_key', 'test_key3']),
|
|
57
83
|
);
|
|
58
84
|
expect(value).toStrictEqual(['test_value', undefined]);
|
|
59
85
|
});
|
|
60
86
|
|
|
61
87
|
it('returns an empty array if payment attributes object is undefined', async () => {
|
|
62
|
-
|
|
63
|
-
() => usePaymentMethodAttributeValues(['test_key', 'test_key3']),
|
|
88
|
+
setupGlobalShopifyMock<'purchase.checkout.payment-option-item.details.render'>(
|
|
64
89
|
{
|
|
65
|
-
|
|
66
|
-
paymentMethodAttributes:
|
|
67
|
-
createMockStatefulRemoteSubscribable(undefined),
|
|
68
|
-
},
|
|
90
|
+
paymentMethodAttributes: createMockSubscribableSignalLike(undefined),
|
|
69
91
|
},
|
|
70
92
|
);
|
|
93
|
+
|
|
94
|
+
const {value} = mount.hook(() =>
|
|
95
|
+
usePaymentMethodAttributeValues(['test_key', 'test_key3']),
|
|
96
|
+
);
|
|
71
97
|
expect(value).toStrictEqual([]);
|
|
72
98
|
});
|
|
73
99
|
|
|
74
100
|
it('returns an empty array if payment attributes object is an empty array', async () => {
|
|
75
|
-
|
|
76
|
-
() => usePaymentMethodAttributeValues(['test_key', 'test_key3']),
|
|
101
|
+
setupGlobalShopifyMock<'purchase.checkout.payment-option-item.details.render'>(
|
|
77
102
|
{
|
|
78
|
-
|
|
79
|
-
paymentMethodAttributes: createMockStatefulRemoteSubscribable([]),
|
|
80
|
-
},
|
|
103
|
+
paymentMethodAttributes: createMockSubscribableSignalLike([]),
|
|
81
104
|
},
|
|
82
105
|
);
|
|
106
|
+
|
|
107
|
+
const {value} = mount.hook(() =>
|
|
108
|
+
usePaymentMethodAttributeValues(['test_key', 'test_key3']),
|
|
109
|
+
);
|
|
83
110
|
expect(value).toStrictEqual([]);
|
|
84
111
|
});
|
|
85
112
|
});
|
|
86
113
|
|
|
87
114
|
describe('useApplyPaymentMethodAttributesChange()', () => {
|
|
88
115
|
it('returns the applyPaymentMethodAttributesChange function', async () => {
|
|
89
|
-
const target
|
|
90
|
-
'purchase.checkout.payment-option-item.details.render';
|
|
91
|
-
const
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
},
|
|
100
|
-
);
|
|
101
|
-
expect(value).toBe(jest.fn);
|
|
116
|
+
const target =
|
|
117
|
+
'purchase.checkout.payment-option-item.details.render' as const;
|
|
118
|
+
const applyPaymentMethodAttributesChange = jest.fn();
|
|
119
|
+
setupGlobalShopifyMock<typeof target>({
|
|
120
|
+
applyPaymentMethodAttributesChange,
|
|
121
|
+
extension: createMockExtension(target),
|
|
122
|
+
});
|
|
123
|
+
|
|
124
|
+
const {value} = mount.hook(() => useApplyPaymentMethodAttributesChange());
|
|
125
|
+
expect(value).toBe(applyPaymentMethodAttributesChange);
|
|
102
126
|
});
|
|
103
127
|
|
|
104
128
|
it('raises when applyPaymentMethodAttributesChange is not available', async () => {
|
|
105
|
-
const
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
}
|
|
113
|
-
|
|
129
|
+
const target: ExtensionTarget = 'purchase.checkout.block.render';
|
|
130
|
+
setupGlobalShopifyMock({
|
|
131
|
+
extension: createMockExtension(target),
|
|
132
|
+
});
|
|
133
|
+
|
|
134
|
+
expect(() => {
|
|
135
|
+
mount.hook(() => useApplyPaymentMethodAttributesChange());
|
|
136
|
+
}).toThrow(
|
|
137
|
+
expect.objectContaining({
|
|
138
|
+
name: 'ExtensionHasNoMethodError',
|
|
139
|
+
}),
|
|
140
|
+
);
|
|
114
141
|
});
|
|
115
142
|
});
|
|
116
143
|
});
|