-
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.
Add e2e tests for filtering and searching patterns (#54906)
* Add e2e tests for filtering and searching patterns * Update packages/e2e-test-utils-playwright/src/admin/visit-site-editor.ts Co-authored-by: Aaron Robertshaw <[email protected]> --------- Co-authored-by: Aaron Robertshaw <[email protected]>
- Loading branch information
1 parent
3cc9af1
commit 7d67425
Showing
6 changed files
with
240 additions
and
63 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
28 changes: 0 additions & 28 deletions
28
packages/e2e-test-utils-playwright/src/request-utils/blocks.js
This file was deleted.
Oops, something went wrong.
64 changes: 64 additions & 0 deletions
64
packages/e2e-test-utils-playwright/src/request-utils/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,64 @@ | ||
/** | ||
* Internal dependencies | ||
*/ | ||
import type { RequestUtils } from './index'; | ||
|
||
type CreateBlockPayload = { | ||
date?: string; | ||
date_gmt?: string; | ||
slug?: string; | ||
title: string; | ||
status: 'publish' | 'future' | 'draft' | 'pending' | 'private'; | ||
content?: string; | ||
meta?: unknown; | ||
wp_pattern_category?: number[]; | ||
}; | ||
|
||
/** | ||
* Delete all blocks using REST API. | ||
* | ||
* @see https://developer.wordpress.org/rest-api/reference/blocks/#list-editor-blocks | ||
* @param this | ||
*/ | ||
export async function deleteAllBlocks( this: RequestUtils ) { | ||
// List all blocks. | ||
// https://developer.wordpress.org/rest-api/reference/blocks/#list-editor-blocks | ||
const blocks = await this.rest( { | ||
path: '/wp/v2/blocks', | ||
params: { | ||
per_page: 100, | ||
// All possible statuses. | ||
status: 'publish,future,draft,pending,private,trash', | ||
}, | ||
} ); | ||
|
||
// Delete blocks. | ||
// https://developer.wordpress.org/rest-api/reference/blocks/#delete-a-editor-block | ||
// "/wp/v2/posts" not yet supports batch requests. | ||
await this.batchRest( | ||
blocks.map( ( block: { id: number } ) => ( { | ||
method: 'DELETE', | ||
path: `/wp/v2/blocks/${ block.id }?force=true`, | ||
} ) ) | ||
); | ||
} | ||
|
||
/** | ||
* Creates a new block using the REST API. | ||
* | ||
* @see https://developer.wordpress.org/rest-api/reference/blocks/#create-a-editor-block. | ||
* @param this | ||
* @param payload Block payload. | ||
*/ | ||
export async function createBlock( | ||
this: RequestUtils, | ||
payload: CreateBlockPayload | ||
) { | ||
const block = await this.rest( { | ||
path: '/wp/v2/blocks', | ||
method: 'POST', | ||
data: { ...payload }, | ||
} ); | ||
|
||
return block; | ||
} |
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
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