Skip to content

Commit

Permalink
Add date and date_gmt to the payload types
Browse files Browse the repository at this point in the history
  • Loading branch information
kevin940726 committed Feb 21, 2023
1 parent 7905184 commit 74718d9
Show file tree
Hide file tree
Showing 3 changed files with 31 additions and 25 deletions.
24 changes: 14 additions & 10 deletions packages/e2e-test-utils-playwright/src/request-utils/pages.ts
Original file line number Diff line number Diff line change
Expand Up @@ -21,8 +21,21 @@ export type CreatePagePayload = {
title?: string;
content?: string;
status: typeof PAGE_STATUS[ number ];
date?: string;
date_gmt?: string;
};

export async function deletePage( this: RequestUtils, id: number ) {
// https://developer.wordpress.org/rest-api/reference/pages/#delete-a-page
return await this.rest( {
method: 'DELETE',
path: `/wp/v2/pages/${ id }`,
params: {
force: true,
},
} );
}

/**
* Delete all pages using REST API.
*
Expand All @@ -41,18 +54,9 @@ export async function deleteAllPages( this: RequestUtils ) {
} );

// Delete all pages one by one.
// https://developer.wordpress.org/rest-api/reference/pages/#delete-a-page
// "/wp/v2/pages" not yet supports batch requests.
await Promise.all(
pages.map( ( page ) =>
this.rest( {
method: 'DELETE',
path: `/wp/v2/pages/${ page.id }`,
params: {
force: true,
},
} )
)
pages.map( ( page ) => deletePage.call( this, page.id ) )
);
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,8 +11,10 @@ export interface Post {

export interface CreatePostPayload {
title?: string;
content: string;
content?: string;
status: 'publish' | 'future' | 'draft' | 'pending' | 'private';
date?: string;
date_gmt: string;
}

/**
Expand Down
28 changes: 14 additions & 14 deletions test/e2e/specs/editor/various/switch-to-draft.spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -13,23 +13,23 @@ test.use( {
},
} );

test.beforeAll( async ( { requestUtils } ) => {
await Promise.all( [
requestUtils.deleteAllPosts(),
requestUtils.deleteAllPages(),
] );
} );

test.afterAll( async ( { requestUtils } ) => {
await Promise.all( [
requestUtils.deleteAllPosts(),
requestUtils.deleteAllPages(),
] );
} );

test.describe(
'Clicking "Switch to draft" on a published/scheduled post/page',
() => {
test.beforeAll( async ( { requestUtils } ) => {
await Promise.all( [
requestUtils.deleteAllPosts(),
requestUtils.deleteAllPages(),
] );
} );

test.afterAll( async ( { requestUtils } ) => {
await Promise.all( [
requestUtils.deleteAllPosts(),
requestUtils.deleteAllPages(),
] );
} );

[ 'schedule', 'publish' ].forEach( ( postStatus ) => {
[ 'large', 'small' ].forEach( ( viewport ) => {
[ 'post', 'page' ].forEach( ( postType ) => {
Expand Down

0 comments on commit 74718d9

Please sign in to comment.