Skip to content

Commit

Permalink
Update and fix e2e tests
Browse files Browse the repository at this point in the history
  • Loading branch information
Mamaduka committed May 11, 2024
1 parent 4cf4504 commit fc44acd
Showing 1 changed file with 19 additions and 25 deletions.
44 changes: 19 additions & 25 deletions test/e2e/specs/editor/various/block-renaming.spec.js
Expand Up @@ -36,26 +36,10 @@ test.describe( 'Block Renaming', () => {
page,
pageUtils,
} ) => {
// Turn on block list view by default.
await editor.setPreferences( 'core', {
showListViewByDefault: true,
} );

const listView = page.getByRole( 'treegrid', {
name: 'Block navigation structure',
} );

await editor.insertBlock( {
name: 'core/group',
attributes: { content: 'First Paragraph' },
} );
await editor.insertBlock( { name: 'core/group' } );

// Select via keyboard.
await pageUtils.pressKeys( 'primary+a' );

// Convert to a Group block which supports renaming.
await editor.clickBlockOptionsMenuItem( 'Group' );

await editor.clickBlockOptionsMenuItem( 'Rename' );

const renameMenuItem = page.getByRole( 'menuitem', {
Expand Down Expand Up @@ -107,11 +91,18 @@ test.describe( 'Block Renaming', () => {
'false'
);

// Check custom name reflected in List View.
listView.getByRole( 'link', {
name: 'My new name',
await pageUtils.pressKeys( 'access+o' );
const listView = page.getByRole( 'treegrid', {
name: 'Block navigation structure',
} );

await expect(
listView.getByRole( 'link', {
name: 'My new name',
} ),
'should reflect custom name in List View'
).toBeVisible();

await expect.poll( editor.getBlocks ).toMatchObject( [
{
name: 'core/group',
Expand All @@ -123,7 +114,8 @@ test.describe( 'Block Renaming', () => {
},
] );

// Re-trigger the rename dialog.
// Re-trigger the rename dialog from the List View.
await listView.getByRole( 'button', { name: 'Options' } ).click();
await renameMenuItem.click();

// Expect modal input to contain the custom name.
Expand All @@ -142,10 +134,12 @@ test.describe( 'Block Renaming', () => {

await saveButton.click();

// Check the original block name to reflected in List View.
listView.getByRole( 'link', {
name: 'Group',
} );
await expect(
listView.getByRole( 'link', {
name: 'Group',
} ),
'should reflect original name in List View'
).toBeVisible();

// Expect block to have no custom name (i.e. it should be reset to the original block name).
await expect.poll( editor.getBlocks ).toMatchObject( [
Expand Down

0 comments on commit fc44acd

Please sign in to comment.