Commit Graph

70 Commits

Author SHA1 Message Date
Saad Tarhi 1e15672b7b Shopper → Checkout → Can place an order as guest (https://github.com/woocommerce/woocommerce-blocks/pull/6009)
* Add "goToCheckout" method in "shopper.block"

Instead of using "shopper.goToCheckoutBlock" method, it will much easier
to maintain the following structure "shopper.block.goToCheckout"

* Create a constant for billing details

* Create "fillBillingDetails" shopper method

* Add "placeOrder" method to "shopper"

* Enable "Cash on delivery" payment method for our test

* Update "@woocommerce/e2e-utils" package

Some new useful e2e utility functions weren't avaiable in the previous version

* Add E2E test for "Can place an order as guest"

* Fix mini-cart failing E2E tests

In case this fix woocommerce/woocommerce-blocks#6006 isn't merged yet, this commit can be used to pass all
E2E tests

Co-authored-by: Saad Tarhi <saad.tarhi@automattic.com>
2022-03-08 14:52:40 +01:00
Tung Du 75b5181e0e Shopper → Mini Cart → Can view empty cart message and start shopping button (https://github.com/woocommerce/woocommerce-blocks/pull/5918) 2022-03-08 17:01:27 +07:00
Saad Tarhi c0aec1e85b Fix mini cart failling tests (https://github.com/woocommerce/woocommerce-blocks/pull/6006)
Set the correct "emptyCart" utility function

Co-authored-by: Saad Tarhi <saad.tarhi@automattic.com>
2022-03-08 00:09:20 +01:00
Saad Tarhi dee5032d41 Shopper → Cart → Can proceed to checkout (https://github.com/woocommerce/woocommerce-blocks/pull/5901)
* Shopper → Cart → Can proceed to checkout

* Refactor the code for E2E testing

Introduce some discussed solution to structure and optimize the code

* Resolve some conflicts with the trunk branch

* Remove method overriding and refactor code

We are trying to avoid overriding exiting E2E Woo's utility functions

Instead we can use our own "shopper.block"

* Use a consistent constant naming convention

Co-authored-by: Saad Tarhi <saad.tarhi@automattic.com>
2022-03-07 16:23:31 +01:00
Tung Du 892d7c268d Shopper → Mini Cart → Can update product quantity (https://github.com/woocommerce/woocommerce-blocks/pull/5963) 2022-03-04 17:40:13 +07:00
Tung Du 43529e5735 Shopper → Mini Cart → Can go to Cart page (https://github.com/woocommerce/woocommerce-blocks/pull/5977) 2022-03-04 16:57:34 +07:00
Tung Du 33ac2d5f4b Shopper → Mini Cart → Can proceed to checkout (https://github.com/woocommerce/woocommerce-blocks/pull/5978) 2022-03-03 08:24:30 +07:00
Lucio Giannotta 08a99165ca Add mock theme with Woo Templates for E2E tests (https://github.com/woocommerce/woocommerce-blocks/pull/5920)
This PR adds a block-enabled theme with templates for WooCommerce
which is intended to be used when testing the more complex scenarios
such as template fallbacks.

Additionally, since theme-dependent logic seems to be becoming more
and more useful (see woocommerce/woocommerce-blocks#5913), this PR also adds a utility function used to
explicitly declare theme dependencies of a test (`useTheme`).

Said function will activate the theme before running a given suite and then
reactivate the previous theme, as to make sure to not have any side-effects
(such as the ones described in woocommerce/woocommerce-blocks#5913 above).

Closes woocommerce/woocommerce-blocks#5660
2022-03-02 15:49:00 +01:00
Tung Du 22eccc8614 Shopper → Mini Cart → Can view filled mini cart contents block (https://github.com/woocommerce/woocommerce-blocks/pull/5923) 2022-03-01 18:25:13 +07:00
Lucio Giannotta 8ad1dff1f4 Rename templates to more e-commerce friendly names (https://github.com/woocommerce/woocommerce-blocks/pull/5935) 2022-02-28 08:00:01 +01:00
Thomas Roberts 7915a793fa Await expectations in checkout frontend test (https://github.com/woocommerce/woocommerce-blocks/pull/5942) 2022-02-25 18:21:10 +00:00
Tung Du 49c5659eb9 Shopper → Mini Cart → Can open/close the drawer (https://github.com/woocommerce/woocommerce-blocks/pull/5894) 2022-02-24 21:02:24 +07:00
Thomas Roberts bbe68f395e Change tests that use the incorrect `waitForSelector` API (https://github.com/woocommerce/woocommerce-blocks/pull/5932)
* Change tests that use the incorrect waitForSelector API

* Use .toMatchElement instead of just .toMatch

* Use sentence case for page title check
2022-02-24 11:31:26 +00:00
Thomas Roberts 918de7bc75 Ensure screenshots can be attached in jest html report (https://github.com/woocommerce/woocommerce-blocks/pull/5919)
* Ensure screenshots can be attached in jest html report

* Force tests to fail in ci

* Console log for testing

* Console log for testing

* Check on hook failure as well as test failure

* Revert "Force tests to fail in ci"

This reverts commit 6efebd63bba4792214f5b24824fb405cf38b1367.

* Take full page screenshot only when error type is not hook_failure

* Remove console log
2022-02-24 09:06:24 +00:00
Tung Du 47f8993a8d Shopper → Mini Cart → Can see the icon with a badge (https://github.com/woocommerce/woocommerce-blocks/pull/5877) 2022-02-22 09:50:59 +07:00
Lucio Giannotta 341a742916 E2E tests for Product Tag Template and Legacy Block (https://github.com/woocommerce/woocommerce-blocks/pull/5888)
Also: 

* Add fixtures for tags
* Teardown both categories and tags when tests are done
2022-02-21 13:26:22 +01:00
Lucio Giannotta d64ebc72dc E2E tests for Product Category Template and Legacy Block (https://github.com/woocommerce/woocommerce-blocks/pull/5820) 2022-02-21 12:38:36 +01:00
Lucio Giannotta 5de9fec527 E2E tests for Product Archive Template and Legacy Block (https://github.com/woocommerce/woocommerce-blocks/pull/5748)
Also:
* Refactors the function to add a custom paragraph
* Add front-end test for archive template
* Use WordPress data to guarantee block presence
* Use WordPress data instead of selectors to match blocks
2022-02-21 12:01:56 +01:00
Lucio Giannotta 497820dcb9 E2E tests for Single Product Template (https://github.com/woocommerce/woocommerce-blocks/pull/5722)
* Add empty block theme to mock E2E tests
* Install empty theme in the test WP instance
2022-02-21 11:01:42 +01:00
Niels Lange 6946a0c189 Remove obsolete * in comment 2022-02-14 17:55:28 +07:00
Alex Florisca 16d5e773bc Reformatted prettier files (https://github.com/woocommerce/woocommerce-blocks/pull/5735) 2022-02-07 16:59:44 +00:00
Tung Du 4dab187dbe Fix: only allow Mini Cart block in Widgets and Site Editor (https://github.com/woocommerce/woocommerce-blocks/pull/5653)
* fix: exclude Mini Cart from the blocks editor

* fix: explicitly register Mini Cart blocks for Site Editor and Widgets

* add check to loading the block on frontend

* add e2e tests for widget area

* improve test title

Co-authored-by: Luigi <gigitux@gmail.com>
2022-02-07 11:29:22 +01:00
Thomas Roberts 426eb51830 Update Checkout block E2E fixture and increase node version in GH actions (https://github.com/woocommerce/woocommerce-blocks/pull/5678)
* Remove unnecessary setup step and use node v16 in E2E action

* Ensure storefront is active

* Use new checkout fixture

* Try with only checkout test

* Update package.json

* Run all tests, not just checkout
2022-02-01 11:14:16 +00:00
Thomas Roberts 5036c69638 Add E2E tests for Filter blocks (Price, Attribute, and Active Filters) (https://github.com/woocommerce/woocommerce-blocks/pull/4562)
* Add clear and fill input test util

* Add tests for Filter Products by Price

* Add class name to filter products by price block in editor

* Update wp-env

* Fix formatting

* Update lock

* Revert "Update lock"

This reverts commit f4e809e000430eea3972c94fd2aea0a19ba6961b.

* Create product attributes during setup

* Remove product attributes during teardown

* Add attributes in fixture-data

* Add two new products, for attribute testing

* Load attributes into store and apply them to products

* Add class to Filter by Attribute when editing

This is so it can be targeted in E2E tests more easily.

* Add tests for Filter Product by Attribute

* Fix formatting in attribute-filter.test.js

* Add tests for active filters block

* Add doc block for ensuteCleanAttributes

* Update wording of title test in all filter block E2E

* Update test wording to read better

* Update snapshots

* Use pptr-testing-library selectors to click elements

This makes the tests easier to reason with, and lets us take a step back from the implementation details (classnames etc.)

* Add saveOrPublish test util

* Use pptr-testing-library selectors to click elements in attribute filter

* Use pptr-testing-library selectors to click elements in price filter

* Add `puppeteer-testing-library`

* Use puppeteer-testing-library API to look for H6 button

* Use correct argument in jest-puppeteer.dev.config

* Update package.json & package-lock.json

* remove tests for 5.3

* remove snapshots

* Remove ensureCleanAttributes

* Remove puppeteer-testing-library, install missing expect-puppeteer package and update tests

The puppeteer-testing-library, although added by gutenberg is not actively used.
I have removed it and realised that the added functionality can be easily replaced by expect-puppeteer.
This is a package that we specify in the jest configuration but it was not part of our package.json.
The selectors from puppeteer-testing-library have been replaced with .toClick and the utility clearAndFillInput with .toFill

The Filter by Attribute block has been skiped until tests are fixed.

* Add back setupPageSettings to jest setup

* Fix filter by attribute block test

* Fix linting error

Co-authored-by: Raluca Stan <ralucastn@gmail.com>
2021-12-23 17:26:10 +01:00
Mike Jolley 70f0c06bf9 Fix e2e tests welcome guide/m1 mac support (https://github.com/woocommerce/woocommerce-blocks/pull/5096)
* Bump dependencies to fix e2e on m1 macs

* Disable welcome guide more reliably - see 3da717b8d0/packages/e2e-test-utils/src/create-new-post.js

* Update selectors and fixture data for cart block

* unused dep

* Remove duplicate block wrapper

* Remove unused jest configuration files

* More robust click in view switcher test

* Revert fixture data change
2021-11-09 13:18:55 +00:00
Mike Jolley 72cf5eade8 Remove hydration hocs in favour of apiFetch Middlewares (https://github.com/woocommerce/woocommerce-blocks/pull/5022)
* Remove withRestApiHydration

* Preload checkout data via setting - server data is required for this block

* Handle cart hydration using createPreloadingMiddleware which removes the need for HOCs

* Rename variable

* Remove withStoreCartApiHydration and timestamp checking

* Empty test file
2021-11-04 11:05:58 +00:00
Seghir Nadir 2408e34faa Migrate Cart i1 to Cart i2 (https://github.com/woocommerce/woocommerce-blocks/pull/4973)
* move empty cart

* remove Cart and rename Cart i2 to Cart

* graduate blocks

* setup template migration from Cart i1 to Cart i2

* back to js so we have a good diff

* add migration

* fix bug in empty cart template

* add useForceLayout hook to edit

* migrate from old block to new block

* migrate styles

* respect align

* add tests

* Include latest cart line item improvements from cart-i1

* Missing changes from cart-i1

* Line items table should be disabled

* Fix e2e tests for cart i2

* update tests to adapt for inner blocks

* update select to resolveSelect to remove warning checker

* rename test/block to test/index

* move blocks to their own file

* undo rename to keep diff clean

* remove .tsx and update jest config

* Revert "update select to resolveSelect to remove warning checker"

This reverts commit 79d55de30edcfe36bbdfe7506df7a09460824f03.

* revert resolveControl

* Fix empty cart editor E2E test by scrolling to the view switch

* parse attributes for order summary block

* migrate attributes when resaving

* Update documentation

Automatic update after running npm run build:docs

* add align options to filled cart and empty cart

* append instead of replcae

* import style.scss in frontend

Co-authored-by: Mike Jolley <mike.jolley@me.com>
Co-authored-by: Raluca Stan <ralucastn@gmail.com>
2021-10-25 15:46:34 +01:00
Tung Du 7dc9b16f4a Add basic E2E tests for products grid blocks (https://github.com/woocommerce/woocommerce-blocks/pull/4872)
* wip: add product on sale test

* test: add fixture for product on sale test

* try: permission

* Revert "try: permission"

This reverts commit f8eb09c0152a567383e93c18f61e91fdadd13c40.

* test: basic e2e test for products by category block

* test: basic e2e test for products by tag block

* add basic test for products by attribute block

* trigger build

* fix: slug
2021-10-21 10:23:15 +01:00
Tung Du bd3e7126f8 Mini Cart block: display a compatibility notice when the user first adds the block in the editor (https://github.com/woocommerce/woocommerce-blocks/pull/4945) 2021-10-21 16:07:20 +07:00
Mike Jolley 4385619be5 Fix notice in e2e test suite from potentially undefined id 2021-10-20 10:11:20 +01:00
Mike Jolley 2e0d0faa84 Enforce valid states from the API (https://github.com/woocommerce/woocommerce-blocks/pull/4844)
* Enforce valid states from the API

* Remove paypal from test
2021-10-19 14:30:02 +01:00
Mike Jolley dc19412a54 Update dependency @woocommerce/e2e-utils to v0.1.6 (https://github.com/woocommerce/woocommerce-blocks/pull/4957)
* Update @woocommerce/e2e-utils

* Define grouped
2021-10-18 20:01:10 +01:00
Niels Lange 40e43b5328 Add e2e tests for Hand-picked Products (https://github.com/woocommerce/woocommerce-blocks/pull/4788) 2021-10-18 15:07:24 +01:00
Niels Lange 3f530ac755 Add e2e tests for Best Selling Products (https://github.com/woocommerce/woocommerce-blocks/pull/4785) 2021-10-18 15:06:48 +01:00
Albert Juhé Lluveras c3152aec96 Add e2e tests to verify disabled blocks can't be inserted into widget areas (https://github.com/woocommerce/woocommerce-blocks/pull/4910) 2021-10-18 08:48:03 +02:00
Niels Lange 8475bc7bad Add e2e tests for Top Rated Products (https://github.com/woocommerce/woocommerce-blocks/pull/4786) 2021-10-11 17:05:50 +01:00
Niels Lange ff78f58556 Add e2e tests for Product Categories List (https://github.com/woocommerce/woocommerce-blocks/pull/4915) 2021-10-11 18:59:45 +07:00
Niels Lange 6286f7fbd6 Add e2e tests for Newest Products (https://github.com/woocommerce/woocommerce-blocks/pull/4789) 2021-10-11 18:55:38 +07:00
Thomas Roberts 255a74b328 Add screenshots on E2E test failures (https://github.com/woocommerce/woocommerce-blocks/pull/4898)
* Add test environment to catch errors

* Add jest-circus and jest-html-reporters

This is so we can log the screenshots and errors that happen during E2E tests.

* Use the jest reporters and jest-circus to run the E2E tests

* Force cart test to break

Revert this!

* Upload jest report artifact when tests fail

* Run artifact upload on failure

* Upload entire report directory to artifact

* Revert "Force cart test to break"

This reverts commit c57f2c5ab1d7b60d8824d854c1cb9a8281a71c4b.

* Update .gitignore and jest.config

* Force cart test to break

* Force cart test to break

* Remove <rootDir> from jest-html-reporter path

This was causing the artefact not to upload.

* Revert "Force cart test to break"

Co-authored-by: Niels Lange <info@nielslange.de>
2021-10-08 11:58:44 +01:00
Niels Lange 6dc54c1268 Add e2e tests for Featured Category (https://github.com/woocommerce/woocommerce-blocks/pull/4773) 2021-09-20 18:34:06 +07:00
Niels Lange 37920b118d Add E2E tests for Featured Products (https://github.com/woocommerce/woocommerce-blocks/pull/4771) 2021-09-17 14:07:26 +02:00
Mike Jolley 5c08c75612 Update Checkout to Checkout i2 (https://github.com/woocommerce/woocommerce-blocks/pull/4745)
* Remove i2 from build

* Remove i2 php registration

* Rename old checkout dir

* Rename i2 dir

* Migrate i1 to i2 code

* Register block metadata to fix frontend rendering when migrating to i2

* Register in correct order

* Missing styles

* add register-components to side effectful list

* wrong block class in e2e test

* wp prefix missing on selector

* Fix top level block test

* Reselect labels to work around rerendering

* missing empty cart styles

* Consolodate duplicate styles

* remove init code

* update selectBlockByName

Co-authored-by: Nadir Seghir <nadir.seghir@gmail.com>
2021-09-16 13:16:21 +01:00
Thomas Roberts a2772a1cad Add E2E and Unit (PHP and JS) tests for Filter by Stock block. (https://github.com/woocommerce/woocommerce-blocks/pull/4682)
* Add back end E2E tests for Filter by Stock

* Add unit/snapshot tests for Filter by stock block

* Refactor Filter by Stock block to load stock statuses in the block body

This is required to make the code easier to test, since the mocked settings were being applied immediately after the block was imported, which didn't give time to let the `allSettings` override take place in the unit tests.

* Add PHP Unit tests for test_custom_stock_counts of ProductQueryFilters

* Remove useMemo from stock filter block

This felt like an overoptimisation, it's very inexpensive to run this every render. The result is less complex code, so it's better this way imo.

* Move initial stock options and the values they are derived from into useState

* Add class name to block in editor
2021-09-15 09:20:31 +01:00
Albert Juhé Lluveras ebdacd62d7 Add initial e2e tests to Mini Cart block (https://github.com/woocommerce/woocommerce-blocks/pull/4677) 2021-09-08 10:14:53 +02:00
Mike Jolley a7d7ea32bb Fix unfiltered html usage of blocks (https://github.com/woocommerce/woocommerce-blocks/pull/4551)
* SSR search

* deprecation handling for search

* Update snaps

* Fix duplicate class and align class property
2021-08-12 17:39:38 +01:00
Mike Jolley 7ff3dac568 Fix e2e tests: Remove paypal from fixture data (https://github.com/woocommerce/woocommerce-blocks/pull/4507)
* Remove paypal from fixture data

* Fix scroll hoc tests

* Missing return type in cart causing TS error

* update e2e utils

* Replace searchForBlock method in e2e utils

* Single block update insert block

* Use insertBlockDontWaitForInsertClose
2021-07-26 15:05:09 +01:00
Raluca Stan 092a28848c Fix e2e checkout tests and adjust jest setup (https://github.com/woocommerce/woocommerce-blocks/pull/4216)
* 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.
2021-05-18 15:09:30 +02:00
Raluca Stan 7deea0eee8 Fix cart and checkout frontend e2e tests (https://github.com/woocommerce/woocommerce-blocks/pull/4199)
* 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>
2021-05-16 18:41:34 +01:00
Raluca Stan b9db5d4c51 Fix/cart backend test (https://github.com/woocommerce/woocommerce-blocks/pull/4153)
* Fix backend cart e2e test

* Adjust test structure

* Fix e2e checkout backend test.

Make sure the confirmation window is closed
2021-05-05 12:52:27 +01:00
Thomas Roberts e6c7f2b6c0 Check for element before trying to click it in cart backend test (https://github.com/woocommerce/woocommerce-blocks/pull/4087) 2021-04-27 09:39:31 +01:00