-
Notifications
You must be signed in to change notification settings - Fork 221
e2e tests for cart and checkout templates #9939
e2e tests for cart and checkout templates #9939
Conversation
The release ZIP for this PR is accessible via:
Script Dependencies ReportThere is no changed script dependency between this branch and trunk. This comment was automatically generated by the TypeScript Errors Report
assets/js/blocks-registry/payment-methods/test/payment-method-config-helper.ts
assets/js/blocks/active-filters/block.tsx assets/js/blocks/cart-checkout-shared/payment-methods/saved-payment-method-options.js assets/js/blocks/classic-template/index.tsx assets/js/blocks/classic-template/test/utils.ts assets/js/data/payment/utils/check-payment-methods.ts assets/js/editor-components/template-notice/index.tsx assets/js/interactivity/components.js |
Size Change: 0 B Total Size: 1.18 MB ℹ️ View Unchanged
|
2ac1e60
to
3bace80
Compare
43f5a50
to
f1a4139
Compare
af9242f
to
efb2b52
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
There's a lot going on in this PR, and still some eslint errors in some files, were these introduced by a bad merge?
I pointed a few possible test improvements out and maybe one TS improvement.
We should revise uses of page.click
with a selector passed in, and instead get the locator first, then .click
on that.
Feel free to ping when these have been revised and I'll take another look!
*/ | ||
import { Page } from '@playwright/test'; | ||
|
||
export const addToCart = async ( page: Page ) => { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Nothing actionable here, but I just pointing out that we could probably add product name as an arg here too. Thinking about when we're on the shop page and we call this, it would fail because of multiple add to cart buttons, so if we add a product name we could call by the button's label:
Add “Beanie” to your basket
test.describe( 'Test the order confirmation template', async () => { | ||
test( 'Template can be opened in the site editor', async ( { page } ) => { | ||
await page.goto( '/wp-admin/site-editor.php' ); | ||
await page.click( 'text=Templates' ); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
page.click
is deprecated the documentation mentions clicking a locator is better.
We could do await page.getByText( 'Templates' ).click()
instead. (But it might not work if there are multiple instances of the Templates
text on the page, so might need to qualify this locator further).
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It says "discouraged"—is that the same thing? I've copied usage from other tests and the global-setup file. I'd rather leave it as I'm just trying to get new tests added rather than update our playwright implementation.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yeah you're right, sorry I misread it as deprecated, I'm so used to seeing that in yellow boxes in documentation 🙈
I am ok with it being left like this for now if updating it is going to delay this PR being merged. I would like to revisit at some point though.
@@ -100,9 +100,9 @@ for ( const { templateTitle, slug, frontendPage } of Object.values( | |||
|
|||
await page.goto( frontendPage ); | |||
|
|||
const helloWorldText = await page.getByText( 'Hello World' ); | |||
|
|||
expect( helloWorldText ).not.toBeNull(); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This was a bug! getByText
returns arrays
There were several failing tests from classic templates. I wasn't able to fix those and I believe its due to a lack of tear down utils causing pages to have unexpected content. To unblock this PR I've commented them out but I imagine they'll need to be reworked cc @gigitux Locally the remaining tests, and new tests, are passing so this can be re-reviewed now @opr |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Tests are passing for me locally - just a couple of comments but I think this can be merged after addressing my suggestion about test.skip
, I think we should do that. Note, you may need to eslint ignore an error about skipping tests, I think this is OK and expected.
} ); | ||
|
||
/* |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
What do you think about test.skip
here and in other places with commented out tests. Might be more searchable when it comes to finding skipped tests later.
'/wp-admin/admin.php?page=wc-settings&tab=advanced' | ||
); | ||
const cartInput = page.locator( | ||
'tr:has-text("Cart page "):has-text("cart template") input' |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Just noting that I would love to revisit this and use the provided locators in future. For now this is OK to get tests working.
6207faf
into
add/9288_cart-checkout-order-received_fse_templates
* Merge branch 'trunk' into poc/cart_and_checkout_fse_templates * Merge branch 'trunk' into add/9288_cart-checkout-order-received_fse_templates * Resolve merge conflicts * Add e2e for permalink settings * Test that templates exist * Add test to check that templates can be edited * Add tests to confirm templates can be edited * Ensure cart has contents before running tests on frontend views * Commend out problem test * Make sure search has multiple results * Remove useThrottle - bad rebase * Revert changes to docs after rebase * Revert function call for noReviewsPlaceholder * Bad rebase * Reverts * Remove revertTemplate * Spacing * Wait for networkidle after navigation * Always wait for network * Use button roles in site editor * More specific button locator * Update option comparison * Fix template content * Disable failing tests * Disable failing classic template tests * Use enterEditMode * More enterEditMode usage * enterEditMode * Use test.skip * More robust selectors * Alt iframe selector --------- Co-authored-by: Paulo Arromba <17236129+wavvves@users.noreply.github.com>
* WIP: dirty attempt to dry run Cart & Checkout templates * Added Cart and Checkout to the template hierarchies * Merge branch 'trunk' into poc/cart_and_checkout_fse_templates * Updated cart & Checkout templates * Order Received FSE template (#8937) * Order Received template bootstrap * typo * WIP: new block * add logic here * Order received classic template * reverted constants.ts * Added the post title (buggy) * Corrected page title * Updated constants.ts * Fixed template typo * removed placeholder for order received block * add order-received template description * updated placeholder description * Formatting fixes * Template description. * replaced hardcoded string with OrderReceivedTemplate::SLUG --------- Co-authored-by: Luigi <gigitux@gmail.com> * Code formatting (#8350) * Code formatting * page_template_hierarchy priority to 1 (#9323) Co-authored-by: Paulo Arromba <17236129+wavvves@users.noreply.github.com> * Migrate Cart and Checkout Pages to the Template Editor when using a FSE theme (#9339) * Introduce woocommerce_blocks_template_content hook * Migrate cart and checkout page content to the template editor * Add redirection from edit page to edit template --------- Co-authored-by: Paulo Arromba <17236129+wavvves@users.noreply.github.com> * Removed header and footer from checkout template. (#9378) * Removed header and footer from checkout template. * Removed header and footer from checkout template migration * Permalink solution for the checkout endpoint/template (#9406) * Checkout endpoint work * Move setting field to util * Include link to edit the template * Remove todo * Refactor checkout templates to share logic (#9411) * Sync endpoints with pages (#9426) * Switch to page syncing * Update settings descriptions --------- Co-authored-by: Paulo Arromba <17236129+wavvves@users.noreply.github.com> * Migrate pages to templates once (#9488) * Migrate content on init, once * Skip migration if page does not exist * Put back HTML for header and footer parts * Fix page redirect due to wrong ID * fix loading template part * Removed unnecessary var * update cart and checkout html templates --------- Co-authored-by: Paulo Arromba <17236129+wavvves@users.noreply.github.com> * Include a notice to redirect user to template editor (#9508) * Template Placeholder Design for the Order Received Template (#9602) * Load frontend styles in editor iframe * Update placeholder to include skeleton and updated icons * Update classic template configs * 1px border for .wp-block-woocommerce-classic-template__placeholder-copy * Show copy on focus * Sample data --------- Co-authored-by: Paulo Arromba <17236129+wavvves@users.noreply.github.com> * Add simplified header on checkout template (#9607) * Added simplified header on checkout template * Moved simplified header to template part * updated constants.ts * added template part to checkout.html * Add missing translation * frontpage_template_hierarchy no longer needed * Allow plugin based template parts (#9667) * Merge branch 'trunk' into add/9288_cart-checkout-order-received_fse_templates * Synced templates on blockified folder * Add blockified order-received.html * removed WooCommerce prefix * Refactor/rebrand order received template to order confirmation (#9734) * rebrand order received to order confirmation * updated descriptions for templates * updated descriptions for order confirmation placeholder * Resolve merge conflict * Resolve merge conflicts * Resolve more merge conflicts after rebase * Fix formatting * Use patterns for localisation (#9883) * e2e tests for cart and checkout templates (#9939) * Merge branch 'trunk' into poc/cart_and_checkout_fse_templates * Merge branch 'trunk' into add/9288_cart-checkout-order-received_fse_templates * Resolve merge conflicts * Add e2e for permalink settings * Test that templates exist * Add test to check that templates can be edited * Add tests to confirm templates can be edited * Ensure cart has contents before running tests on frontend views * Commend out problem test * Make sure search has multiple results * Remove useThrottle - bad rebase * Revert changes to docs after rebase * Revert function call for noReviewsPlaceholder * Bad rebase * Reverts * Remove revertTemplate * Spacing * Wait for networkidle after navigation * Always wait for network * Use button roles in site editor * More specific button locator * Update option comparison * Fix template content * Disable failing tests * Disable failing classic template tests * Use enterEditMode * More enterEditMode usage * enterEditMode * Use test.skip * More robust selectors * Alt iframe selector --------- Co-authored-by: Paulo Arromba <17236129+wavvves@users.noreply.github.com> * Skip flakey test --------- Co-authored-by: Luigi <gigitux@gmail.com> Co-authored-by: Mike Jolley <mike.jolley@me.com>
I'm not sure what other cases are needed so this needs feedback from @wavvves but I've introduced e2e tests to check that each new template exists in the editor, and that the permalink settings save and update the frontend page.
Fixes #9863
Testing
Automated Tests
User Facing Testing
e2e tests should pass.