Fix sidebar attribute control in Products by Attribute block (#49351)

* Fix sidebar attribute control in Products by Attribute block

* Add changelog file

* Linting
This commit is contained in:
Albert Juhé Lluveras 2024-07-11 15:52:57 +02:00 committed by GitHub
parent fa82f493f1
commit ec95afc178
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
3 changed files with 29 additions and 1 deletions

View File

@ -61,7 +61,7 @@ export const ProductsByAttributeInspectorControls = (
selected={ attributes }
onChange={ ( value = [] ) => {
const result = value.map(
( { id, attr_slug: attributeSlug } ) => ( {
( { id, value: attributeSlug } ) => ( {
id,
attr_slug: attributeSlug,
} )

View File

@ -28,4 +28,28 @@ test.describe( `${ blockData.slug } Block`, () => {
blockLocatorFrontend.getByRole( 'listitem' )
).toHaveCount( 9 );
} );
test( 'can change attributes from the sidebar', async ( {
editor,
admin,
frontendUtils,
page,
} ) => {
await admin.createNewPost();
await editor.insertBlock( { name: blockData.slug } );
const blockLocator = await editor.getBlockByName( blockData.slug );
await blockLocator.getByText( 'Color' ).click();
await blockLocator.getByText( 'Done' ).click();
await page.getByText( 'Filter by Product Attribute' ).click();
await page.getByText( 'Color' ).click();
await page.getByText( 'Size' ).click();
await expect( blockLocator.getByRole( 'listitem' ) ).toHaveCount( 1 );
await editor.publishAndVisitPost();
const blockLocatorFrontend = await frontendUtils.getBlockByName(
blockData.slug
);
await expect(
blockLocatorFrontend.getByRole( 'listitem' )
).toHaveCount( 1 );
} );
} );

View File

@ -0,0 +1,4 @@
Significance: patch
Type: fix
Fix sidebar attribute control in Products by Attribute block