cypress-wp-utils icon indicating copy to clipboard operation
cypress-wp-utils copied to clipboard

insertBlock Command doesn't work with block variations that have multiple backslashes

Open roseg43 opened this issue 2 years ago • 0 comments

Describe the bug

When trying to use insertBlock to insert a block variation with multiple backslashes (i.e. core/query/10up/content-grid, the block cannot be found in the inserter, as the first backslash is being converted to a dash (-) when generating the search selector, making the selector fail.

Steps to Reproduce

  1. Create a block variation (sample registration code added below) of the Query block using a name like 10up/post-grid
  2. Attempt to insert the newly created block in a test
  3. Confirm that cy.insertBlock('core/query/10up/post-grid') generates an invalid selector

Screenshots, screen recording, code snippet

Block Variation Registration example

const VARIATION_NAME = '10up/content-grid';

registerBlockVariation('core/query', {
	name: VARIATION_NAME,
	title: 'Content River',
	description: 'A grid of content that can be manually curated',
	isActive: ({ namespace }) => namespace === VARIATION_NAME,
	attributes: {
		namespace: VARIATION_NAME,
		query: {
			inherit: true,
		},
	},
	scope: ['inserter'],
	innerBlocks: [['10up/post-picker-group', {}, []]],
});

Environment information

No response

WordPress information

I'm using a completely fresh install of WordPress 6.3.2 using wp-env

Code of Conduct

  • [X] I agree to follow this project's Code of Conduct

roseg43 avatar Oct 24 '23 14:10 roseg43