Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Playwright Utils: Fix 'clickBlockOptionsMenuItem' helper #55923

Merged
merged 1 commit into from
Nov 7, 2023

Conversation

Mamaduka
Copy link
Member

@Mamaduka Mamaduka commented Nov 7, 2023

What?

PR fixes a bug where the editor.clickBlockOptionsMenuItem helper failed for menu items displaying keyboard shortcodes.

Why?

The helper should work with any menu item in the Options dropdown.

How?

Switch to page.getByRole(), which uses case-insensitive and substring matching for labels by default.

Testing Instructions

The following e2e test case will fail on the trunk:

/**
 * WordPress dependencies
 */
const { test, expect } = require( '@wordpress/e2e-test-utils-playwright' );

test.describe( 'clickBlockOptionsMenuItem', () => {
	test.beforeEach( async ( { admin } ) => {
		await admin.createNewPost();
	} );

	test( 'should delete a block via options menu', async ( {
		editor,
		page,
	} ) => {
		await editor.canvas
			.getByRole( 'button', { name: 'Add default block' } )
			.click();
		await page.keyboard.type( 'Hey!' );

		await editor.clickBlockOptionsMenuItem( 'Delete' );
		await expect(
			editor.canvas.getByRole( 'document', { name: 'Block: Paragraph' } )
		).toBeHidden();
	} );
} );

@Mamaduka Mamaduka added [Type] Bug An existing feature does not function as intended [Tool] E2E Test Utils /packages/e2e-test-utils labels Nov 7, 2023
@Mamaduka Mamaduka self-assigned this Nov 7, 2023
Copy link

github-actions bot commented Nov 7, 2023

Flaky tests detected in 3619b24.
Some tests passed with failed attempts. The failures may not be related to this commit but are still reported for visibility. See the documentation for more information.

🔍 Workflow run URL: https://github.com/WordPress/gutenberg/actions/runs/6783799696
📝 Reported issues:

@Mamaduka
Copy link
Member Author

Mamaduka commented Nov 7, 2023

Thanks for the review, @swissspidy 🙇

@Mamaduka Mamaduka merged commit e94446a into trunk Nov 7, 2023
55 checks passed
@Mamaduka Mamaduka deleted the fix/click-block-options-menu-item-util branch November 7, 2023 13:03
@github-actions github-actions bot added this to the Gutenberg 17.1 milestone Nov 7, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
[Tool] E2E Test Utils /packages/e2e-test-utils [Type] Bug An existing feature does not function as intended
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants