Skip to content

Commit 5c6b7e1

Browse files
jorgefilipecostayouknowriad
authored andcommitted
Make clickOnMoreMenuItem not dependent on aria labels (#13166)
The clickOnMoreMenuItem end 2 end test util was dependent on aria labels being present on each menu item. This aria labels are redundant and just duplicate the inner text menu item, they will be removed as soon as #12955 is merged. This commit updates an end 2 end test util that relied on this aria labels being present. This way we will make sure tests pass on #12955 as soon as this PR is merged. ## How has this been tested? I verified the end 2 end tests pass. I reverted all snapshot updates in #12955 and merge that PR with this and I checked the end 2 end tests continue to pass.
1 parent dbac4dc commit 5c6b7e1

1 file changed

Lines changed: 19 additions & 3 deletions

File tree

Lines changed: 19 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,8 @@
1+
/**
2+
* External dependencies
3+
*/
4+
import { first } from 'lodash';
5+
16
/**
27
* Clicks on More Menu item, searches for the button with the text provided and clicks it.
38
*
@@ -7,7 +12,18 @@ export async function clickOnMoreMenuItem( buttonLabel ) {
712
await expect( page ).toClick(
813
'.edit-post-more-menu [aria-label="Show more tools & options"]'
914
);
10-
await page.click(
11-
`.edit-post-more-menu__content button[aria-label="${ buttonLabel }"]`
12-
);
15+
const moreMenuContainerSelector =
16+
'//*[contains(concat(" ", @class, " "), " edit-post-more-menu__content ")]';
17+
let elementToClick = first( await page.$x(
18+
`${ moreMenuContainerSelector }//button[contains(text(), "${ buttonLabel }")]`
19+
) );
20+
// If button is not found, the label should be on the info wrapper.
21+
if ( ! elementToClick ) {
22+
elementToClick = first( await page.$x(
23+
moreMenuContainerSelector +
24+
'//button' +
25+
`/*[contains(concat(" ", @class, " "), " components-menu-item__info-wrapper ")][contains(text(), "${ buttonLabel }")]`
26+
) );
27+
}
28+
await elementToClick.click();
1329
}

0 commit comments

Comments
 (0)