Skip to content
This repository has been archived by the owner on Feb 23, 2024. It is now read-only.

Fix 404 and 500 errors in E2E test logs, editor and front-end. #5989

Merged
merged 18 commits into from
Mar 10, 2022

Conversation

tomasztunik
Copy link
Contributor

@tomasztunik tomasztunik commented Mar 3, 2022

Motivation

Running the E2E tests and debugging their failures was becoming unwieldy. Our logs were polluted by large amounts of errors, most of which wouldn't make the tests fail, but were in fact captures of the browser's console logs. This made it hard to identify the actual culprits of a failed test run and to parse the logs output.

This PR aims to clean up all those false negatives, and output cleaner logs.

Changes

  • Change atomic blocks to not use custom webpack build paths:

Originally, we had treated atomic blocks as different, since they were only supposed to be registered in case a parent component was consuming them. With the advent of Global Styles, and the move towards FSE where the atomic blocks are going to be used as product elements, this distinction made less sense.

Specifically, we had outputted the built components as custom-named webpack chunks, which meant that classes inheriting from AbstractBlock needed to hardcode this custom path to be compatible.

This meant that we previously had to enqueue scripts in the editor to make sure they were loaded correctly (see, e.g., #5816), but the class handling of the assets were still trying to fetch them by their default path, causing a slew of 404 errors which weren't really impacting the functionality of the application, but were triggering unnecessary network requests and were caught by Jest during our E2E tests, polluting the logs.

Additionally, on the front-end it also caused more 404 errors, due to blocks being registered normally as a requirement for enabling Global Styles.

A side-effect of this PR is simplifying this configuration, as now default paths work and don't have to be hard-coded.

This change moves build output for atomic blocks from build/atomic-block-components/_name_ to build/product-_name_ reflecting the actual block name and always prefixed with context namespace (product) to avoid possible name clashes.

  • Ensure all atomic blocks are now registered via php

Currently AddToCart and SKU blocks were missing as the only blocks that did not support global styles yet, this adds basic setup so that we can unify how

  • Ensure all lazy loaded blocks (using chunks) register their chunk_translations by themselves via php

Before AllProducts.php took the responsibility for registering all chunks which was easy to miss or not understand implications. Registered chunks in AllProducts were making them available for usage outside of AllProducts as well.

  • Add missing emptytheme footer.html template part

The theme emptytheme was added as the most minimal block theme possible, in order to cleanly test Site Editor related features. As its purpose was supposed to be getting away with the most minimal of themes, the footer template part had not originally been included.

This caused 404 error as this template part is always fetched when user navigates in the site template editor.

  • Replaced trashAllPosts with new REST API based deleteAllTemplates util

Previously, we used a util called trashAllPosts which navigated to the post UI and deleted all the posts to tear down any side-effects of template editing tests.

However, with a recent change introduced in WordPress 5.9.1, Core removed the UI for those and that made our tests meet a 500 error.

Using the REST API should also make all the tests faster.

  • Remove deprecated usage of Puppeteer waitFor

Puppeteer has deprecated the use of the generic waitFor method for more specific methods to avoid confusion.

Deprecation warnings were polluting the logs, so we switched to more specific methods (i.e. mostly changed waitFor with waitForTimeout).

Fixes #5945
Fixes #5957

Testing

Automated Tests

  • Changes in this PR are covered by Automated Tests.
    • Unit tests
    • E2E tests

Manual Testing

How to test the changes in this Pull Request:

  1. Run E2E tests
  2. there should be no 404 or 500 errors in the test logs

User Facing Testing

These are steps for user testing (where "user" is someone interacting with this change that is not editing any code).

  • Same as above, or
  • See steps below.
  1. Visit the editor
  2. Add Single Page and All Products blocks
  3. There should be no 404 errors in the editor
  4. Visit the created page in the front-end
  5. There should be no 404 errors in the page

@rubikuserbot rubikuserbot requested review from a team and frontdevde and removed request for a team March 3, 2022 14:59
@github-actions
Copy link
Contributor

github-actions bot commented Mar 3, 2022

Size Change: -1.66 kB (0%)

Total Size: 862 kB

Filename Size Change
build/active-filters-frontend.js 5.92 kB -356 B (-6%)
build/active-filters.js 6.96 kB -5 B (0%)
build/all-products-frontend.js 18.2 kB -367 B (-2%)
build/all-products.js 33.9 kB -55 B (0%)
build/all-reviews.js 8.02 kB -7 B (0%)
build/atomic-block-components/add-to-cart--atomic-block-components/button--atomic-block-components/catego--90468e1a.js 0 B -223 B (removed) 🏆
build/atomic-block-components/add-to-cart--atomic-block-components/button--atomic-block-components/image---a7e2bb9b.js 0 B -2.64 kB (removed) 🏆
build/atomic-block-components/add-to-cart-frontend.js 0 B -7.01 kB (removed) 🏆
build/atomic-block-components/add-to-cart.js 0 B -7.49 kB (removed) 🏆
build/atomic-block-components/button--atomic-block-components/category-list--atomic-block-components/imag--f11cdc7a.js 0 B -501 B (removed) 🏆
build/atomic-block-components/button-frontend.js 0 B -2.08 kB (removed) 🏆
build/atomic-block-components/button.js 0 B -2.3 kB (removed) 🏆
build/atomic-block-components/category-list-frontend.js 0 B -922 B (removed) 🏆
build/atomic-block-components/category-list.js 0 B -500 B (removed) 🏆
build/atomic-block-components/image-frontend.js 0 B -1.86 kB (removed) 🏆
build/atomic-block-components/image.js 0 B -1.08 kB (removed) 🏆
build/atomic-block-components/price-frontend.js 0 B -1.95 kB (removed) 🏆
build/atomic-block-components/price.js 0 B -1.51 kB (removed) 🏆
build/atomic-block-components/rating-frontend.js 0 B -1.14 kB (removed) 🏆
build/atomic-block-components/rating.js 0 B -717 B (removed) 🏆
build/atomic-block-components/sale-badge-frontend.js 0 B -1.1 kB (removed) 🏆
build/atomic-block-components/sale-badge.js 0 B -683 B (removed) 🏆
build/atomic-block-components/sku-frontend.js 0 B -386 B (removed) 🏆
build/atomic-block-components/sku.js 0 B -386 B (removed) 🏆
build/atomic-block-components/stock-indicator-frontend.js 0 B -1.04 kB (removed) 🏆
build/atomic-block-components/stock-indicator.js 0 B -623 B (removed) 🏆
build/atomic-block-components/summary-frontend.js 0 B -1.34 kB (removed) 🏆
build/atomic-block-components/summary.js 0 B -923 B (removed) 🏆
build/atomic-block-components/tag-list-frontend.js 0 B -923 B (removed) 🏆
build/atomic-block-components/tag-list.js 0 B -498 B (removed) 🏆
build/atomic-block-components/title-frontend.js 0 B -1.31 kB (removed) 🏆
build/atomic-block-components/title.js 0 B -933 B (removed) 🏆
build/attribute-filter-frontend.js 16.8 kB +46 B (0%)
build/attribute-filter.js 13.1 kB -15 B (0%)
build/blocks-checkout.js 17.4 kB +1 B (0%)
build/cart-blocks/accepted-payment-methods-frontend.js 1.16 kB +1 B (0%)
build/cart-blocks/checkout-button-frontend.js 1.15 kB -5 B (0%)
build/cart-blocks/express-payment-frontend.js 5.18 kB -13 B (0%)
build/cart-blocks/filled-cart-frontend.js 759 B -8 B (-1%)
build/cart-blocks/items-frontend.js 300 B +2 B (+1%)
build/cart-blocks/line-items-frontend.js 5.5 kB -3 B (0%)
build/cart-blocks/order-summary-frontend.js 8.87 kB -11 B (0%)
build/cart-blocks/totals-frontend.js 320 B -1 B (0%)
build/cart-frontend.js 45 kB -363 B (-1%)
build/cart.js 43.6 kB -19 B (0%)
build/checkout-blocks/actions-frontend.js 1.41 kB -2 B (0%)
build/checkout-blocks/billing-address--checkout-blocks/shipping-address-frontend.js 4.12 kB -12 B (0%)
build/checkout-blocks/contact-information-frontend.js 2.83 kB -9 B (0%)
build/checkout-blocks/express-payment-frontend.js 5.48 kB -15 B (0%)
build/checkout-blocks/fields-frontend.js 344 B -1 B (0%)
build/checkout-blocks/order-note-frontend.js 1.52 kB +384 B (+34%) 🚨
build/checkout-blocks/order-summary-frontend.js 11.3 kB +1 B (0%)
build/checkout-blocks/payment-frontend.js 7.76 kB -18 B (0%)
build/checkout-blocks/shipping-address-frontend.js 998 B +1 B (0%)
build/checkout-blocks/shipping-methods-frontend.js 4.74 kB +6 B (0%)
build/checkout-blocks/terms-frontend.js 1.22 kB -3 B (0%)
build/checkout-frontend.js 47.2 kB -374 B (-1%)
build/checkout.js 44.7 kB -30 B (0%)
build/featured-category.js 8.62 kB -11 B (0%)
build/featured-product.js 9.72 kB -13 B (0%)
build/handpicked-products.js 7.09 kB -19 B (0%)
build/legacy-template.js 2.19 kB -1 B (0%)
build/mini-cart-component-frontend.js 16.5 kB -16 B (0%)
build/mini-cart-contents-block/empty-cart-frontend.js 329 B +1 B (0%)
build/mini-cart-contents-block/footer--mini-cart-contents-block/products-table-frontend.js 5.32 kB -8 B (0%)
build/mini-cart-contents-block/footer-frontend.js 5.67 kB -4 B (0%)
build/mini-cart-contents-block/items-frontend.js 226 B +1 B (0%)
build/mini-cart-contents-block/products-table-frontend.js 5.36 kB +2 B (0%)
build/mini-cart-contents-block/shopping-button-frontend.js 287 B -1 B (0%)
build/mini-cart-contents.js 23.6 kB -7 B (0%)
build/mini-cart.js 6.33 kB -2 B (0%)
build/price-filter-frontend.js 12.1 kB -361 B (-3%)
build/product-best-sellers.js 7.37 kB -18 B (0%)
build/product-categories.js 3.17 kB -5 B (0%)
build/product-category.js 8.48 kB -26 B (0%)
build/product-new.js 7.67 kB -15 B (0%)
build/product-on-sale.js 7.98 kB -18 B (0%)
build/product-search.js 2.18 kB -6 B (0%)
build/product-tag.js 7.81 kB -16 B (0%)
build/product-top-rated.js 7.9 kB -15 B (0%)
build/products-by-attribute.js 8.39 kB -18 B (0%)
build/reviews-by-category.js 11.4 kB -15 B (0%)
build/reviews-by-product.js 12.6 kB -19 B (0%)
build/reviews-frontend.js 6.97 kB -374 B (-5%)
build/single-product-frontend.js 21.6 kB -368 B (-2%)
build/single-product.js 10 kB -20 B (0%)
build/stock-filter-frontend.js 6.5 kB +6 B (0%)
build/stock-filter.js 6.57 kB -7 B (0%)
build/vendors--atomic-block-components/add-to-cart--cart-blocks/order-summary--checkout-blocks/billing-ad--c5eb4dcd-frontend.js 0 B -19 kB (removed) 🏆
build/vendors--atomic-block-components/add-to-cart-frontend.js 0 B -7.51 kB (removed) 🏆
build/vendors--atomic-block-components/price--cart-blocks/line-items--cart-blocks/order-summary--checkout--194c50bf-frontend.js 0 B -5.26 kB (removed) 🏆
build/vendors--cart-blocks/order-summary--checkout-blocks/billing-address--checkout-blocks/order-summary---eb4d2cec-frontend.js 4.74 kB +1 B (0%)
build/vendors--mini-cart-contents-block/footer--mini-cart-contents-block/products-table-frontend.js 7.35 kB -364 B (-5%)
build/wc-blocks-registry.js 2.7 kB +1 B (0%)
build/wc-blocks-shared-context.js 1.52 kB +5 B (0%)
build/wc-blocks-vendors.js 70.7 kB +1.1 kB (+2%)
build/product-add-to-cart--product-button--product-category-list--product-image--product-price--product-r--a0326d00.js 222 B +222 B (new file) 🆕
build/product-add-to-cart--product-button--product-image--product-title.js 2.64 kB +2.64 kB (new file) 🆕
build/product-add-to-cart-frontend.js 7 kB +7 kB (new file) 🆕
build/product-add-to-cart.js 7.47 kB +7.47 kB (new file) 🆕
build/product-button--product-category-list--product-image--product-price--product-rating--product-sale-b--e17c7c01.js 499 B +499 B (new file) 🆕
build/product-button-frontend.js 2.08 kB +2.08 kB (new file) 🆕
build/product-button.js 2.29 kB +2.29 kB (new file) 🆕
build/product-category-list-frontend.js 923 B +923 B (new file) 🆕
build/product-category-list.js 499 B +499 B (new file) 🆕
build/product-image-frontend.js 1.85 kB +1.85 kB (new file) 🆕
build/product-image.js 1.08 kB +1.08 kB (new file) 🆕
build/product-price-frontend.js 1.93 kB +1.93 kB (new file) 🆕
build/product-price.js 1.51 kB +1.51 kB (new file) 🆕
build/product-rating-frontend.js 1.13 kB +1.13 kB (new file) 🆕
build/product-rating.js 713 B +713 B (new file) 🆕
build/product-sale-badge-frontend.js 1.09 kB +1.09 kB (new file) 🆕
build/product-sale-badge.js 681 B +681 B (new file) 🆕
build/product-sku-frontend.js 380 B +380 B (new file) 🆕
build/product-sku.js 382 B +382 B (new file) 🆕
build/product-stock-indicator-frontend.js 1.03 kB +1.03 kB (new file) 🆕
build/product-stock-indicator.js 620 B +620 B (new file) 🆕
build/product-summary-frontend.js 1.33 kB +1.33 kB (new file) 🆕
build/product-summary.js 918 B +918 B (new file) 🆕
build/product-tag-list-frontend.js 917 B +917 B (new file) 🆕
build/product-tag-list.js 495 B +495 B (new file) 🆕
build/product-title-frontend.js 1.31 kB +1.31 kB (new file) 🆕
build/product-title.js 932 B +932 B (new file) 🆕
build/vendors--cart-blocks/line-items--cart-blocks/order-summary--checkout-blocks/order-summary--checkout--6efbf40e-frontend.js 5.26 kB +5.26 kB (new file) 🆕
build/vendors--cart-blocks/order-summary--checkout-blocks/billing-address--checkout-blocks/order-summary---4f3822fa-frontend.js 19.3 kB +19.3 kB (new file) 🆕
build/vendors--product-add-to-cart-frontend.js 7.54 kB +7.54 kB (new file) 🆕
ℹ️ View Unchanged
Filename Size
build/cart-blocks/empty-cart-frontend.js 346 B
build/checkout-blocks/billing-address-frontend.js 891 B
build/checkout-blocks/totals-frontend.js 325 B
build/mini-cart-contents-block/filled-cart-frontend.js 230 B
build/mini-cart-contents-block/title-frontend.js 367 B
build/mini-cart-frontend.js 1.72 kB
build/price-filter.js 8.49 kB
build/price-format.js 1.19 kB
build/vendors--cart-blocks/line-items--checkout-blocks/order-summary--mini-cart-contents-block/products-table-frontend.js 3.14 kB
build/wc-blocks-data.js 9.83 kB
build/wc-blocks-editor-style-rtl.css 4.84 kB
build/wc-blocks-editor-style.css 4.84 kB
build/wc-blocks-google-analytics.js 1.56 kB
build/wc-blocks-middleware.js 953 B
build/wc-blocks-shared-hocs.js 1.14 kB
build/wc-blocks-style-rtl.css 22.2 kB
build/wc-blocks-style.css 22.2 kB
build/wc-blocks-vendors-style-rtl.css 1.28 kB
build/wc-blocks-vendors-style.css 1.28 kB
build/wc-blocks.js 2.62 kB
build/wc-payment-method-bacs.js 816 B
build/wc-payment-method-cheque.js 811 B
build/wc-payment-method-cod.js 909 B
build/wc-payment-method-paypal.js 837 B
build/wc-settings.js 2.61 kB

compressed-size-action

@tomasztunik tomasztunik changed the title Change atomic blocks to not use custom webpack build paths Fix 404 errors we see in editor and front-end including in E2E test logs Mar 3, 2022
@tomasztunik tomasztunik changed the title Fix 404 errors we see in editor and front-end including in E2E test logs Fix 404 and 500 errors we see in editor and front-end including in E2E test logs Mar 3, 2022
@tomasztunik tomasztunik changed the title Fix 404 and 500 errors we see in editor and front-end including in E2E test logs Fix 404 and 500 errors in E2E test logs, editor and front-end. Mar 3, 2022
@sunyatasattva sunyatasattva added the skip-changelog PRs that you don't want to appear in the changelog. label Mar 4, 2022
@sunyatasattva sunyatasattva marked this pull request as ready for review March 4, 2022 13:48
Copy link
Contributor

@gigitux gigitux left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for working on this! 💪

404 errors disappear, but for the tests, I have some errors in my local env, but on CI, everything looks great. I guess it is a problem with my env.

I added two comments about the package.json. My suggestion is to do another npm install to generate a new package-lock.json.

package.json Outdated Show resolved Hide resolved
package.json Outdated Show resolved Hide resolved
@tomasztunik tomasztunik force-pushed the fix/5945-404-errors branch from c8c0f47 to c63d4b4 Compare March 9, 2022 08:44
tomasztunik and others added 10 commits March 9, 2022 09:45
we want to always load lazy loaded components from their default paths
to avoid having to handle importing components in different ways for
regular and atomic component packages
The Site Editor is expecting the footer parts to be there or it will try to
load them anyways and throw a 404. It's not breaking, but it's polluting
the console.
Previously, we used a util called `trashAllPosts` which navigated to the post UI
and deleted all the posts to tear down any side-effects of template editing tests.

However, with a [recent change](WordPress/wordpress-develop@14e20f7),
WP Core removed the UI for those and that made our tests meet a 500 error.

Using the REST API should also make everything faster.
was still present in attribute-filter.test.js
Before it was responsible for enabling translations for all the atomic blocks
@tomasztunik tomasztunik force-pushed the fix/5945-404-errors branch 2 times, most recently from e441cc6 to 6d88635 Compare March 9, 2022 09:42
@gigitux gigitux force-pushed the fix/5945-404-errors branch from 6d88635 to fa27249 Compare March 9, 2022 10:15
@tomasztunik tomasztunik force-pushed the fix/5945-404-errors branch from f908feb to 84bfa7f Compare March 9, 2022 10:49
@tomasztunik
Copy link
Contributor Author

tomasztunik commented Mar 9, 2022

With @gigitux we've wanted to understand more the possible impact of changing the translations and we've learned a little bit more how the process works. Changing the chunk names will cause the translations to stop working as the loading of translation files is based on the md5 checksum of the translated filename path. Once new translation files are generated when deployed to w.org existing translations should be reused and new translation json file will be generated with md5 part reflecting changed block entrypoint filename.

This release will require downloading of new translation files if it doesn't happen automatically :)

So 🤞 but looks like it should be good.

@gigitux gigitux force-pushed the fix/5945-404-errors branch from 90da334 to e1260af Compare March 9, 2022 17:42
@tomasztunik
Copy link
Contributor Author

We should verify after realease if we need to do any manual trigger to regenerate translation files for new version

Copy link
Contributor

@gigitux gigitux left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Great job! Thanks for working on this @tomasztunik @sunyatasattva

We should verify after realease if we need to do any manual trigger to regenerate translation files for new version

Good point, but from what we discovered, the process should be pretty smooth 🤞

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
skip-changelog PRs that you don't want to appear in the changelog.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

404 error on product-sale-badge.js All Product Block and atomic blocks: 404 errors
4 participants