* Move type defs
* Move type guards
* Fix imports
* Extract prepareTotalItems to TS file
* usePaymentMethodInterface as TS file
* Fix TS props
* Fix currency type defs
* Add return type to usePaymentMethodInterface
* Add key prop to CartTotalItem
* Fixed up js tests
* Move SymbolPosition into type-defs package
Co-authored-by: Thomas Roberts <thomas.roberts@automattic.com>
* Hide "including x in taxes" if tax amount is 0
* Add jest types to tsconfig
* Move SHOW_TAXES into component body
This is to make the code more testable and allows us to change values. There's no significant performance impact because of this change.
* Add tests and snapshots for TotalsFooterItem
* Move text-input to checkout package
* Pass validation props directly to ValidatedTextInput
* Import label relatively instead of from package
* Pass validation functions to ValidatedTextInput
This is so it doesn't need to get them from useValidationContext.
* Add InputProps to ValidatedTextInput
This will be used to control additional props on the input element of TextInput
* Spread inputProps onto <input> element of TextInput
* Export TextInput from @woocommerce/blocks-checkout
* Add @woocommerce/blocks-checkout package to tsconfig
* Allow styling to be applied to number inputs and when value is 0
* Make style order consistent
* Remove inputProps to rely on rest in TextInput
* Add specific prop for the inputErrorComponent
* Only disallow active state if value is 0 AND type is number
* Change all uses of ValidatedTextInput to also pass inputErrorComponent
* Revert "Change all uses of ValidatedTextInput to also pass inputErrorComponent"
This reverts commit ec734b99c20c4d29fcf778714246fc406ee37eaf.
* Revert "Remove inputProps to rely on rest in TextInput"
This reverts commit 1fc64cca4002206423d1fa443ff2d60130ba1ea0.
* Revert "Revert "Change all uses of ValidatedTextInput to also pass inputErrorComponent""
This reverts commit 110e3606a996668be5a32698b634b7706d16cddc.
* Revert "Revert "Remove inputProps to rely on rest in TextInput""
This reverts commit aeb03526c44b3fcc97a719a18930d08157a80baf.
* Don't pass errorMessage to ValidatedTextInput
* Add isCompact prop to components using SearchListControl
* Update @woocommerce/components to 6.1.2
* Remove legacy CSS code
* Add some CSS rules to override conflicting editor styles
* Replace showCount prop with has-count class name
* Create ExpandableSearchListItem component
* Refactor ProductControl so it uses ExpandableSearchListItem
* Update @woocommerce/components to 6.2.0
* Fix @woocommerce/components builds breaking
* Fix a11y of expandable item list children
* Set categories to an empty array by default
* Render compact control in Attribute filter sidebar
* Add countLabel to ProductAttributeTermControl
* Fix ProductTagControl selected items
* Use sentence case for countLabel
* Fix wrong margins in block editor
* Fix checkbox alignment
* Update package-lock.json
* Fix withCategories test
* Fix JS error in Filter Products by Attribute block
* Make input ids unique
* Change index file from base/context to .ts
This is to stop TS complaining when importing things from here.
* Convert ValidatedTextInput to TypeScript
* Convert TextInput to TypeScript
* Ensure Label accepts correct HTML Attributes Props
* Remove PropTypes from TextInput and ValidatedTextInput
No longer needed because of TypeScript
* Use correct error id to show validation message
* Use HTMLElement instead of a specific element type for LabelProps
* Update assets/js/base/components/text-input/validated-text-input.tsx
Co-authored-by: Albert Juhé Lluveras <contact@albertjuhe.com>
* Update assets/js/base/components/text-input/validated-text-input.tsx
* Use correct formatting in ValidatedTextInput
Co-authored-by: Albert Juhé Lluveras <contact@albertjuhe.com>
* Fix checkout test
- make tests independent & test also for empty cart case
- make sure the Order summary is expanded with a better selector
* Remove unnecessary localStorage operations from tests
* Go to cart page before removing an item from cart
* Remove logging observing before tests
This removes unnecessary console.log interception. A big part of the logic was done for Puppeteer 1.6.1, but since 3.0.0 message.text() returns string. We allow console.error messages to surface in our tests. Although they don't cause the test to fail it might be a good addition for debugging purposes.
* git move to ts files
* Type the checkout state provider
* Restore for loop for error handling
* Types not needed
* Consolodate response handling
* Unused import
* Fix defaults for onCheckoutAfterProcessingWithSuccess etc
* Type useEmitResponse and remove isObject checks
* useEmitResponse as const
* Check that redirectUrl is string
* Define actions as const
* data.redirectUrl should be truthy
* Add redirectURL todo item as followup
* remove null fallback
* Update cart/coupon/shipping design
* Add order summary heading
* Move and style discounts on checkout sidebar
* Add rate to tax lines
* Ensure the option to display taxes itemised is available to Cart block
* Output individual tax items below the total & add styles for this
* Add success notice under coupon input on successful coupon addition
* Add border to bottom of Totals footer
* Show success message when adding coupon
* Add padding to cart item rows
* Add preview data to cart for when taxes are enabled
* Add rate to cart response type
* Add showRateAfterTaxName attribute to Cart block
* Add control to cart block to show rate percentage after rate name
* Add rate % in cart totals only if option is toggled on
* Pass showRateAfterTaxName attribute down to TotalsTaxes
* Add showRateAfterTaxName to Checkout block
* Add control to block editor for showRateAfterTaxName on Checkout
* Pass showRateAfterTaxName down to TotalsTaxes in Checkout
* Change label for showing tax rates in cart and checkout blocks
* Add test to ensure Taxes section shows in Cart block
* Add tests for cart sidebar and rate percentages
* Remove order summary title from checkout sidebar
* Check if taxes are enabled before rendering the option to show rate %s
* Add ShippingVia component to show the selected rate in sidebar
* Remove value from individual tax rates
* Remove bold from Shipping via label
* Remove coupon added successfully message
* Ensure panel headings that are h2s are the same colour as others
* Clean up eslint warnings
* Show rate %s by default
* Update snapshots following design changes
Co-authored-by: Mike Jolley <mike.jolley@me.com>
* Un-used PropTypes import
* Avoid global and use ownerDocument
* receiveCart return type
* ignoreRestSiblings when destructuring for @typescript-eslint/no-unused-vars
* Replace lodash find
* Use global rather than window
* Remove lodash map
* move rule to overrides
* Wip: fix e2e fe tests
* Test that navigation ends
* Fix waitForNavigation
* comment out failing php test
* click the dom element
* Ensure navigation happens by waiting for it. Test page title.
* remove skip and update docs
* Revert "comment out failing php test"
This reverts commit 7c40e8caf3aa32e35e3b70eb32051251b06e0613.
* Fix USD from merge conflict
* Add missing check for page title
* Try page.waitForFunction for text search
* test to see checkout page title is correct
* test checkout page url on CI
* unde jest config change
* Fix assertion for checkout page
* remove extra localStorage item remove call
Co-authored-by: Mike Jolley <mike.jolley@me.com>
Co-authored-by: Nadir Seghir <nadir.seghir@gmail.com>
* Make extensions optional, not all filters will need to pass this through
For example the CartCouponSchema has no option for extensibility (and I don't think it's needed at any rate) so extensions will always be an empty object. Rather than explicitly specifying this when running the filter, we can let it default to an empty object.
* Add filter for coupon code
* Add type defs for customer
Taken from 194ecccf78/assets/js/type-defs/customer.ts
* Convert ShippingCalculatorAddress to TypeScript
* Convert ShippingCalculator to TypeScript
* Convert ShippingLocation to TypeScript
* Allow packageId to be a number or string in useSelectShippingRate(s)
* Convert ShippingRatesControl to TypeScript
* Convert ShippingOptionsStep to TypeScript
* Allow package_id to be a string or number
This is because of Subscriptions using strings for package IDs
* Change to use CartShippingRateItemShippingRate instead of Rate
* Add extra props to PackageProps type
* Make ShippingAddress have the correct type
* Use CartShippingRateItemShippingRate instead of Rate
* Remove Rate type
* Set return types to JSX.Element
* Change type of props.renderOption in ShippingRatesControl
* Remove customer type defs and relocate aliases to default-address-fields
* Add EnteredAddress type
* Import EnteredAddress from new location
* Remove unnecessary eslint ignore
* Remove unused variable
* Remove confusing use of word Item in Shipping types
* Remove confusing use of word Item in Shipping types
* Feature gate PaymentApi
* Improve payment method missing dependencies error message so it's clear it only affects blocks
* Add PaymentApi feature flags to list of feature flags in docs
* modify emitEventWithAbort to change return value
`emitEventWithAbort` now returns an array of responses up to the first response that triggered an error or fail response instead of aborting on success responses too.
* update add to cart form context provider
* update checkout state context provider
* update payment method data context provider
* update tests and fix thrown error handling.
* Rename the argument in the CheckoutFilterFunction type
This only exists as an extra descriptive hint to anyone using this type, the value `label` was never used by anything so it does not need to be changed anywhere else.
* Create Available Filters document
* Add available filters to the extensibility README
* Update docs/extensibility/available-filters.md to fix typographical error
Co-authored-by: Mike Jolley <mike.jolley@me.com>
Co-authored-by: Mike Jolley <mike.jolley@me.com>
* Update package-lock.json
* Move Block Type Settings into Block Type Classes (https://github.com/woocommerce/woocommerce-blocks/pull/4059)
* BLOCK SETTINGS: Remove unused constants/settings
* AssetDataRegistry: Helpers to check for settings that exist, and registering page ID/permalinks
* Move checkout and cart block settings to checkout and cart blocktypes
* Move isShippingCalculatorEnabled to cart block
* Remove HAS_DARK_EDITOR_STYLE_SUPPORT and IS_SHIPPING_CALCULATOR_ENABLED in favour of getSetting
* Move displayCartPricesIncludingTax to blocktypes, and implement getSetting
* Move block settings to core settings and blocktypes
* Fix namespace usage
* Move review settings
* move tag settings
* Keep productCount in core data
* Move min and default height
* Improve storePages code
* Move attributes to attribute filter block type
* Move $word_count_type outside of settings array
* Remove unneeded setting in preview data (shippingCostRequiresAddress)
* Move min/max settings dependency from GridLayoutControl to Blocks themselves and use getSettings
* DEFAULT_COLUMNS and ROWS to settings
* Move product columns/rows to block types
* Add grid settings to AllProducts block
* Correct default rows
* correct min rows default
* Move hasDarkEditorStyleSupport
* Move hideOutOfStockItems to block type settings
* Move build settings to inline script dependency
* Pass data through asset api and move restApiRoutes
* Export all core settings as constants
* Remove WORD_COUNT_TYPE from core settings
* Move some other core settings to assets
* Update constants
* Make settings use TypeScript
* Update CURRENT_USER_IS_ADMIN usage
* WORD_COUNT_TYPE
* REST_API_ROUTES
* REVIEW_RATINGS_ENABLED and SHOW_AVATARS
* Remove REVIEW_RATINGS_ENABLED and SHOW_AVATARS constants
* Remove MIN_HEIGHT
* Remove DEFAULT_HEIGHT
* PLACEHOLDER_IMG_SRC
* LIMIT_TAGS
* HAS_PRODUCTS
* HOME_URL
* HAS_TAGS
* COUPONS_ENABLED
* SHIPPING_ENABLED
* TAXES_ENABLED
* DISPLAY_ITEMIZED_TAXES
* SHIPPING_COST_REQUIRES_ADDRESS
* SHIPPING_STATES and SHIPPING_COUNTRIES
* STORE_PAGES
* ALLOWED_COUNTRIES
* ALLOWED_STATES
* SHIPPING_METHODS_EXIST
* PAYMENT_GATEWAY_SORT_ORDER
* CHECKOUT_SHOW_LOGIN_REMINDER
* CHECKOUT_ALLOWS_GUEST and CHECKOUT_ALLOWS_SIGNUP
* ATTRIBUTES
* DISPLAY_CART_PRICES_INCLUDING_TAX
* DISPLAY_CART_PRICES_INCLUDING_TAX
* update build for TS files
* fix build dir
* Move blocks build config params
* Move placeholderImgSrc to core settings
* Move rest api hydration hoc to shared hocs and provide it restApiRoutes directly to avoid asset data registration
* Move wordCountType to abstract block
* Remove WORD_COUNT_TYPE in favour of getSetting
* Move IS_LARGE_CATALOG and PRODUCT_COUNT to abstract block type and use getSetting inline
* Add wcBlocksConfig
* fix tests
* Remove unused $asset_data_registry
* remove console.log
* Move build settings to abstract block
* Trigger build again
* Move hydration back to regular hocs for compatibility with trunk (merge conflict)
* Removed wcSharedHocsConfig
* esc home url
* Update search fixture
* Update search snap
* 40000 timeout
* hasProducts -> productCount
* Product Count is part of blocks config
* update mocks
* Use version comparison to determine if batching is enabled
* Change isWpVersion
* scrollTo button
* Rename product backorder badge to tsx
* Rename Policies component to tsx
* Convert Product badge to TS
* Convert Product Details to TypeScript
* Convert ProductImage to TypeScript
* Convert ProductLowStockBadge to TypeScript
* Move ItemData into ProductResponse type def file
* Add type defs directory to tsconfig
* Import types for ProductResponseItemData in ProductDetails
* Convert ProductMetaData to TypeScript
* Convert ProductSaleBadge to TypeScript
* Type component props to their interfaces
* Ensure components have an explicit return type of JSX.Element set
* Export PLACEHOLDER_IMG_SRC as string
* Add null to component return type
* Import PLACEHOLDER_IMG_SRC from correct location
Co-authored-by: Mike Jolley <mike.jolley@me.com>
* Convert Button to TypeScript
* Add alias of @types/wordpress__components
* Make ButtonProps extend the wp/components button's base props
* Update package-lock.json
* Extend Button.ButtonProps instead of only BaseProps
* Add return type to Button component
* Add emptyHiddenAddressFields function
* Add tests for emptyHiddenAddressFields
* Remove address fields that should be hidden before processing checkout
* Empty hidden address fields before displaying in shipping calculator
* Refactor emptyHiddenAddressFields so we only iterate once
* Fix test for emptyHiddenAddressFields
* Import default address fields from @woocommerce/settings
* Import emptyHiddenAddressFields
* Copy address first before emptying fields
* Modify address directly instead of copying it
* Copy address variable instead of mutating it directly
* Add files to TS project
* Return the new address rather than the parameter
* Don't clean address fields in the presentation layer
* Clean address in useStoreCart before it gets sent to components
* Convert CartLineItemsTitle to TypeScript
* Add type guards
* Change CartLineItemRow extension to .tsx
* Remove parseInt from price precision
This is because the API sends it as a number, so it will never be a string, so no need to parse it.
* Add dinero.js types
* Type QuantitySelector and add types for @wordpress/keycodes
* Make __experimentalApplyCheckoutFilter use generic types
* Add catalog_visibility type & change types of CartItem
* Add isNumber and isString to type guards
* Type ProductLowStockBadge
* Ensure type returned by a filter function is the same it received
* Include type guards and hooks in tsconfig
* Add more type safety to useStoreCartItemQuantity
* Make className optional on QuantitySelector
* Type CartLineItemRow
* Type CartLineItemsTable
* Type Cart
* Add extra keys to CartResponseItem
* Clean aria-hidden logic
* Export type-guards from module
* Use aliases to import types in CartLineItemRow
* Remove unused prop types and specify return type of function
* Specify return type of component
* Use JSX.Element instead of ReactNode
* Remove unused variables & set return type of components
* Remove PropTypes
* BLOCK SETTINGS: Remove unused constants/settings
* AssetDataRegistry: Helpers to check for settings that exist, and registering page ID/permalinks
* Move checkout and cart block settings to checkout and cart blocktypes
* Move isShippingCalculatorEnabled to cart block
* Remove HAS_DARK_EDITOR_STYLE_SUPPORT and IS_SHIPPING_CALCULATOR_ENABLED in favour of getSetting
* Move displayCartPricesIncludingTax to blocktypes, and implement getSetting
* Move block settings to core settings and blocktypes
* Fix namespace usage
* Move review settings
* move tag settings
* Keep productCount in core data
* Move min and default height
* Improve storePages code
* Move attributes to attribute filter block type
* Move $word_count_type outside of settings array
* Remove unneeded setting in preview data (shippingCostRequiresAddress)
* Move min/max settings dependency from GridLayoutControl to Blocks themselves and use getSettings
* DEFAULT_COLUMNS and ROWS to settings
* Move product columns/rows to block types
* Add grid settings to AllProducts block
* Correct default rows
* correct min rows default
* Move hasDarkEditorStyleSupport
* Move hideOutOfStockItems to block type settings
* Move build settings to inline script dependency
* Pass data through asset api and move restApiRoutes
* Export all core settings as constants
* Remove WORD_COUNT_TYPE from core settings
* Move some other core settings to assets
* Update constants
* Make settings use TypeScript
* Update CURRENT_USER_IS_ADMIN usage
* WORD_COUNT_TYPE
* REST_API_ROUTES
* REVIEW_RATINGS_ENABLED and SHOW_AVATARS
* Remove REVIEW_RATINGS_ENABLED and SHOW_AVATARS constants
* Remove MIN_HEIGHT
* Remove DEFAULT_HEIGHT
* PLACEHOLDER_IMG_SRC
* LIMIT_TAGS
* HAS_PRODUCTS
* HOME_URL
* HAS_TAGS
* COUPONS_ENABLED
* SHIPPING_ENABLED
* TAXES_ENABLED
* DISPLAY_ITEMIZED_TAXES
* SHIPPING_COST_REQUIRES_ADDRESS
* SHIPPING_STATES and SHIPPING_COUNTRIES
* STORE_PAGES
* ALLOWED_COUNTRIES
* ALLOWED_STATES
* SHIPPING_METHODS_EXIST
* PAYMENT_GATEWAY_SORT_ORDER
* CHECKOUT_SHOW_LOGIN_REMINDER
* CHECKOUT_ALLOWS_GUEST and CHECKOUT_ALLOWS_SIGNUP
* ATTRIBUTES
* DISPLAY_CART_PRICES_INCLUDING_TAX
* DISPLAY_CART_PRICES_INCLUDING_TAX
* update build for TS files
* fix build dir
* Move blocks build config params
* Move placeholderImgSrc to core settings
* Move rest api hydration hoc to shared hocs and provide it restApiRoutes directly to avoid asset data registration
* Move wordCountType to abstract block
* Remove WORD_COUNT_TYPE in favour of getSetting
* Move IS_LARGE_CATALOG and PRODUCT_COUNT to abstract block type and use getSetting inline
* Add wcBlocksConfig
* fix tests
* Remove unused $asset_data_registry
* remove console.log
* Move build settings to abstract block
* Trigger build again
* Move hydration back to regular hocs for compatibility with trunk (merge conflict)
* Removed wcSharedHocsConfig
* esc home url
* Update search fixture
* Update search snap
* 40000 timeout
* hasProducts -> productCount
* Product Count is part of blocks config
* update mocks
* Use version comparison to determine if batching is enabled
* Change isWpVersion
* scrollTo button
* Add When to employ end to end (E2E) testing doc
* Add links to documentation for RTL and puppeteer
* Update docs/testing/when-to-employ-e2e-testing.md
Co-authored-by: Albert Juhé Lluveras <contact@albertjuhe.com>
* Update when-to-employ-e2e-testing.md
Co-authored-by: Albert Juhé Lluveras <contact@albertjuhe.com>
* Add batch route
* Register batch route
* Allow batching on writable endpoints
* Batch in client
* Batch non-GET requests
* Batching support with typescript defs
* Remove unused hook
* Prevent multiple fragment updates
* Only use batch route if detected
* Correct var name
* Move nonce check to validate_callback so it runs before requests are completed
* remove unused imports
* updateCartFragments function as const
* Add phpunit tests for batching functionality
* Reduce batch delay
* increase timeout
* Update isCartUpdatePostRequest for batch support
* Update Endpoint used in test
* Move nonce check back inline - custom headers are not returned otherwise
* Fix error handling
* Back to 30s
* Update assets/js/middleware/cart-update.ts
Co-authored-by: Thomas Roberts <5656702+opr@users.noreply.github.com>
* whitespace
Co-authored-by: Thomas Roberts <5656702+opr@users.noreply.github.com>
* update @wordpress/env to 4.0.2
* switch `core` to null for the default wp-env config
* remove DT types for @wordpress/api-fetch and install actual api-fetch package as a dev dependency.
The actual package now has types which are more up to date so it’s better to use it for the types than what’s in Definitely Typed.
This reverts commit 5b65a02297.
This commit broke cart updates for the cart block (surfaced with changing quantity)
There were also legit e2e test fails for the cart-update middleware behaviour that weren’t addressed.
* Check if Cart and Checkout are registered before removing payment methods so it won't break Elementor (https://github.com/woocommerce/woocommerce-blocks/pull/4056)
* Empty commit for release pull request
* update versions and add testing file
* add download file
* Bumping version strings to new version.
Co-authored-by: Seghir Nadir <nadir.seghir@gmail.com>
Co-authored-by: github-actions <github-actions@github.com>
* Add batch route
* Register batch route
* Allow batching on writable endpoints
* Batch in client
* Batch non-GET requests
* Batching support with typescript defs
* Remove unused hook
* Prevent multiple fragment updates
* Only use batch route if detected
* Correct var name
* Move nonce check to validate_callback so it runs before requests are completed
* remove unused imports
* updateCartFragments function as const
* Add phpunit tests for batching functionality
* Reduce batch delay
* increase timeout
* Remove unused fixtures
* Update package-lock.json
* Update product-search fixture and snapshot
* Ensure the product is selected before continuing with the test.
This clicks the test at least once, or at most thrice to ensure it is checked before trying to evaluate the rest of the test.
* Revert "Remove unused fixtures"
This reverts commit e4a4e11b72c6723341d60391bd9cb9cc4197efaf.
* Look for button with aria-label: 'Toggle block inserter'
* Revert "Look for button with aria-label: 'Toggle block inserter'"
This reverts commit a25ea8d9abafead372ef24b2feb92ff58bd95cea.
* Update @wordpress/e2e-test-utils to 5.1.2
* Check for existence of add block button
* Add initial e2e tests to Checkout block frontend
* Fix comment format
* Scroll to payment methods before checking if they are clickable
* Typos
* Implement caching in getBlockPagePermalink to improve e2e test performance
* Revert "Typos"
This reverts commit 1b544276056084f73d5bcdfa391d5438590e4782.
* Simplify product price definitions
* Move scrollTo function to utils
* Fix checkbox styling in 2020 and 2017 themes by setting input font size
* 2017 button hover style fixes
* Fix editor dark inputs
* Restore dark color
* Fix circular dependencies in Icons package
* CircularDependencyPlugin
* Fix deriveSelectedShippingRates CD
* Move useStoreNotices to context/hooks
* Move useStoreCart to base/context/hooks
* Move useStoreEvents to base/context/hooks
* Move collection/product hooks
* Move useStoreAddToCart
* Move useCustomerData
* move shipping hooks
* Move checkout and payment hooks
* Context should import hooks with relative paths
* Prevent circular dependency in store notices container components
* Move address fields to settings so they are shared
* Import PaymentMethod components direct
* relative import
* Fix select CD
* Move ValidationInputError
* Move components consumed by context
* Fix up internal imports in context
* fix CD in checkout package
* Separate providers
* Fixing context exports
* Fix base context hook import
* fix mocks
* Pass hooks to Slot Fills as Fill Props to avoid imports from base-context
* Export components, not hooks
* Pass props to ExperimentalOrderMeta
* Run CD plugin when using `npm start` only
* Rename CIRCULAR_DEPS to CHECK_CIRCULAR_DEPS
* Remove duplicate key from rebase
* Move packages component back to main file
* Remove dashicon module replacement
* Restore SVG import from package not external
* Move core locale handling to avoid impact settings package size
* Remove deleted file from rebase
* Apply kses before wc_format_content
* Add kses to price HTML strings
* KSES in product grid
* kses in featured product
* Switch short description filter to wc_format_content in featured product block
* Fix click on Proceed to checkout bug when Coupon error is visible.
The bug happened because of the layout shift produced by the error message disappearance.
* Strip tags that are added to notices
* Add test to ensure HTML is stripped by convert_notices_to_exceptions
* Test function directly, rather than through validate_cart_items
* Apply correct formatting to tests/php/StoreApi/Utilities/NoticeHandler.php
Co-authored-by: Albert Juhé Lluveras <contact@albertjuhe.com>
Co-authored-by: Albert Juhé Lluveras <contact@albertjuhe.com>
Trying a different way of adding a commit to allow for pr creation on release pull requests. This way reduces both the number of commits and requires no actual file changes.
* Add cartUpdate middleware
* Include timestamp for when cart data was generated
* Add getCartFromApi action
* Check whether cart can be hydrated or needs to be fetched from API
* Add cartDataIsStale action and remove getCartFromApi action
* Add isCartDataStale selector
* Don't load cart until staleness check is complete
* Add comment to ease worry about locaStorage execution
* Correct doc block and fix typographical error
* Cater for lastCartUpdate or the timestamp being undefined
* Include @woocommerce/api and @woocommerce/e2e-utils
* Add getNormalPagePermalink test utility
This will allow us to get the permalink of a "normal" page, i.e. one that is not using the block editor.
* Add getBlockPagePermalink test utility
This will get the permalink for a page using the Block editor.
* Emit action to update cart staleness in all execution paths
* Add visitPostOfType function
This will allow us to visit the editor page for a post based on its name and post type.
* Add functions to get permalinks from editor pages
* Add front-end tests for cart
* Update package-lock.json
* Create local function to ensure the page permalink is visible
* Change functions for getting permalinks
They were often failing for unknown reasons, these _somehow_ make them more stable.
* Add logging for GitHub actions
* Add more logging for tests
* Add more logging for tests
* Add more logging for tests
* Wait for networkidle on back
* Remove logging except timestamp
* Wait for timestamp to be added to localStorage
* Split tests to make runs slightly shorter
* Wait for add to cart request before continuing test
* Fix formatting in cart.test.js
* Rename cartDataStale to setIsCartDataStale
* Create constant for localStorage timestamp name
* Rename cartDataIsStale to isCartDataStale
This is for consistency, the action to change this is called setIsCartDataStale - I think this reads better.
* Use cleaner logic when determining if the cart should render or fetch
* Change docblock for isCartDataStale selector
* Remove boolean cast from SET_IS_CART_DATA_STALE reducer
* Set longer timeouts for frontend cart tests
* Enclose cart staleness checks in condition/prevent unnecessary execution
* Remove unnecessary boolean cast from selector
* Use constant for local storage key in tests
* Use new localstorage key in tests. cant access constants in page context
* Implement `started` action creator.
Also for TS typing I changed `paymentMethodData` to be optional for both the `success` and `started` action creators.
This is because the behaviour allows for paymentMethodData to be retained in the state if it is not explicitly provided on dispatch.
* Implement started action creator on the exposed payment status dispatcher.
The implementation now allows for receiving payment method data when the `start` status is dispatched.
* Don’t overwrite payment method data when `success` status is set.
It is intended that if paymentMethodData is undefined, that is simply passed through to the dispatched action. This signals the reducer to retain the existing paymentMethodData in state (when undefined).
The correct way to clear the paymentMethodData is to either explictly provide an empty object, or set the status to pristine.
* Fix types for incoming paymentMethodData
* Implement receiving paymentMethodData in reducer.
This changeset also configures the reducer to retain the existing paymentMethodData in state (and related correlated information0 when the provided paymentMethodData property is undefined.
The only time paymentMethodData should be reset in state is when it is explicitly provided or the status is set to PRISTINE.
* Fix types for started action dispatcher.
* Explicitly clear paymentMethodData state when express payment started.
Also restores previous paymentMethodData when express payment cancelled.
* Switch saved tokens to utilize the payment method status started dispatched action instead of success.
This change ensures that savedToken handlers registered by payment methods have access to the `onPaymentProcessing` checkout event.
* fix typedef
Really just need to ensure types are used anywhere, this is a temporary change due to the time sensitive needs for this PR.
* Update assets/js/base/context/cart-checkout/payment-methods/reducer.ts
Co-authored-by: Albert Juhé Lluveras <contact@albertjuhe.com>
Co-authored-by: Albert Juhé Lluveras <contact@albertjuhe.com>
* update wp-env package
* bump versions in e2e workflows
* Fix job names
* explicitly set core WP version
without this, the `mappings` configuration option causes breakage due to what appears to be a bug in the package.
* Change how GB install job is setup
`wp-env` currently has an issue where if you define the explicit WP version to install (vs just what is included by default), permissions aren’t configured correctly for the WP folder in the containers. So the ability to install plugins via cli is not possible. This only surfaces in linux environments.
I tried a number of ways to work around this but in the end the only foolproof way is to configure the environment to be setup with the installed plugin.
* Remove item and change quantity doAction hooks
* Cart event
* Event/Action system for cart events
* GA implementation
* Revert some unrelated commits
* revert change
* Listing impression config for all products
* Category support
* remove unrelated change
* Remove listype and block import
* wrap action in try catch
* Tidy
* Only load analytics scripts in experimental builds
* Made console log more specific
* Wrap script reg in experimental check
* Fix cart preview when shipping calculator is false and core setting for require address is true
* Type base/components/cart-checkout/totals/shipping/index file
* Fix return statement for ShippingLocation component
* move logic to preivewCart
Co-authored-by: Seghir Nadir <nadir.seghir@gmail.com>
* Remove custom style for Product search block and ProductByCategoryBlock
These buttons are overwriting the default button appearance used in other blocks,
making the UI inconsistent. They lack focus and are not visible on dark backgrounds
* Replace the remove filter icon with a svg using currentColor as fill
* Fix Price Slider range icons visual bug
* Adjust close active filter icon colors to work for white as currentColor
* Add new config for saved token processing by payment methods.
* Implement new saved token handling config from registered payment methods.
* Implement new saved token handling config from registered payment met… … 2b42205 …hods.
* make sure saved token handler component is only loaded when a token payment method is selected
* type hooks
* type useStoreCart
* type the rest
* Remove old typedefs
* Specify that the return value from useDispatch is a Promise< void >
* Change return type of removeItem
* If ref.current is undefined then return value without checking shallowEq
* Revert "Specify that the return value from useDispatch is a Promise< void >"
This reverts commit 97863bd584d38024398913a79ce63fa6b964846a.
* Remove type parameter from removeItem and changeCartItemQuantity
* Change action return type to cater for generator functions
* Remove type parameter from addItemToCart
* Add mapped types file to help with actions that are generator functions
* Include addItemToCart in return types of cart actions
* Use custom DispatchFromMap
* Add todos for why we've redefined functionality that exists in Calypso
* update types
* remove fromEntries and use polyfill
* address review
* ignore ts no shadow
* fix test errors
Co-authored-by: Thomas Roberts <thomas.roberts@automattic.com>
* Hide payment methods that have missing dependencies and display an error in the admin
* Clarify docs
* Use wp_scripts() instead of the global
* Don't localize logs and always show the docs link
* Add wards to ensure keys exist
* Show a console error instead of a notice in the admin
* Type shipping related hooks and packages
* Move component interface from shared shipping types file
* Fix Typescript import errors
* Type FormattedMonetaryAmountProps
* Change FormattedMonetaryAmountProps's value prop type
Looks like TotalsItem was the only on sending '-' as a value and it looks like it’s no longer passed through.
* Move `displayType` as a prop on FormattedMonetaryAmount
* Spacing
* Spacing
Co-authored-by: Mike Jolley <mike.jolley@me.com>
* Add Typescript to Panel and Icon
* Fix Icon component import
* Convert packages/checkout/utils/validation/index to TypeScript
* Convert checkout registry to TypeScript
* Add return type to mustContain
* Add TypeScript to Totals components from @woocommerce/blocks-checkout
* Add TypeScript to @woocommerce/price-format
* Use types from @woocommerce/type-defs when possible
* Allow empty objects when loading
* Fix formatting in payment-method-data-context.js
* Add missing return types
* Fix up price warnings
* Fix more warnings in FormattedMonetaryAmount
Co-authored-by: Raluca Stan <ralucastn@gmail.com>
Co-authored-by: Thomas Roberts <thomas.roberts@automattic.com>
Co-authored-by: Mike Jolley <mike.jolley@me.com>
* generating changeset for pull request
* generating changeset for pull request
* update changelog in readme.txt
* fix zip script to account for spaces in path
* fix deploy script to account for paths
* add testing notes
* Update docs/testing/releases/460.md
Fix incorrect version reference.
* Show cart item subtotal instead of total in Cart and Checkout blocks (https://github.com/woocommerce/woocommerce-blocks/pull/3905)
* Show cart item subtotal instead of total in Cart and Checkout blocks
* Update test that would have caught this error
* Update changelog and testing steps
* update docs index
* update testing zip file
* update changelog in readme.txt
* update github-deploy to account for spaces in local path
* Bumping version strings to new version.
* add tsconfig.base.json to excludes for release builds
Co-authored-by: github-actions <github-actions@github.com>
Co-authored-by: Darren Ethier <darren@roughsmootheng.in>
Co-authored-by: Albert Juhé Lluveras <contact@albertjuhe.com>
* Client side improvement to the payment method integration docs
* improvements to php docs
* Improvements to server side documentation of Payment Method Checkout blocks integration
* Update docs/extensibility/payment-method-integration.md
Co-authored-by: Allen Smith <loranallensmith@gmail.com>
* Update docs/extensibility/payment-method-integration.md
Co-authored-by: Allen Smith <loranallensmith@gmail.com>
* Update docs/extensibility/payment-method-integration.md
Co-authored-by: Allen Smith <loranallensmith@gmail.com>
* Update docs/extensibility/payment-method-integration.md
Co-authored-by: Allen Smith <loranallensmith@gmail.com>
* More edits addressing feedback.
* Update docs/extensibility/payment-method-integration.md
Co-authored-by: Allen Smith <loranallensmith@gmail.com>
Co-authored-by: Allen Smith <loranallensmith@gmail.com>
* Fix tslint warnings
* Install @automattic/data-stores to get access to some type generics for use with our data stores.
* improve ts typing of cart-data store.
* fix incorrect rebase conflict resolution.
* Add tsconfig to components directory and include it as project
* Add @types/classnames package
* Migrate Label component to TSX
* Remove unused imports from Label component
* fix package-lock.json
It was generated with npm 7 and we don’t support that yet (and that update should be done in a separate pull)
* Add interface for LabelProps and implement.
Also:
- import `Fragment` from @wordpress/element.
- import `HTMLAttributes` explicitly as a type from react (@types/wordpress__element doesn’t export this interface).
* fix jest configuration
Co-authored-by: Darren Ethier <darren@roughsmootheng.in>
* add typescript support
* Add type declarations for Cart and CartResponse interfaces
* make sure we’re resolving .ts files as well as .js files on imports
* add more types
* type the cart data store
* Apply suggestions from code review (implement .tsx in configs)
Co-authored-by: Jon Surrell <jon.surrell@automattic.com>
* remove global fetchMock declaration and directly import where used.
* rename type
* remove named action types and just infer by returning action creator values as const
* use interface instead of type
* rename
* renames
* create CartAction type as union of action creator returned types and implement in reducer
* remove unused imports
* refresh package-lock after rebase
* Add base TS config that projects will inherit from
* Add tsconfig for assets/js/data project
* Ignore TS error on cart store registration
We will address this in cooldown when we have time to investigate further
* Add tsc to build step to catch TypeScript errors
* add a separate command for tsc and tweak build command to use
* restore checkJs and allowJs values in config and remove ts check from build command
* Add ts:check-all command
* Add TypeScript checking workflows
* Change triggers for TypeScript workflow
* Use npm ci instead of npm install
* Remove ts:check-all from TypeScript workflow
* Remove TS Check GitHub workflow
* Remove type-defs dir from TS include, and remove ts:check-all script
We no longer need the ts:check-all script because ts:check will do this for us, the old ts:check did nothing and did not work.
* fix coupon loading issues
* include .ts files only from type-defs folder
Co-authored-by: Jon Surrell <jon.surrell@automattic.com>
Co-authored-by: Thomas Roberts <thomas.roberts@automattic.com>
* Show total sale badge in medium carts
* Add markup to cart line item row to enable it to be displayed as flex
* Add styling to display price and sale badge as flex
* Revert product price being displayed as block
* Rename sale badge and price wrapper
* Hide line-total sale badge on mobile
* Change class name on total price and sale badge wrapper again
* Show total sale badge in medium carts
* Add markup to cart line item row to enable it to be displayed as flex
* Add styling to display price and sale badge as flex
* Revert product price being displayed as block
* Rename sale badge and price wrapper
* Hide line-total sale badge on mobile
* Change class name on total price and sale badge wrapper again
* Fix cart line subtotal display when currency has 0 decimals
* Fix wrong usages of getCurrency instead of getCurrencyFromPriceResponse
* Add tests
* Move comment in tests to relevant line
* Fix cart line subtotal display when currency has 0 decimals
* Fix wrong usages of getCurrency instead of getCurrencyFromPriceResponse
* Add tests
* Move comment in tests to relevant line
* Take stock status into account for All Products block.
A new `hideOutOfStockItems` setting flag has been added and it is used to hide the out of stock products
from the block. Products that are not out of stock can have 'instock', 'onbackorder' as stock status.
* Update StoreApi docs with new stock_status
* Fix the stock_status query param for collections of products
* Move bulk of payment registry/interface to more generic classes
* Implement registries for block types
* Split editor and frontend integration contexts
* Make abstract dynamic blocks extend the abstract block class
* Remove block type scripts from assets
* deprecate register_block_script
* Updates remaining blocks with new AbstactBlock which takes care of script enqueueing
* Add suffix to integration registry
* rename translator comment
* clarify method comment
* Wrong variable after rebase