Skip to content

Commit

Permalink
Enable skipped E2E tests for attributes (woocommerce#50143)
Browse files Browse the repository at this point in the history
* Enable test to add existing attributes

* Enable test to update product attribute

* Add changelog

* Locate item by aria-label instead of label

* Add blur to the summary field
  • Loading branch information
octaedro authored Aug 1, 2024
1 parent 6a9278d commit 03bbc13
Show file tree
Hide file tree
Showing 3 changed files with 22 additions and 15 deletions.
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
Significance: minor
Type: fix

Enable skipped E2E tests for attributes #50143
Original file line number Diff line number Diff line change
Expand Up @@ -51,6 +51,14 @@ test.describe( 'General tab', { tag: '@gutenberg' }, () => {
.last()
.fill( productData.summary );

// We blur the summary field to hide the toolbar before clicking on the regular price field.
await page
.locator(
'[data-template-block-id="basic-details"] .components-summary-control'
)
.last()
.blur();

const regularPrice = page
.locator( 'input[name="regular_price"]' )
.first();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -267,36 +267,31 @@ test(
}
);

test.skip(
test(
'can add existing attributes',
{ tag: '@gutenberg' },
async ( { page, product, attributes } ) => {
await test.step( 'go to product editor, Organization tab', async () => {
await page.goto(
`wp-admin/post.php?post=${ product.id }&action=edit`
);
const getAttributesResponsePromise = page.waitForResponse(
( response ) =>
response.url().includes( '/terms?attribute_id=' ) &&
response.status() === 200
);
await page.getByRole( 'tab', { name: 'Organization' } ).click();
await getAttributesResponsePromise;
} );

await test.step( 'add an existing attribute', async () => {
await page.getByRole( 'button', { name: 'Add new' } ).click();

await page.waitForLoadState( 'domcontentloaded' );

// Add attributes that do not exist
await page.getByPlaceholder( 'Search or create attribute' ).click();
await page
.locator( '.woocommerce-attributes-combobox input' )
.click();

// Unless we wait for the list to be visible, the attribute name will be filled too soon and the test will fail.
await waitForAttributeList( page );

await page
.getByPlaceholder( 'Search or create attribute' )
.locator( '.woocommerce-attributes-combobox input' )
.fill( attributes.attribute.name );
await page
.getByRole( 'option', { name: attributes.attribute.name } )
Expand All @@ -306,7 +301,7 @@ test.skip(
await page.getByPlaceholder( 'Search or create value' ).click();

for ( const term of attributes.terms ) {
await page.getByLabel( term.name, { exact: true } ).check();
await page.getByText( term.name, { exact: true } ).click();
}

await page.keyboard.press( 'Escape' );
Expand Down Expand Up @@ -355,9 +350,7 @@ test.skip(
}
);

// Test skipped because an issue with the options not always loading makes it flaky.
// See https://github.com/woocommerce/woocommerce/issues/44925
test.skip(
test(
'can update product attributes',
{ tag: '@gutenberg' },
async ( { page, productWithAttributes } ) => {
Expand All @@ -376,7 +369,9 @@ test.skip(
await page.reload();
await page.getByRole( 'button', { name: 'Edit' } ).click();
await expect(
page.getByLabel( `Remove ${ attribute.options[ 0 ] }` )
page.locator(
`button[aria-label="Remove ${ attribute.options[ 0 ] }"]`
)
).toBeVisible( { timeout: 2000 } );
},
{
Expand Down

0 comments on commit 03bbc13

Please sign in to comment.