-
Notifications
You must be signed in to change notification settings - Fork 219
Interactivity API and Product Button: Add E2E tests #10036
Interactivity API and Product Button: Add E2E tests #10036
Conversation
…oocommerce/woocommerce-blocks into add/6949-interactivity-api-product-button-e2e
…ocks into add/create-frontendUtils-class
…oocommerce/woocommerce-blocks into add/create-frontendUtils-class
…oocommerce/woocommerce-blocks into add/6949-interactivity-api-product-button-e2e
…oocommerce/woocommerce-blocks into add/6949-interactivity-api-product-button-e2e
The release ZIP for this PR is accessible via:
Script Dependencies ReportThe
This comment was automatically generated by the TypeScript Errors Report
assets/js/atomic/blocks/product-elements/button/frontend.tsx
assets/js/interactivity/store.js node_modules/preact/src/jsx.d.ts |
Size Change: 0 B Total Size: 1.35 MB ℹ️ View Unchanged
|
It is necessary work to a middleware to avoid this kind o...It is necessary work to a middleware to avoid this kind of code.
woocommerce-blocks/tests/e2e-pw/utils/storeApi/StoreApiUtils.ts Lines 18 to 29 in a143631
🚀 This comment was generated by the automations bot based on a
|
…ocks into add/6949-interactivity-api-product-button-e2e
…://github.com/woocommerce/woocommerce-blocks into add/6949-interactivity-api-product-button-e2e
…ithub.com/woocommerce/woocommerce-blocks into add/6949-interactivity-api-product-button-e2e
…ithub.com/woocommerce/woocommerce-blocks into add/6949-interactivity-api-product-button-e2e
I removed @danieldudzic as reviewer since that he is AFK. |
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.
Hey Luigi! Great work 🙌🏻
I left a few minor comments, but everything else looks good to me 🚀
tests/e2e-pw/tests/product-button/product-button.block_theme.side_effects.spec.ts
Outdated
Show resolved
Hide resolved
await admin.page.goto( | ||
'wp-admin/admin.php?page=wc-settings&tab=products' | ||
); |
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.
I think we can remove this line since the handleAddToCartAjaxSetting
function already handles this.
tests/e2e-pw/tests/product-button/product-button.block_theme.side_effects.spec.ts
Outdated
Show resolved
Hide resolved
await Promise.all( [ | ||
block.locator( 'loading' ).waitFor( { | ||
state: 'detached', | ||
} ), | ||
block.click(), | ||
] ); |
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.
I noticed a potential issue in the code related to a race condition:
await Promise.all( [
block.locator( 'loading' ).waitFor( {
state: 'detached',
} ),
block.click(),
] );
Here, you're trying to execute two actions concurrently:
- Waiting for the
loading
element within theblock
to become detached. - Clicking the
block
element.
The problem is that if the block
element requires the loading
element to be fully detached before it can be clicked, then attempting to click the block
while the loading
element is still in the process of detaching could cause unexpected behaviors or errors in the test.
To avoid this race condition, I'd recommend executing the actions sequentially:
await block.locator( 'loading' ).waitFor( {
state: 'detached',
} );
await block.click();
This ensures the loading
element is fully detached before attempting to click the block
element.
What do you think? Have I misunderstood something? 🤔
tests/e2e-pw/tests/product-button/product-button.block_theme.side_effects.spec.ts
Outdated
Show resolved
Hide resolved
…ithub.com/woocommerce/woocommerce-blocks into add/6949-interactivity-api-product-button-e2e
…ithub.com/woocommerce/woocommerce-blocks into add/6949-interactivity-api-product-button-e2e
…9-interactivity-api-product-button-e2e
…://github.com/woocommerce/woocommerce-blocks into add/6949-interactivity-api-product-button-e2e
Thanks for the feedback, @imanish003! I addressed your feedback! |
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.
Hey @gigitux,
Fantastic job, and thank you for incorporating my feedback. Your responsiveness is greatly appreciated 🙌🏻
I ran the E2E tests locally, and all tests are passing without any issues. 🚀
|
||
test( 'should be visible', async ( { frontendUtils } ) => { | ||
const blocks = await frontendUtils.getBlockByName( blockData.slug ); | ||
await expect( await blocks ).toHaveCount( |
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.
I think you might have missed removing the await from await blocks
. 🤔
* Update Interactivity API JS files * Disable TS checks in the Interactivity API for now * Add new SSR files * Replace wp_ prefixes with wc_ ones * Replace wp- prefix with wc- * Replace guternberg_ prefix with woocommerce_ * Remove file comments from Gutenberg * Rename files with `wp` prefix * Fix code to load Interactivity API php files * Remove TODO comments * Replace @WordPress with @woocommerce * Update Webpack configuration * Fix directive prefix * Remove interactivity folder from tsconfig exclude * Add client-side navigation meta tag code * Remove unneeded blocks.php file * Fix store tag id * Register Interactivity API runtime script * Fix Interactivity API runtime registering * Remove all files related to directive processing in PHP * Move json_encode to Store's render method * WIP * WIP * WIP * WIP * Preserve previous context * Ignore Minicart block on client-side navigation * Refresh page on store updatRefresh page on store updatee * Refactor logic * Add console error when a path is missing * fix PHP lint error * WIP store * use store approach * update jest configuration * restore Mini Cart changes * move cart store subscription to interactivity package * move interactivity flag * format HTML * move addToCartText to the context * Load product-query stylesheet when rendering the Products block * update sideEffects array * fix catch * rename moreThanOneItem to isThereMoreThanOneItem * improve how scripts are enqueued * update default value for the filter woocommerce_blocks_enable_interactivity_api * Update assets/js/atomic/blocks/product-elements/button/block.json Co-authored-by: Albert Juhé Lluveras <contact@albertjuhe.com> * Update assets/js/interactivity/cart/cart-store.ts Co-authored-by: Albert Juhé Lluveras <contact@albertjuhe.com> * fix block.json * remove updateStore function * restore interactivity api changes * import cart store * show notice when there is an error * add logic to dequeue script on classic themes and block themes * imrpove logic about notice * Interactivity API: add `afterLoad` callbacks to `store()` function (#10338) * show notice when there is an error * Add initial implementation for store callbacks * Run `afterLoad` callbacks after `init` * Move cart state subscription to Product button * Remove cart-store from Interactivity API internals * Change callbacks with options and save only afterLoad callbacks * ProductButton: Add animation (#10351) * implement animation * improve logic * refactor logic * refactor code * address feedback about code style * add support for woocommerce_add_to_cart_quantity * Fix animation flickering * Introduce wp-effect, reduce the amount of numberOfItem variables to 2 and consolidate animation status * add support for added class * Remove unnecessary selector * Don't fetch cart if it was already fetched * remove added class --------- Co-authored-by: Luis Herranz <luisherranz@gmail.com> --------- Co-authored-by: Luigi <gigitux@gmail.com> Co-authored-by: Luis Herranz <luisherranz@gmail.com> * update deepsignal * remove added class * update deepsignal * Interactivity API and Product Button: Add E2E tests (#10036) * Add FrontendUtils class * fix conflicts * use locator * restore click usage * Product Button: Add E2E test * fix util * fix E2E tests * remove comment * Add E2E test to ensure that woocommerce_product_add_to_cart_text works * update sideEffects array * add zip and unzip as package * fix wp-env configuration * fix E2E test * add report * try now * try now * try now * fix E2E test * E2E: Add documentation for testing actions and filters. Fixes #10135 (#10206) * update description * fix label * rename files * make requestUtils private * remove page.goto * use toHaveCount * use productsToDisplay variable * fix E2E tests * rename class utils --------- Co-authored-by: Daniel Dudzic <daniel.dudzic@automattic.com> --------- Co-authored-by: David Arenas <david.arenas@automattic.com> Co-authored-by: Luis Herranz <luisherranz@gmail.com> Co-authored-by: Albert Juhé Lluveras <contact@albertjuhe.com> Co-authored-by: Daniel Dudzic <daniel.dudzic@automattic.com>
This PR adds E2E for #10006.
This PR includes two raw implementations for (missing some work to consider those two points finished and usable for all E2E tests):
Furthermore, I set up the traces upload. In this way, we can debug locally the E2E tests that fail.
Testing
Automated Tests
User Facing Testing
e2e tests should pass.