Skip to content

Commit

Permalink
Fix: Private post with future date becomes public on update (#18834)
Browse files Browse the repository at this point in the history
  • Loading branch information
jorgefilipecosta committed Dec 2, 2019
1 parent 69950b1 commit 5671c0a
Show file tree
Hide file tree
Showing 2 changed files with 37 additions and 2 deletions.
35 changes: 35 additions & 0 deletions packages/e2e-tests/specs/editor/various/post-visibility.test.js
Expand Up @@ -8,6 +8,9 @@ import {
} from '@wordpress/e2e-test-utils';

describe( 'Post visibility', () => {
afterEach( async () => {
await setBrowserViewport( 'large' );
} );
[ 'large', 'small' ].forEach( ( viewport ) => {
it( `can be changed when the viewport is ${ viewport }`, async () => {
await setBrowserViewport( viewport );
Expand All @@ -28,4 +31,36 @@ describe( 'Post visibility', () => {
expect( currentStatus ).toBe( 'private' );
} );
} );

it( 'visibility remains private even if the publish date is in the future', async () => {
await createNewPost();

// Enter a title for this post.
await page.type( '.editor-post-title__input', 'Title' );

await openDocumentSettingsSidebar();

// Set a publish date for the next month.
await page.click( '.edit-post-post-schedule__toggle' );
await page.click( 'div[aria-label="Move forward to switch to the next month."]' );
await (
await page.$x( '//td[contains(concat(" ", @class, " "), " CalendarDay ")][text() = "15"]' )
)[ 0 ].click();

await page.click( '.edit-post-post-visibility__toggle' );

const [ privateLabel ] = await page.$x( '//label[text()="Private"]' );
await privateLabel.click();

// Enter a title for this post.
await page.type( '.editor-post-title__input', ' Changed' );

await page.click( '.editor-post-publish-button' );

const currentStatus = await page.evaluate( () => {
return wp.data.select( 'core/editor' ).getEditedPostAttribute( 'status' );
} );

expect( currentStatus ).toBe( 'private' );
} );
} );
4 changes: 2 additions & 2 deletions packages/editor/src/components/post-publish-button/index.js
Expand Up @@ -63,10 +63,10 @@ export class PostPublishButton extends Component {
let publishStatus;
if ( ! hasPublishAction ) {
publishStatus = 'pending';
} else if ( isBeingScheduled ) {
publishStatus = 'future';
} else if ( visibility === 'private' ) {
publishStatus = 'private';
} else if ( isBeingScheduled ) {
publishStatus = 'future';
} else {
publishStatus = 'publish';
}
Expand Down

0 comments on commit 5671c0a

Please sign in to comment.