-
Notifications
You must be signed in to change notification settings - Fork 33
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #1934 from Codeinwp/fix/live-search-css
Fix Live Search initialisation inside containers like Popup Block
- Loading branch information
Showing
2 changed files
with
155 additions
and
16 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,54 @@ | ||
/** | ||
* WordPress dependencies | ||
*/ | ||
import { test, expect } from '@wordpress/e2e-test-utils-playwright'; | ||
|
||
test.describe( 'Live Search Block', () => { | ||
test.beforeEach( async({ admin }) => { | ||
await admin.createNewPost(); | ||
}); | ||
|
||
test( 'can be created by typing "/live-search"', async({ editor, page }) => { | ||
|
||
// Create a Progress Block with the slash block shortcut. | ||
await page.click( 'role=button[name="Add default block"i]' ); | ||
await page.keyboard.type( '/live-search' ); | ||
await page.keyboard.press( 'Enter' ); | ||
|
||
const blocks = await editor.getBlocks(); | ||
|
||
// Since Live Search is a variation of the Search block, we check for the Search block instead. | ||
const hasSearch = blocks.some( ( block ) => 'core/search' === block.name ); | ||
|
||
expect( hasSearch ).toBeTruthy(); | ||
}); | ||
|
||
test( 'add a live search block inside a Popup and check results rendering', async({ admin, editor, page }) => { | ||
await editor.insertBlock({ | ||
name: 'themeisle-blocks/popup', | ||
innerBlocks: [ | ||
{ | ||
name: 'core/search', | ||
attributes: { | ||
otterIsLive: true | ||
} | ||
} | ||
] | ||
}); | ||
|
||
const postId = await editor.publishPost(); | ||
|
||
await page.goto( `/?p=${postId}` ); | ||
|
||
const input = page.locator( '.otter-popup__modal_body .o-live-search input' ); | ||
|
||
expect ( input ).toBeVisible(); | ||
|
||
await input.fill( 'u' ); | ||
|
||
// If the width is 0, it means the results are not rendered properly. | ||
const container = page.locator( '.o-live-search .container-wrap' ); | ||
let width = await container.evaluate( node => node.offsetWidth ); | ||
expect( width ).toBeGreaterThan( 0 ); | ||
}); | ||
}); |