-
Notifications
You must be signed in to change notification settings - Fork 4.3k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Migrate template part test to playwright (#41048)
* Migrate template part test to playwright * Apply suggestions from code review Co-authored-by: Kai Hao <kevin830726@gmail.com>
- Loading branch information
1 parent
fcaf478
commit f8313d6
Showing
5 changed files
with
353 additions
and
359 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
11 changes: 0 additions & 11 deletions
11
packages/e2e-test-utils-playwright/src/editor/select-block-by-client-id.ts
This file was deleted.
Oops, something went wrong.
48 changes: 48 additions & 0 deletions
48
packages/e2e-test-utils-playwright/src/editor/select-blocks.ts
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,48 @@ | ||
/** | ||
* External dependencies | ||
*/ | ||
import type { Locator } from '@playwright/test'; | ||
|
||
/** | ||
* Internal dependencies | ||
*/ | ||
import type { Editor } from './index'; | ||
|
||
export async function selectBlocks( | ||
this: Editor, | ||
startSelectorOrLocator: string | Locator, | ||
endSelectorOrLocator?: string | Locator | ||
) { | ||
const startBlock = | ||
typeof startSelectorOrLocator === 'string' | ||
? this.canvas.locator( startSelectorOrLocator ) | ||
: startSelectorOrLocator; | ||
|
||
const endBlock = | ||
typeof endSelectorOrLocator === 'string' | ||
? this.canvas.locator( endSelectorOrLocator ) | ||
: endSelectorOrLocator; | ||
|
||
const startClientId = await startBlock.getAttribute( 'data-block' ); | ||
const endClientId = await endBlock?.getAttribute( 'data-block' ); | ||
|
||
if ( endClientId ) { | ||
await this.page.evaluate( | ||
( [ startId, endId ] ) => { | ||
// @ts-ignore | ||
wp.data | ||
.dispatch( 'core/block-editor' ) | ||
.multiSelect( startId, endId ); | ||
}, | ||
[ startClientId, endClientId ] | ||
); | ||
} else { | ||
await this.page.evaluate( | ||
( [ clientId ] ) => { | ||
// @ts-ignore | ||
wp.data.dispatch( 'core/block-editor' ).selectBlock( clientId ); | ||
}, | ||
[ startClientId ] | ||
); | ||
} | ||
} |
Oops, something went wrong.