Commit Graph

22 Commits

Author SHA1 Message Date
Jonathan Lane 8e2e7de7ce
Migrate Puppeteer test action from Blocks repo (#42733)
* Migrate Puppeteer test action from Blocks repo

* Update file path

* Use pnpm

* Use npm

* Updates based on feedback

* Comment out paths for testing

* Fix paths with working directory

* Use pnpm

* Fix missing pnpms

* npm instead

* Do use pnpm

* Update command

* Blocks wp-env config

* Update paths, config files

* Run test commands from blocks

* Config update

* Uncomment paths so that e2e checks only run on Blocks

---------

Co-authored-by: Jon Lane <jon.lane@automattic.com>
2023-12-13 16:01:34 -08:00
Christopher Allford ec9b7852f9
Fixed Blocks Linting Errors (#42727) 2023-12-12 15:05:20 -08:00
Saad Tarhi 33978990a5 Move shopper-side Checkout E2E tests to Playwright (https://github.com/woocommerce/woocommerce-blocks/pull/11998)
* convert first local pickup test

* Convert the second local pickup test

This test detected a bug. We will skip it for now and create a ticket to fix it!

* Remove old local pickup E2E tests

* Convert Payment Methods E2E tests

* Remove old payment methods tests

* Convert shipping/billing E2E tests

* Remove old shipping/billing E2E tests

* Add some line breaks for a better readability

* Update tests/e2e/tests/checkout/checkout-block.shopper.block_theme.side_effects.spec.ts

Co-authored-by: Niels Lange <info@nielslange.de>

* Fix ESLint errors

* Move E2E tests to the Checkout shopper file

* Fix ESLint error

* Convert Checkout Error Forms E2E tests

* Use guest user instead of logged in customer for Checkout Errors E2E tests

---------

Co-authored-by: Niels Lange <info@nielslange.de>
2023-12-08 21:35:53 +01:00
Saad Tarhi 417683095a Playwright E2E tests: Multiple signed in roles (https://github.com/woocommerce/woocommerce-blocks/pull/10561)
* Convert checkout place order E2E tests to Playwright

* Add "gotoMyAccount" method

* Create login/logout utility functions

* Use the existing "customer" test data

* Complete the place order test cases

* Fix "My Account" page title

* Fix rebase

* Reset My account page title

* Check for heading instead of the page title

* Check for heading in login/logout functions

* Fix all failing tests

* Add guest/customer/admin roles

* Update the auth setup

* Register the auth setup within Playwright

* Update testing cases

* Add generated auth files to .gitignore

* Tidy up comments

Co-authored-by: Thomas Roberts <5656702+opr@users.noreply.github.com>

* Remove unnecessary comment

Co-authored-by: Thomas Roberts <5656702+opr@users.noreply.github.com>

* Update comments

Co-authored-by: Thomas Roberts <5656702+opr@users.noreply.github.com>

* Remove unnecessary comment

Co-authored-by: Thomas Roberts <5656702+opr@users.noreply.github.com>

* Update comment for Guest case

Co-authored-by: Thomas Roberts <5656702+opr@users.noreply.github.com>

* Remove confusing comment

* Remove another unnecessary comment

* Remove unnecessary Playwright project dependency

* Tidy up the file structure and constants

* Fix mixed up test descriptions

* Remove commented code

Co-authored-by: Thomas Roberts <5656702+opr@users.noreply.github.com>

* Remove unnecessary function from frontend-utils

* Refactor testing cases

* Rename testing file

* Delete unused testing file

* Ensure we're logged out before trying to log in as a user

* Log out before each authentication setup step

* Ensure tests requiring admin are logged in

* Log in as admin during block theme setup

* Fix Playwright strict mode violation

* Run Multiple sign-in roles to the global-setup phase

In this step of the Playwright's setup, we can add the multiple sign-in
roles and keeping the admin logged by default.
This fixes the issue of failing tests `logged out` error.

* Remove unnecessary login as admin

* Remove "auth.setup" dependency since the logic lives in the global setup instead

* Remove unnecessary login as admin from test files

The admin profile is set by default

---------

Co-authored-by: Thomas Roberts <5656702+opr@users.noreply.github.com>
Co-authored-by: Thomas Roberts <thomas.roberts@automattic.com>
2023-12-08 17:44:59 +01:00
Thomas Roberts 906961be3b Move merchant-side Checkout E2E tests to Playwright (https://github.com/woocommerce/woocommerce-blocks/pull/11853) 2023-12-07 17:32:18 +00:00
Niels Lange 7a0835e354 Migrate translation tests to Playwright (https://github.com/woocommerce/woocommerce-blocks/pull/12070)
* Migrate translation tests to Playwright

* Optimise tests

* Migrate translation tests to Playwright

* Optimise tests

* Run test as side effects
2023-12-07 16:50:00 +00:00
Luigi Teschio 88562d1106 Products By Attribute: E2E tests - skip test (https://github.com/woocommerce/woocommerce-blocks/pull/12085) 2023-12-07 17:19:50 +01:00
Darren Ethier 795f008952 Implement the Block Hooks API to automatically inject the Mini-Cart block (https://github.com/woocommerce/woocommerce-blocks/pull/11745)
* Change the default for Mini Cart block

The Block Hooks API currently doesn’t allow for setting the default state of the block injected into content so this ensures the mini-cart block has a better default state for injection. The current default (displaying total value in cart) takes up more width increasing the risk of poor layout.

* Utilize Block Hooks to automatically inject mini-cart block.

* include experimental prefix on filters

* Fix filter name.

* remove experimental prefix.

On thinking about this, I don’t think these need to be experimental. They are intentionally provided as escape hatches for hosts/themes that want to opt-in/out so we’ll have to support them when this is shipped (at least until its no longer needed!)

* fix variable name!

* fix unit tests because of new default

* remove another incorrect text expectation

Defaults for the block affect this expectation.

* fix E2E tests

* Mini Cart Block: improve E2E test

* fix: improve check for the Product Collection block

---------

Co-authored-by: Luigi Teschio <gigitux@gmail.com>
2023-12-04 17:27:27 +01:00
Thomas Roberts 66cc2bd9e8 Move checkout terms & conditions/privacy policy tests (https://github.com/woocommerce/woocommerce-blocks/pull/11973) 2023-11-29 04:16:44 -08:00
Thomas Roberts a652fa18f8 Move the Checkout -> Account tests from puppeteer to Playwright (https://github.com/woocommerce/woocommerce-blocks/pull/11961) 2023-11-28 23:16:25 +04:00
Thomas Roberts d32be3f47b Migrate cart/checkout tax tests to Playwright (https://github.com/woocommerce/woocommerce-blocks/pull/11954) 2023-11-28 21:00:40 +07:00
Thomas Roberts eaab9950af Update Puppeteer E2E tests to WP 6.4.1 and disable failing ones (https://github.com/woocommerce/woocommerce-blocks/pull/11816)
Co-authored-by: Luigi Teschio <gigitux@gmail.com>
2023-11-20 13:06:12 +01:00
Mike Jolley 2044798af6 Remove Shipping calculator settings and link to the WooCommerce admin settings (https://github.com/woocommerce/woocommerce-blocks/pull/11184)
* Remove block level options in favour of settings

* Remove calculator toggle test

* Update assets/js/blocks/cart/inner-blocks/cart-order-summary-shipping/block.tsx

Co-authored-by: Thomas Roberts <5656702+opr@users.noreply.github.com>

* Remove unused attributes

---------

Co-authored-by: Thomas Roberts <5656702+opr@users.noreply.github.com>
2023-10-11 15:09:43 +01:00
Mike Jolley 27ae9acafc Remove all instances of GUTENBERG_EDITOR_CONTEXT (https://github.com/woocommerce/woocommerce-blocks/pull/11126) 2023-10-10 10:57:26 +00:00
Alexandre Lara 3ecd34e01a Upgrade webpack to version 5 (https://github.com/woocommerce/woocommerce-blocks/pull/8013)
* Upgrade terser-webpack-plugin to version 4.2.3

* Upgrade webpack-bundle-analyzer to 4.7.0

* Upgrade to Webpack version 5

* Upgrade @wordpress/dependency-extraction-webpack-plugin to 4.6.0

* Upgrade dependency copy-webpack-plugin to version 11.0.0

* Upgrade dependency terser-webpack-plugin to version 5.3.6

* Replace webpack-rtl-plugin with the new @automattic/webpack-rtl-plugin

* Replace module.issuer with the new ModuleGraph API

There is a warning appearing in the console when running the application. This is due to the fact that the module.issuer has been deprecated on Webpack 5 and replaced with the new ModuleGraph API. This commit replaces the deprecated API with the new one.

* Upgrade babel and babel plugins to latest version

* Replace jsonpFunction with the new uniqueName property

Add a unique name of the webpack build to avoid multiple webpack runtimes to conflict when using globals. It defaults to output.library name or the package name from package.json in the context, if both aren't found, it is set to an ''.

* Replace cacheDirectory inline configuration with options.cacheDirectory

* Upgrade @wordpress/e2e-tests dependency to version 5.6.0

* Remove babel-plugin-transform-react-jsx dependency

Remove babel-plugin-transform-react-jsx dependency because it is already included in @wordpress/babel-preset-default

* Remove unnecessary Babel dependencies

Remove some unnecessary babel dependencies that are already included in the @babel/preset-env package.

* Upgrade puppeteer dependency to version 16.2.0

* Remove caret from package.json dependencies

* Fix Storybook build error

This commit fixes the Storybook build error that was being caused because of Storybook by default uses Webpack 4, but since we are currently upgrading our webpack to version 5, we need to install some required dependencies and also explicitly tell Storybook to use Webpack 5.

* Fix package-lock.json after merging with trunk

* Add own webpack-rtl-plugin implementation to the project

Before upgrading Webpack to version 5, we were using the original `webpack-rtl-plugin` released by Romain Berger; unfortunately, this plugin is not compatible with Webpack 5, so we replaced it with `@automattic/webpack-rtl-plugin`. The problem is that `@automattic/webpack-rtl-plugin` by default generates files with the '.rtl.css' suffix and does not provide a way to change that.

This commit adds our own implementation of the `webpack-rtl-plugin` (adapted from `@automattic/webpack-rtl-plugin`) that is compatible with Webpack 5 and allows us to change the suffix of the generated files to follow the recommended way defined by Wordpress (https://codex.wordpress.org/Right-to-Left_Language_Support)

* Change conditional clause to be multiline

* Fix package-lock.json after merge with trunk

* Fix package-lock.json after merge with trunk

* Rename files to fix ESLint errors

This commit renames files that have the .js extension but contain JSX code. This is causing ESLint to throw errors because by default our Eslint configuration expects only files with the .jsx extension to contain JSX code.

* Fix package-lock.json file

* Add is-plain-obj module to the transformIgnorePatterns of jest config

* Update package-lock.json

* Fix package-lock.json

* Upgrade @wordpress/i18n dependency to version 4.31.0

* Update package-lock.json

* Update composer lock file

* Fix Webpack config for Webpack 5

* Add the package-lock.json

* Remove unsupported config from webpack

* Fix error with Webpack build

* Add wait for network idle to the tests

* Attempt to fix e2e test

* Restore promise.all

* Upgrade puppeteer to v17.1.3

* Upgrade expect-puppeteer

* Update expect-puppeteer

* Downgrade expect-puppeteer

* Revert "Upgrade puppeteer to v17.1.3"

This reverts commit 61ed52a56f131961f3970b6fb22cdd8b540bada3.

* Upgrade Puppeteer to version 17.1.3

* Fix executionContext.frame is not a function error

* Fix e2e tests

* Remove isExperimentalBuild from Product Gallery inner blocks

* Upgrade Webpack and Webpack-cli to latest version

* Upgrade postcss and mini-css plugins

* Fix error with mini-cart block

* Fix styling error with filter blocks

* Fix issue when running unit tests

* Fix storybook script not loading

* Fix a11y issue in Storybook

* Fix error when multiple isExperimentalBuild was being used

* Prevent error when layout is not present in the attributes object

* Update `chunkIds` to `named` in Webpack

* Add cache groups to the Webpack configs
2023-09-20 17:31:52 -03:00
Sam Seay abd41cae11 Fixes for jest transpilation issues. (https://github.com/woocommerce/woocommerce-blocks/pull/10788)
* Fix bug where is-plain-obj is not transpiled by Jest, update lock.
* Update packages.
* Mock useSelect for a handful of RichText selectors in test.
* Resolve react to single version to avoid invalid hook errors.
* Patch trim-html locally to avoid a bug in the released npm source.
* Mock out resizeObserver to avoid https://github.com/FezVrasta/react-resize-aware/issues/58
* Don't transpile config package: https://github.com/node-config/node-config/issues/628
2023-09-05 04:03:35 +00:00
Thomas Roberts 55f65cdf17 Move cart widget tests to playwright and ensure classic/block theme configs are executed correctly (https://github.com/woocommerce/woocommerce-blocks/pull/10669) 2023-08-28 03:04:28 -07:00
Thomas Roberts 38594b3c9f Cart e2e test housekeeping (https://github.com/woocommerce/woocommerce-blocks/pull/10663) 2023-08-22 16:31:38 -07:00
Manish Menaria f40131c33e Remove client side navigation from Products beta block (https://github.com/woocommerce/woocommerce-blocks/pull/10636)
* Remove client side navigation from Products beta block

Changes:
- Removed the `add_navigation_id_directive` method and its associated filter. This method previously added a `data-wc-navigation-id` attribute to the query block for client-side navigation, which is no longer required.
- Removed the `add_navigation_link_directives` method and its associated filter. This method previously added interactive directives to pagination links inside the Query Pagination block. This specific functionality has been removed as it is no longer needed.
- Introduced a new method `mark_block_as_interactive`, which is designed to mark the Product Query as an interactive region so that interactive elements can work inside it. This is achieved using the 'data-wc-interactive' attribute.

* add data-wc-interactive to product button block

* Remove unnecessary code

As we have added `data-wc-interactive` on Product button therefore we don't need to add it in Product Query block.

* Boolean attribute doesn't need explicit value equal to true

* Skip failing i18n-related E2E tests

* Skip failing i18n-related E2E test

---------

Co-authored-by: Luigi <gigitux@gmail.com>
Co-authored-by: Niels Lange <info@nielslange.de>
2023-08-17 15:45:59 +02:00
Thomas Roberts ad9b732629 Convert shipping selection Checkout tests to playwright (https://github.com/woocommerce/woocommerce-blocks/pull/10532)
* Create selectAndVerifyShippingOption method

* Add goToCheckout util

* Add emptyCart util

* Add selectAndVerifyShippingOption to FrontendUtils class

* Add initial checkout shopper test file and a shipping options test

* Remove selectAndVerifyShippingOptions from frontendUtils

* Re-add selectAndVerifyShippingOption to checkout block test

* Move cart and checkout blocks into their own directories

* Create CheckoutPage class to keep utils for checkout

* Use CheckoutPage class in Checkout tests

* Update name of test suite

* Remove nested describe

* Move to correct folder, make selectAndVerifyShippingOption return

* Remove networkidle and goToCheckout from frontendutils

* Add placeOrder util

* Add fillBilingDetails util to checkout page

* Add fillShippingDetails util to checkout page

* Add fillInCheckoutWithTestData util to checkout page

* Add checkCustomerPushCompleted util to checkout page

* Change test to focus on free shipping and flat rate in separate tests

* Instead of waiting for selector, just wait for the shipping name

* Check element visibility instead of count

* Use postcode id rather than autocomplete value

* Don't instantiate FrontendUtils

* Delete tests that have been moved to playwright

* Add test to side effects project because it adds items to cart

* Remove unused method

* Go to cart page before removing items

This is to ensure the cart data store is loaded

* Empty cart before proceeding with tests

* Re-implement goToCheckout to frontendUtils

* Remove check for whether customer data has been pushed

Rely instead on order complete page to check for address details.

* Ensure request to set shipping option is complete

* Get email address from page not billing form (its not there)

* Move testData to class property

* Add verifyAddressDetails util

* Make test check for setting different addresses and shipping in same run

* Remove User can have different shipping and billing addresses from jest

* Pass in playwright's request to the frontend utils file

* Update emptyCart function to use API requests to empty the cart

* Pass request utils to frontendUtils class

* Update frontendUtils to use requestUtils for API requests
2023-08-15 03:42:29 -07:00
Mike Jolley 566513e3ed Simplify code path and remove todo (https://github.com/woocommerce/woocommerce-blocks/pull/10526) 2023-08-11 10:44:50 +01:00
Mike Jolley 2b80d3e830 Rename commands and directories for Playwright and JEST e2e tests (https://github.com/woocommerce/woocommerce-blocks/pull/10493)
* Move e2e to e2e-jest

* Move e2e-pw to e2e

* Update e2e usage + scripts

* Missed some directory renames

* Update gitignore

* Remove test results as its in gitignore
2023-08-08 17:58:12 +01:00