[e2e tests] Fix flaky test create-variable-product-block-editor > can create a variation option and publish the product (#51246)
This commit is contained in:
parent
9fd4b54902
commit
31a2474c3b
|
@ -0,0 +1,4 @@
|
|||
Significance: patch
|
||||
Type: dev
|
||||
|
||||
|
|
@ -147,10 +147,25 @@ test.describe( 'Variations tab', { tag: '@gutenberg' }, () => {
|
|||
);
|
||||
|
||||
for ( const term of sizeAttribute.terms ) {
|
||||
const apiResponsePromise = page.waitForResponse(
|
||||
( response ) => {
|
||||
const urlToMatch = `/wp-json/wc/v3/products/attributes/${ newAttrData.id }/terms?name=${ term.name }&slug=${ term.slug }`;
|
||||
|
||||
return (
|
||||
response
|
||||
.url()
|
||||
.includes( encodeURI( urlToMatch ) ) &&
|
||||
response.status() === 201
|
||||
);
|
||||
}
|
||||
);
|
||||
|
||||
// Fill the input field with the option
|
||||
await FormTokenFieldInputLocator.fill( term.name );
|
||||
await FormTokenFieldInputLocator.press( 'Enter' );
|
||||
|
||||
await apiResponsePromise;
|
||||
|
||||
/*
|
||||
* Check the new option is added to the list,
|
||||
* by checking the last aria-hidden
|
||||
|
@ -163,21 +178,6 @@ test.describe( 'Variations tab', { tag: '@gutenberg' }, () => {
|
|||
await expect( newAriaHiddenTokenLocator ).toHaveText(
|
||||
term.name
|
||||
);
|
||||
|
||||
/*
|
||||
* Wait for the async POST request
|
||||
* that creates the new attribute term to finish.
|
||||
*/
|
||||
await page.waitForResponse( ( response ) => {
|
||||
const urlToMatch = `/wp-json/wc/v3/products/attributes/${ newAttrData.id }/terms?name=${ term.name }&slug=${ term.slug }&_locale=user`;
|
||||
|
||||
return (
|
||||
response
|
||||
.url()
|
||||
.includes( encodeURI( urlToMatch ) ) &&
|
||||
response.status() === 201
|
||||
);
|
||||
} );
|
||||
}
|
||||
|
||||
await page
|
||||
|
|
Loading…
Reference in New Issue