This repository has been archived by the owner on Feb 23, 2024. It is now read-only.
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add E2E tests for Product Collection Block (#9825)
* Add E2E tests for Product Collection Block This commit does the following changes: 1. Adjusts the .gitignore file to ignore the test-results and artifacts directories under all subdirectories named 'e2e-pw'. 2. Adds new E2E tests for the Product Collection block, specifically testing: - If the block renders correctly, including validating the number of product images, titles, prices, and 'Add to Cart' buttons. - If the sidebar settings correctly control the number of displayed columns. 3. Implements the 'ProductCollectionPage' class, providing methods to perform actions such as creating a new post, inserting a block, publishing a post, and locating various elements on the page. 4. Adjusts the directory structure for the E2E tests to improve organization and readability. * Minor improvements * Update E2E tests for Product Collection block sidebar settings This commit updates the E2E tests for the sidebar settings of the Product Collection block. The changes include: 1. Refactoring the test assertions to use property accessors instead of method calls for the `ProductCollectionPage` class. This improves readability and consistency. 2. Updating the `ProductCollectionPage` class to initialize locators for editor and frontend elements separately. This allows easier differentiation between editor and frontend locators. The test file `sidebar-settings.block_theme.spec.ts` has been deleted, as its functionality is now covered by the updated tests in `product-collection.block_theme.spec.ts`. * Don't update package.json files * Don't update gitignore file * Add E2E test for order by control This commit updates the E2E tests for the sidebar settings and order by control of the Product Collection block. The changes include: 1. Refactoring the test assertions and descriptions for improved readability and clarity. 2. Adding a new test case to verify the correct sorting of products by title in descending order. 3. Updating the `ProductCollectionPage` class to include a new method `setOrderBy()` to set the order by value in the order by control. 4. Adding a new method `waitForProductsToLoad()` in the `ProductCollectionPage` class to wait for the products to load in the block. These changes ensure that the sidebar settings and order by control are functioning correctly in the Product Collection block. * Minor improvements * Add tests for "on sale" filter * Add tests for Hand picked products filter This commit updates the E2E tests for the handpicked products filter in the Product Collection block. The changes include: 1. Adding a new test case to verify that products can be filtered based on the selection in the handpicked products option. 2. Adding a new method `addFilter()` to the `ProductCollectionPage` class to select a filter option from the dropdown. 3. Adding a new method `setHandpickedProducts()` to the `ProductCollectionPage` class to set the handpicked products in the block settings. These changes ensure that the handpicked products filter is functioning correctly in the Product Collection block. * Verify that on sale filter works on frontend Adding assertions to verify the count and presence of on-sale products in the frontend after publishing. * Add tests for Keyword filter This commit updates the E2E tests for the keyword filter in the Product Collection block. The changes include: 1. Adding assertions to verify that the products are correctly filtered based on the keyword entered. 2. Adding assertions to verify the filtered products in the frontend after publishing. These changes ensure that the keyword filter in the Product Collection block is functioning correctly. * Use fixture to setup product collection page This commit refactors the E2E tests for the Product Collection block to improve test structure and readability. The changes include: 1. Refactoring the test structure using the `test.extend` function to define shared setup and teardown logic. 2. Moving the creation of the `ProductCollectionPage` instance to the shared setup logic. 3. Using the `pageObject` fixture in each test to access the `ProductCollectionPage` instance. 4. Removing duplicate code for creating the `ProductCollectionPage` instance. These changes enhance the maintainability and readability of the E2E tests for the Product Collection block.
- Loading branch information