E2E: update how to detect when global attributes are loaded. (#48915)

* rename helper file name

* detect attributes loaded at data-layer level

* changelog
This commit is contained in:
Damián Suárez 2024-06-28 09:39:11 +01:00 committed by GitHub
parent 185a3d579c
commit 93e148d921
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
5 changed files with 30 additions and 20 deletions

View File

@ -0,0 +1,4 @@
Significance: patch
Type: update
E2E: in the new Product Editor app, update how to detect when global attributes are loaded.

View File

@ -12,7 +12,7 @@ const attributes = require( './fixtures/attributes' );
const tabs = require( './data/tabs' ); const tabs = require( './data/tabs' );
const { const {
waitForGlobalAttributesLoaded, waitForGlobalAttributesLoaded,
} = require( './helpers/confirm-global-attributes-loaded' ); } = require( './helpers/wait-for-global-attributes-loaded' );
const { const {
createVariableProduct, createVariableProduct,

View File

@ -1,18 +0,0 @@
/**
* Waits for the spinner to appear and disappear,
* indicating that attributes have been loaded.
*
* This function confirms that the attributes have been
* loaded by waiting for a spinner to appear and then disappear.
* The spinner indicates that a loading process is occurring,
* and its disappearance indicates that the process is complete.
*
* @param {Object} page - The Playwright Page object.
*/
export async function waitForGlobalAttributesLoaded( page ) {
const spinnerLocator = page.locator(
'.woocommerce-new-attribute-modal__table-row .components-spinner'
);
await spinnerLocator.waitFor( { state: 'visible' } );
await spinnerLocator.waitFor( { state: 'hidden' } );
}

View File

@ -0,0 +1,24 @@
/**
* Waits for the global attributes to be loaded on the page.
*
* This function waits until the `hasFinishedResolution` selector
* from the `wc/admin/products/attributes` store indicates that
* the product attributes are no longer loading.
*
* @param {Object} page - The Playwright Page object.
* @return {Promise<void>} A promise that resolves when the global attributes are loaded.
*/
export async function waitForGlobalAttributesLoaded( page ) {
await page.waitForFunction( () => {
const storeId = 'wc/admin/products/attributes';
const attributeSortCriteria = { order_by: 'name' };
const isLoadingAttributes = ! wp.data
.select( storeId )
.hasFinishedResolution( 'getProductAttributes', [
attributeSortCriteria,
] );
return ! isLoadingAttributes;
} );
}

View File

@ -7,7 +7,7 @@ const { clickOnTab } = require( '../../../../utils/simple-products' );
const attributesData = require( './fixtures/attributes' ); const attributesData = require( './fixtures/attributes' );
const { const {
waitForGlobalAttributesLoaded, waitForGlobalAttributesLoaded,
} = require( './helpers/confirm-global-attributes-loaded' ); } = require( './helpers/wait-for-global-attributes-loaded' );
async function waitForAttributeList( page ) { async function waitForAttributeList( page ) {
// The list child is different in case there are no results versus when there already are some attributes, so we need to wait for either one to be visible. // The list child is different in case there are no results versus when there already are some attributes, so we need to wait for either one to be visible.