forked from WordPress/gutenberg
-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
13 changed files
with
342 additions
and
117 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
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
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
31 changes: 31 additions & 0 deletions
31
packages/e2e-test-utils-playwright/src/request-utils/patterns.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,31 @@ | ||
/** | ||
* Internal dependencies | ||
*/ | ||
import type { RequestUtils } from './index'; | ||
|
||
/** | ||
* Delete all pattern categories using REST API. | ||
* | ||
* @see https://developer.wordpress.org/rest-api/reference/categories/#list-categories | ||
* @param this | ||
*/ | ||
export async function deleteAllPatternCategories( this: RequestUtils ) { | ||
// List all pattern categories. | ||
// https://developer.wordpress.org/rest-api/reference/categories/#list-categories | ||
const categories = await this.rest( { | ||
path: '/wp/v2/wp_pattern_category', | ||
params: { | ||
per_page: 100, | ||
}, | ||
} ); | ||
|
||
// Delete pattern categories. | ||
// https://developer.wordpress.org/rest-api/reference/categories/#delete-a-category | ||
// "/wp/v2/category" does not yet supports batch requests. | ||
await this.batchRest( | ||
categories.map( ( category: { id: number } ) => ( { | ||
method: 'DELETE', | ||
path: `/wp/v2/wp_pattern_category/${ category.id }?force=true`, | ||
} ) ) | ||
); | ||
} |
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 |
---|---|---|
@@ -1,28 +1,25 @@ | ||
/** | ||
* WordPress dependencies | ||
*/ | ||
import { compose } from '@wordpress/compose'; | ||
import { withSelect } from '@wordpress/data'; | ||
import { useSelect } from '@wordpress/data'; | ||
|
||
/** | ||
* Internal dependencies | ||
*/ | ||
import { store as editorStore } from '../../store'; | ||
|
||
export function PostStickyCheck( { hasStickyAction, postType, children } ) { | ||
export default function PostStickyCheck( { children } ) { | ||
const { hasStickyAction, postType } = useSelect( ( select ) => { | ||
const post = select( editorStore ).getCurrentPost(); | ||
return { | ||
hasStickyAction: post._links?.[ 'wp:action-sticky' ] ?? false, | ||
postType: select( editorStore ).getCurrentPostType(), | ||
}; | ||
}, [] ); | ||
|
||
if ( postType !== 'post' || ! hasStickyAction ) { | ||
return null; | ||
} | ||
|
||
return children; | ||
} | ||
|
||
export default compose( [ | ||
withSelect( ( select ) => { | ||
const post = select( editorStore ).getCurrentPost(); | ||
return { | ||
hasStickyAction: post._links?.[ 'wp:action-sticky' ] ?? false, | ||
postType: select( editorStore ).getCurrentPostType(), | ||
}; | ||
} ), | ||
] )( PostStickyCheck ); |
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
Oops, something went wrong.