Tweak create-product-attribute spec (#42854)

* Adds missing aria-label and tabindex HTML attributes to the Help tip element for "Product data" on "Add new product" page.

* Escape HTML tags

* Added changelog

* Update comment

* Amend method for selecting "New attribute" placeholder.

* Restore use of `getByRole()` and select first instance (two are being matched, in some cases).

* Use last match (in some test runs, `getByRole()` is unexpectedly matching more than 1 heading.

---------

Co-authored-by: Sagar Tamang <mi5t4n@gmail.com>
This commit is contained in:
Barry Hughes 2023-12-19 16:35:20 -08:00 committed by GitHub
parent 310de4cc9f
commit d033a40b26
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
3 changed files with 10 additions and 3 deletions

View File

@ -0,0 +1,4 @@
Significance: patch
Type: fix
Adds missing aria-label and tabindex HTML attributes to the Help tip element for "Product data" on "Add new product" page

View File

@ -176,7 +176,10 @@ jQuery( function ( $ ) {
function change_product_type_tip( content ) {
$( '#tiptip_holder' ).removeAttr( 'style' );
$( '#tiptip_arrow' ).removeAttr( 'style' );
$( '.woocommerce-product-type-tip' ).tipTip( {
$( '.woocommerce-product-type-tip' )
.attr( 'tabindex', '0' )
.attr( 'aria-label', $( '<div />' ).html( content ).text() ) // Remove HTML tags.
.tipTip( {
attribute: 'data-tip',
content: content,
fadeIn: 50,

View File

@ -73,7 +73,7 @@ test.describe( 'Add product attributes', () => {
await expect(
page.getByRole( 'heading', {
name: 'New attribute',
} )
} ).first()
).toBeVisible();
} );
}
@ -147,7 +147,7 @@ test.describe( 'Add product attributes', () => {
await test.step( `Expect "${ attributeName }" to appear on the list of saved attributes, and expand it.`, async () => {
const heading_attributeName = page.getByRole( 'heading', {
name: attributeName,
} );
} ).last();
await expect( heading_attributeName ).toBeVisible();
await heading_attributeName.click();