Skip to content

Commit

Permalink
Refactor Instant Search tests to verify toolbar button visibility whe…
Browse files Browse the repository at this point in the history
…n Search block is inside Query block with enhanced pagination. Removed checks for renaming Search block to "Instant Search" in List View and Inspector Controls, focusing on button visibility instead.
  • Loading branch information
michalczaplinski committed Jan 6, 2025
1 parent 1d70719 commit e0dd93b
Showing 1 changed file with 26 additions and 34 deletions.
60 changes: 26 additions & 34 deletions test/e2e/specs/interactivity/instant-search.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -560,7 +560,7 @@ test.describe( 'Instant Search', () => {
await requestUtils.deleteAllPosts();
} );

test( 'should rename Search block to "Instant Search" in the List View and Inspector Controls', async ( {
test( 'should hide specific toolbar buttons when Search block is inside Query block with enhanced pagination', async ( {
editor,
page,
} ) => {
Expand Down Expand Up @@ -595,56 +595,48 @@ test.describe( 'Instant Search', () => {
} );
await editor.selectBlocks( searchBlock );

// Make sure the List View is open
await editor.openListView();
const listView = page.getByRole( 'region', {
name: 'Document Overview',
// Verify that the specific toolbar buttons are hidden
const toolbar = page.getByRole( 'toolbar', {
name: 'Block tools',
} );
await expect( listView ).toBeVisible();

// Check that the Search block which is a child of the Query Loop block
// is renamed to "Instant Search" in the List View
await expect(
listView.getByText( 'Instant Search' )
).toBeVisible();

const editorSettings = page.getByRole( 'region', {
name: 'Editor settings',
} );

const blockCard = editorSettings.locator(
'.block-editor-block-card'
);

// Check that the Search block is renamed to "Instant Search" in the Inspector Controls title
await editor.canvas
.getByRole( 'document', { name: 'Block: Search' } )
.click();
await expect( blockCard ).toContainText( 'Instant Search' );
toolbar.getByRole( 'button', {
name: 'Change button position',
} )
).toBeHidden();
await expect(
toolbar.getByRole( 'button', { name: 'Use button with icon' } )
).toBeHidden();

// Select the Query Loop block and open the Advanced View and disable enhanced pagination
// Select the Query Loop block and disable enhanced pagination
await editor.selectBlocks(
editor.canvas.getByRole( 'document', {
name: 'Block: Query Loop',
} )
);
await editor.openDocumentSettingsSidebar();
const editorSettings = page.getByRole( 'region', {
name: 'Editor settings',
} );
await editorSettings
.getByRole( 'button', { name: 'Advanced' } )
.click();
await editorSettings
.getByRole( 'checkbox', { name: 'Reload full page' } )
.click();

// Check that the block is renamed back to "Search" in the Inspector Controls title
await editor.canvas
.getByRole( 'document', { name: 'Block: Search' } )
.click();
await expect( blockCard ).toContainText( 'Search' );
await expect( blockCard ).not.toContainText( 'Instant Search' );
// Select the Search block again
await editor.selectBlocks( searchBlock );

// Check that the Search block is renamed back to "Search" in the List View
await expect( listView.getByText( 'Search' ) ).toBeVisible();
// Verify that the toolbar buttons are now visible
await expect(
toolbar.getByRole( 'button', {
name: 'Change button position',
} )
).toBeVisible();
await expect(
toolbar.getByRole( 'button', { name: 'Use button with icon' } )
).toBeVisible();
} );
} );
} );

0 comments on commit e0dd93b

Please sign in to comment.