Skip to content

Commit

Permalink
Update tests as drafts are now part of post sttatus
Browse files Browse the repository at this point in the history
  • Loading branch information
olaseni committed May 3, 2024
1 parent f77230c commit 9157e12
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 4 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,10 @@ const selectors = {

// Preview
previewButton: `${ panel } :text("View"):visible, [aria-label="View"]:visible`,

// Post status
postStatusButton: `button.editor-post-status-trigger`,

desktopPreviewMenuItem: ( target: EditorPreviewOptions ) =>
`button[role="menuitem"] span:text("${ target }")`,
previewPane: `.edit-post-visual-editor`,
Expand Down Expand Up @@ -265,7 +269,7 @@ export class EditorToolbarComponent {
*
* This is applicable for the following scenarios:
* - publish of a new article (Publish)
* - update an existing article (Update)
* - update/save an existing article (Update)
* - schedule a post (Schedule)
*/
async clickPublish(): Promise< void > {
Expand All @@ -282,6 +286,11 @@ export class EditorToolbarComponent {
const editorParent = await this.editor.parent();

await Promise.race( [
( async () => {
// Works with Gutenberg >=v18.2.0
await editorParent.locator( selectors.postStatusButton ).click();
await editorParent.getByRole( 'radio', { name: 'Draft' } ).click();
} )(),
( async () => {
// Works with Gutenberg >=v15.8.0
await this.openSettings( 'Settings' );
Expand Down
6 changes: 3 additions & 3 deletions packages/calypso-e2e/src/lib/pages/editor-page.ts
Original file line number Diff line number Diff line change
Expand Up @@ -709,7 +709,7 @@ export class EditorPage {
// is merely being updated.
// If not yet published, a second click on the EditorPublishPanelComponent
// is added to the array of actions.
if ( publishButtonText.toLowerCase() !== 'update' ) {
if ( publishButtonText.toLowerCase() !== 'save' ) {
actionsArray.push( this.editorPublishPanelComponent.publish() );
}

Expand Down Expand Up @@ -769,10 +769,10 @@ export class EditorPage {
*/
async unpublish(): Promise< void > {
const editorParent = await this.editor.parent();

await this.editorToolbarComponent.switchToDraft();
// @TODO: eventually refactor this out to a ConfirmationDialogComponent.
await editorParent.getByRole( 'button' ).getByText( 'OK' ).click();
// Saves the draft
await this.editorToolbarComponent.clickPublish();
// @TODO: eventually refactor this out to a EditorToastNotificationComponent.
await editorParent.getByRole( 'button', { name: 'Dismiss this notice' } ).waitFor();
}
Expand Down

0 comments on commit 9157e12

Please sign in to comment.